-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (17 loc) · 702 Bytes
/
index.js
File metadata and controls
26 lines (17 loc) · 702 Bytes
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
const express = require('express');
const bodyParser = require('body-parser');
const controllers = require('./controllers/productController');
const middlewares = require('./middlewares');
const app = express();
app.use(express.json());
app.use(middlewares.log);
app.use(middlewares.checkAuthToken);
app.use(bodyParser.urlencoded({ extended: false }));
app.get('/products', controllers.getAllProducts);
app.get('/product/:id', controllers.getProductById);
app.post('/product', controllers.createProduct);
app.delete('/product/:id', controllers.deleteProductById);
app.put('/product/:id', controllers.editProductById);
app.listen(3000, () => {
console.log('App listening on port 3000!');
});