-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (32 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fs = require('fs');
const http = require('http');
const soap = require('soap');
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
// TODO: require mongoose models.
const models = require('./lib/models');
// SOAP service
const services = require('./lib/services')(models);
const KantorCabangService = { KantorCabang: { KantorCabangPort: services } };
// Express app
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// WSDL specification
const xml = fs.readFileSync('specification.wsdl', 'utf8');
app.get('/wsdl', (req, res) => res.set('Content-Type', 'text/xml').send(xml));
// Client app
const client = require('./lib/client')(models);
app.use(client);
// Initialize database connection
mongoose.connect('mongodb://localhost/bank');
// Start server
const server = http.createServer(app);
const PORT = process.env.PORT || 8888;
server.listen(PORT, () => console.log(`Listening at ${PORT}`));
const soapServer = soap.listen(server, '/', KantorCabangService, xml);
// UNCOMMENT THIS FOR SERVER LOGGING
// soapServer.log = function (type, data) {
// console.log(type, data);
// };