-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
59 lines (45 loc) · 1.61 KB
/
app.js
File metadata and controls
59 lines (45 loc) · 1.61 KB
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
57
58
59
// server.js
var express = require('express');
var bodyParser = require('body-parser');
var argv = require('minimist')(process.argv.slice(2));
var app = express();
var subpath = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({ type: 'application/json'}));
// //app.use("/v1", subpath);
var api = require('./app/session/api'); //can waka dipake
require('./app/routes')(app);
var swagger = require('swagger-node-express').createNew(subpath);
app.use(express.static('dist'));
swagger.setApiInfo({
title: "example API",
description: "API to do something, manage something...",
termsOfServiceUrl: "",
contact: "chandraocest@gmail.com",
license: "",
licenseUrl: ""
});
app.get('/api-docs', function(req, res){
res.sendFile(__dirname + '/dist/index.html');
});
//set api-docs
swagger.configureSwaggerPaths('/', 'api-docs.json', '');
//configure the API domain
var domain = '10.14.206.217';
if(argv.domain !== undefined)
domain = argv.domain;
else
console.log('No --domain=xxx specified, taking default hostname "localhost".');
// Configure the API port
var port = 8080;
if(argv.port !== undefined)
port = argv.port;
else
console.log('No --port=xxx specified, taking default port ' + port + '.')
var applicationUrl = "http://" + domain + ":" + port + "";
swagger.configure(applicationUrl, '1.0.0');
var server = app.listen(port, domain, function() {
var host = server.address().address
var port = server.address().port
//console.log("Example app listening at http://%s:%s", host, port);
});