Last active
July 12, 2019 16:39
-
-
Save oreoluwade/0b858b075b60f93409794f07fcb56ae5 to your computer and use it in GitHub Desktop.
Express app that runs the application
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 logger = require('morgan'); | |
const mongoose = require('mongoose'); | |
const dotenv = require('dotenv'); | |
const userRoutes = require('./user.route'); | |
dotenv.config(); | |
const app = express(); | |
//connect to mongodb | |
const DB_NAME = process.env.MONGODB_URI; | |
mongoose.Promise = global.Promise; | |
mongoose.connect(DB_NAME, { | |
useCreateIndex: true, | |
useNewUrlParser: true, | |
useFindAndModify: false | |
}); | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); | |
app.use(logger('dev')); | |
const port = process.env.PORT || 5000; | |
app.get('/', (req, res) => { | |
res.send({ | |
message: | |
'Alackaday! Welcome to simple upload, powered by NodeJS, multer, postman and aws-sdk!' | |
}); | |
}); | |
app.use('/api', userRoutes); | |
app.listen(port, () => { | |
console.log(`Server listening on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment