Created
November 4, 2018 23:26
-
-
Save cziem/a74ea5262067d0bdb85cbcff2d067098 to your computer and use it in GitHub Desktop.
minimal setup for the server.js
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
const express = require('express') | |
const bodyParser = require('body-parser') | |
const mongoose = require('mongoose') | |
const cors = require('cors') | |
require('dotenv').config() | |
const app = express() | |
const port = process.env.PORT || 5000 | |
// Connect to the database | |
const options = { useNewUrlParser: true } | |
mongoose.connect('mongodb://localhost:/mern_boilerplate', options) | |
.then(() => console.log('connected successfully')) | |
.catch(err => console.log('An error occurred', err)) | |
app.use(cors()) | |
app.use(bodyParser.json()) | |
app.use(bodyParser.urlencoded({ extended: true })) | |
app.listen(port, () => console.log(`server is running on port ${port})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment