forked from mike-marcacci/gandhi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (25 loc) · 936 Bytes
/
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
'use strict'
const fs = require('fs')
const cluster = require('cluster')
// the config
const config = process.argv.length > 2 ?
// config from argument
require(['/', '.'].indexOf(process.argv[2][0]) === -1
? './' + process.argv[2]
: process.argv[2])
: fs.existsSync(__dirname + '/config.json') ||
fs.existsSync(__dirname + '/config.js') ||
fs.existsSync(__dirname + '/config/index.js') ?
// config in root directory
require('./config')
// default config
: require('./config.default.js')
const gandhi = require('./lib/index.js')(config)
require('./setup/index.js')(config)
const app = require('express')()
// bring in gandhi
app.use(config.root, gandhi)
// this needs to be here because Angular is stupid, and fails to use any sensible query string
// format... we need to find a better way to fix this, probably on the client side.
app.set('query parser', 'simple')
app.listen(config.port)