forked from faren/NodeJS-API-KONG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (43 loc) · 888 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
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const customers = [
{
id: 5,
first_name: 'Dodol',
last_name: 'Dargombez'
},
{
id: 6,
first_name: 'Nyongot',
last_name: 'Gonzales'
}
];
const clients = [
{
id: 1,
first_name: 'Haha',
last_name: 'Hehe'
},
{
id: 2,
first_name: 'Lala',
last_name: 'Lili'
}
];
app.use(bodyParser.json());
app.get('/api/v1/customers', (req, res) => {
res.json(customers);
});
app.get('/api/v1/customers/:id', (req, res) => {
res.json(customers[req.params.id]);
});
app.get('/api/v1/clients', (req, res) => {
res.json(clients);
});
app.get('/api/v1/clients/:id', (req, res) => {
res.json(clients[req.params.id]);
});
app.listen(10000, () => {
console.log(`Server started!`);
});