UNPKG

2.61 kBJavaScriptView Raw
1/*****
2 License
3 --------------
4 Copyright © 2017 Bill & Melinda Gates Foundation
5 The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
10
11 Contributors
12 --------------
13 This is the official list of the Mojaloop project contributors for this file.
14 Names of the original copyright holders (individuals or organizations)
15 should be listed with a '*' in the first column. People who have
16 contributed from an organization can be listed under the organization
17 that actually holds the copyright for their contributions (see the
18 Gates Foundation organization for an example). Those individuals should have
19 their names indented and be marked with a '-'. Email address can be added
20 optionally within square brackets <email>.
21
22 * Gates Foundation
23 - Name Surname <name.surname@gatesfoundation.com>
24
25 * ModusBox
26 - Neal Donnan <neal.donnan@modusbox.com>
27 - Juan Correa <juan.correa@modusbox.com>
28 - Rajiv Mothilal <rajiv.mothilal@modusbox.com>
29 - Miguel de Barros <miguel.debarros@modusbox.com>
30
31 --------------
32 ******/
33
34'use strict'
35
36const Handler = require('./handler')
37const Factory = require('./factory')
38const Enums = require('./enums')
39
40const plugin = {
41 name: 'error-handler',
42 register: function (server) {
43 server.ext('onPreResponse', Handler.onPreResponse)
44 }
45}
46
47const validateRoutes = (options = {}) => {
48 options.abortEarly = false
49 const language = options.language || {}
50 language.key = '{{!key}} '
51 options.language = language
52 return options
53}
54
55module.exports = {
56 plugin,
57 Handler: Handler,
58 validateRoutes,
59 Factory: Factory,
60 Enums: Enums,
61 CreateFSPIOPError: Factory.createFSPIOPError,
62 CreateFSPIOPErrorFromJoiError: Factory.createFSPIOPErrorFromJoiError,
63 CreateInternalServerFSPIOPError: Factory.createInternalServerFSPIOPError,
64 CreateFSPIOPErrorFromErrorInformation: Factory.createFSPIOPErrorFromErrorInformation,
65 CreateFSPIOPErrorFromErrorCode: Factory.createFSPIOPErrorFromErrorCode,
66 ReformatFSPIOPError: Factory.reformatFSPIOPError,
67 ValidateFSPIOPErrorCode: Factory.validateFSPIOPErrorCode,
68 FindFSPIOPErrorCode: Enums.findFSPIOPErrorCode
69}