Created
October 30, 2019 13:06
-
-
Save markodayan/41fccf159b897eaee94ce5511bcb67c2 to your computer and use it in GitHub Desktop.
A Gist
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
// @desc Basic boilerplate for server.js file. app set up, set up middleware like dotenv and morgan.use of environment vars | |
const express = require('express'); | |
const dotenv = require('dotenv'); | |
const morgan = require('morgan'); | |
const bootcamps = require('./routes/bootcamps'); | |
// Load environment variables | |
dotenv.config({ path: './config/config.env' }); | |
const app = express(); | |
// Dev logging middleware | |
if (process.env.NODE_ENV === 'development') { | |
app.use(morgan('dev')); | |
} | |
// Mount routers | |
app.use('/api/v1/bootcamps', bootcamps); | |
const PORT = process.env.PORT || 5000; | |
app.listen(PORT, | |
console.log(`Server running in ${process.env.NODE_ENV} mode on port ${PORT}`) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment