UNPKG

2.76 kBJavaScriptView Raw
1/*
2
3 ----------------------------------------------------------------------------
4 | qewd-ripple: QEWD-based Middle Tier for Ripple OSI |
5 | |
6 | Copyright (c) 2016-17 Ripple Foundation Community Interest Company |
7 | All rights reserved. |
8 | |
9 | http://rippleosi.org |
10 | Email: code.custodian@rippleosi.org |
11 | |
12 | Author: Rob Tweed, M/Gateway Developments Ltd |
13 | |
14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | you may not use this file except in compliance with the License. |
16 | You may obtain a copy of the License at |
17 | |
18 | http://www.apache.org/licenses/LICENSE-2.0 |
19 | |
20 | Unless required by applicable law or agreed to in writing, software |
21 | distributed under the License is distributed on an "AS IS" BASIS, |
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
23 | See the License for the specific language governing permissions and |
24 | limitations under the License. |
25 ----------------------------------------------------------------------------
26
27 16 October 2017
28
29*/
30
31var ewdRipple = require('qewd-ripple/lib/startup');
32
33var config = {
34 port: 3000,
35 poolSize: 4,
36 ripple: {
37 mode: 'demo'
38 },
39 cors: true,
40 bodyParser: require('body-parser') // over-rides default setting for limit
41};
42
43config.addMiddleware = function(bodyParser, app) {
44
45 app.use(bodyParser.json({limit: '1mb'}));
46 app.use(bodyParser.urlencoded({limit: '1mb', extended: true}));
47
48 require('body-parser-xml')(bodyParser);
49
50 app.use(bodyParser.xml({
51 limit: '1MB',
52 xmlParseOptions: {
53 explicitArray: false
54 }
55 }));
56
57 // custom error handler for XML parsing errors:
58
59 app.use(function(err, req, res, next) {
60 if (req.headers['content-type'] && req.headers['content-type'] === 'text/xml') {
61 res.status(500).send({ error: 'Unable to parse XML - ' + err});
62 }
63 else {
64 next(err);
65 }
66 });
67};
68
69ewdRipple.start(config);