-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (34 loc) · 990 Bytes
/
app.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
45
46
47
'use strict';
const express = require('express');
const bodyparser = require('body-parser');
const compression = require('compression');
const helmet = require('helmet')
const app = express();
// parse application/x-www-form-urlencoded
app.use(bodyparser.urlencoded({ extended: false }));
// parse application/json
app.use(bodyparser.json());
// compress all responses
app.use(compression());
app.use(helmet());
app.get('/hello/:name', (req, res) => {
res.send(`Hello ${req.params.name}`);
});
app.get('/about-us', (req, res) => {
res.send('We are developers!!!');
});
app.get('/contacts', (req, res) => {
res.send('Our contacts');
});
app.get('/foo', (req, res) => {
res.send('foooo...');
});
const server = app.listen(8888, () => {
console.log('app is listening on port 8888 ...');
});
process.on('SIGINT', () => {
console.info('closing server connection ...');
server.close(() => {
console.log('server connection closed ...');
});
});