-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (30 loc) · 1.03 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
const http = require('http');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const cors = require('cors');
const middleware = require('./utils/middleware');
const featRouter = require('./controllers/feats');
const userRouter = require('./controllers/users');
const loginRouter = require('./controllers/login');
const locationRouter = require('./controllers/locations');
const propertiesRouter = require('./controllers/properties');
const config = require('./utils/config');
app.use(cors());
app.use(bodyParser.json({ limit: '10mb' }));
app.use(middleware.logger);
app.use('/api/login', loginRouter);
app.use('/api/users', userRouter);
app.use('/api/feats', featRouter);
app.use('/api/locations', locationRouter);
app.use('/api/properties', propertiesRouter);
app.use(middleware.error);
const server = http.createServer(app);
server.listen(config.port, () => {
console.log(`Server running on port ${config.port}`);
});
server.on('close', () => {
});
module.exports = {
app, server
};