UNPKG

3.27 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 Many thanks to Ward DeBacker for help with custom router response handling
30
31*/
32
33
34var config = {
35 managementPassword: 'keepThisSecret!',
36 serverName: 'New QEWD Server',
37 port: 8080,
38 poolSize: 1,
39 database: {
40 type: 'cache',
41 params: {
42 path: '/opt/cache/mgr',
43 username: '_SYSTEM',
44 password: 'SYS',
45 namespace: 'USER'
46 }
47 }
48};
49
50var qewd = require('qewd').master;
51
52/*
53 //Optional - add custom Express middleware, eg:
54
55 // first load the intercept
56
57 var xp = qewd.intercept();
58
59 // now you can add your own custom routes..:
60
61 xp.app.get('/testx', function(req, res) {
62 console.log('*** /testx query: ' + JSON.stringify(req.query));
63 res.send({
64 hello: 'world',
65 query: JSON.stringify(req.query)
66 });
67 // or use ewd-qoper8-express handler
68 //xp.qx.handleMessage(req, res);
69 });
70
71 // or, even simpler, using ewd-qoper8-express router:
72
73 xp.app.use('/test', xp.qx.router());
74
75 // router + custom response handling:
76
77 xp.app.use('/report', xp.qx.router({ nextCallback: true }), function(req, res) {
78 var message = res.locals.message;
79 res.set('Content-Type', 'application/xml');
80 if (message.error) {
81 res.send(js2xmlparser('error', message));
82 }
83 else {
84 res.send(js2xmlparser(message.json.root || 'xmlRoot', message.json.data || {}));
85 }
86 });
87
88*/
89
90
91qewd.start(config);