Commit 4f3d0f3e authored by Vadim's avatar Vadim

fixup! Конец занятия 74

parent 851d1c8a
const express = require('express');
const router = express.Router();
const db = require('./db/fileDb');
db.init();
router.get('/', (req, res) => {
res.send('List of products will be here')
});
router.get('/:id', (req, res) => {
res.send('Single product will be here' + req.params.id)
});
router.post('/', (req, res) => {
console.log('Create product', req.body);
db.addItem(req.body);
res.send('Create product will be here')
});
module.exports = router;
\ No newline at end of file
const express = require('express');
const products = require('./app/products');
const app = express();
const port = 8000;
app.use(express.json())
app.use('/products', products);
app.listen(port, () => {
console.log(`Server started on port ${port}`)
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment