-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
56 lines (44 loc) · 1.48 KB
/
server.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ***********************
* Initialize Middleware *
* **********************/
var express = require('express');
var httpServer = require('http');
var files = require('fs');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
var package = require('./package.json')
const VERSION = package.version;
const VENDOR_NAME = 'Apex Data Solutions, LLC';
const description = package.description;
app.use(bodyParser.json({ strict: false, limit: 50000000, inflate: true }));
/* **************
* CONFIGURE *
* **************/
app.use(express.static(path.resolve("./")));
app.post('/test', function (req, res) {
//add extra header
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
//the JSON is in the body
console.dir(req.body);
//the querystring is here:
console.log(req.query)
//here you send a response / confirmation to the client
res.type('application/json');
res.send(JSON.stringify({ err: 'false' }));
});
/* ******************
* Start the server *
* ******************/
var port = 1337;
//add extra header
app.use(function (req, res, next) {
//add extra header
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
var server = app.listen(port, function () {
console.log('Listening on port:', port);
});