Created
July 7, 2019 05:02
-
-
Save otoloye/166625fab29a8f3a3f06aaedd7a7ec92 to your computer and use it in GitHub Desktop.
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
import express from 'express'; | |
import mongoose from 'mongoose'; | |
import dotenv from 'dotenv'; | |
import { userRoute } from './routes'; | |
dotenv.config(); | |
const app = express(); | |
//connect to mongodb | |
mongoose.connect(process.env.MONGODB_URI, { | |
useCreateIndex: true, | |
useNewUrlParser: true | |
}); | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); | |
app.use('/api', userRoute); | |
app.get('/', (req, res) => { | |
res.status(200).json({ message: 'Welcome to my API' }); | |
}); | |
export default app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment