Last active
December 3, 2019 13:08
-
-
Save jasheloper/0d3b4ed534bdc3cab44b2e77c6a78a2e to your computer and use it in GitHub Desktop.
Creating a file to will handle all routes related to the user resource.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
router.get('/', (req, res) => { | |
res.status(200).send('hello from the GET /users endpoint'); | |
}); | |
router.get('/:id', (req, res) => { | |
res.status(200).send('hello from the GET /users/:id endpoint'); | |
}); | |
router.post('/', (req, res) => { | |
res.status(200).send('hello from the POST /users endpoint'); | |
}); | |
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const userRoutes = require('./users/userRoutes'); | |
const productRoutes = require('./products/productRoutes'); | |
const clientRoutes = require('./clients/clientRoutes'); | |
const server = express(); | |
server.use('/users', userRoutes); | |
server.use('/products', productRoutes); | |
server.use('/clients', clientRoutes); | |
server.listen(8000, () => console.log('API running on port 8000')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment