-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapp.ts
31 lines (24 loc) · 777 Bytes
/
app.ts
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
/**
* Main application file
*/
import * as express from 'express'
import * as http from 'http'
import * as mongoose from 'mongoose'
import config from './config/environment'
import expressConfig from './config/express'
import routesConfig from './routes'
// Set default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// Connect to database
mongoose.connect(config.mongo.uri, config.mongo.options);
// Setup server
const app: express.Application = express();
const server = http.createServer(app)
expressConfig(app)
routesConfig(app)
// Start server
server.listen(config.port, config.ip, () => {
console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
})
// Expose app
export default app