-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (28 loc) · 819 Bytes
/
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
import 'babel-polyfill';
import express from 'express';
import cool from 'cool-ascii-faces';
const app = express();
app.set('port', (process.env.PORT || 5000));
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.get('/cool', (req, res) => {
res.send(`${cool()} Hey man...`);
});
app.get('/404', (req, res) => {
res.status(404).send();
});
app.get('/403', (req, res) => {
res.status(403).send({api: 'unauthorized'});
});
app.all('/secret', (req, res, next) => {
res.send('Accessing the secret section ...');
console.log('Accessing the secret section ...');
next(); // pass control to the next handler
});
app.all('/*', (req, res, next) => {
res.send('going deeper...');
});
app.listen(app.get('port'), () => {
console.log(`Example app listening on port ${app.get('port')}!`);
});