UNPKG

3.13 kBJavaScriptView Raw
1/*
2
3 ----------------------------------------------------------------------------
4 | qewd: Quick and Easy Web Development |
5 | |
6 | Copyright (c) 2017 M/Gateway Developments Ltd, |
7 | Reigate, Surrey UK. |
8 | All rights reserved. |
9 | |
10 | http://www.mgateway.com |
11 | Email: rtweed@mgateway.com |
12 | |
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 3 January 2017
28
29*/
30
31
32var config = {
33 managementPassword: 'keepThisSecret!',
34 serverName: 'New QEWD Server',
35 port: 8080,
36 poolSize: 1,
37 database: {
38 type: 'cache',
39 params: {
40 path: '/home/ubuntu/globalsdb/mgr'
41 }
42 }
43};
44
45var qewd = require('qewd').master;
46
47/*
48 //Optional - add custom Express middleware, eg:
49
50 // first load the intercept
51
52 var xp = qewd.intercept();
53
54 // now you can add your own custom routes..:
55
56 xp.app.get('/testx', function(req, res) {
57 console.log('*** /testx query: ' + JSON.stringify(req.query));
58 res.send({
59 hello: 'world',
60 query: JSON.stringify(req.query)
61 });
62 // or use ewd-qoper8-express handler
63 //xp.qx.handleMessage(req, res);
64 });
65
66 // or, even simpler, using ewd-qoper8-express router:
67
68 xp.app.use('/test', xp.qx.router());
69
70 // router + custom response handling:
71
72 xp.app.use('/report', xp.qx.router({ nextCallback: true }), function(req, res) {
73 var message = res.locals.message;
74 res.set('Content-Type', 'application/xml');
75 if (message.error) {
76 res.send(js2xmlparser('error', message));
77 }
78 else {
79 res.send(js2xmlparser(message.json.root || 'xmlRoot', message.json.data || {}));
80 }
81 });
82
83*/
84
85
86qewd.start(config);