Created
April 20, 2019 18:45
-
-
Save victorsteven/f7051a95554bc8e3e439737bfa55be1b to your computer and use it in GitHub Desktop.
Root index.js file
This file contains hidden or 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
| import config from 'dotenv'; | |
| import express from 'express'; | |
| import bodyParser from 'body-parser'; | |
| import bookRoutes from './server/routes/BookRoutes'; | |
| config.config(); | |
| const app = express(); | |
| app.use(bodyParser.json()); | |
| app.use(bodyParser.urlencoded({ extended: false })); | |
| const port = process.env.PORT || 8000; | |
| app.use('/api/v1/books', bookRoutes); | |
| // when a random route is inputed | |
| app.get('*', (req, res) => res.status(200).send({ | |
| message: 'Welcome to this API.', | |
| })); | |
| app.listen(port, () => { | |
| console.log(`Server is running on PORT ${port}`); | |
| }); | |
| export default app; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment