-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (32 loc) · 1.1 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
39
40
41
42
43
44
const express = require('express');
const http = require('http');
const morgan = require('morgan');
const bodyParser = require('body-parser');
/*Routers requires*/
const dishRouter = require('./routes/dishRouter');
const leaderRouter = require('./routes/leaderRouter');
const promotionRouter = require('./routes/promotionRouter');
/*end Routers requires*/
const hostname = 'localhost';
const port = 3000;
const app = express();
app.use(morgan('dev'));
app.use(bodyParser.json());
/*Routers*/
app.use('/dishes', dishRouter);
app.use('/leaders', leaderRouter);
app.use('/promotions', promotionRouter);
// app.use('/dishes/:dishId', dishRouter);
// app.use('/leaders/:leaderId', dishRouter);
// app.use('/promotions/:promotionId', dishRouter);
/*end Routers*/
app.use(express.static(__dirname+ '/public'));
app.use((req, res, next) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html');
res.end('<html><body><h1>Express Server</h1></body></html>');
});
const server = http.createServer(app);
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}`);
});