Skip to content

Instantly share code, notes, and snippets.

@kianaditya
Last active June 16, 2020 11:20
Show Gist options
  • Save kianaditya/644b4eff17de03d0368a19bb34fa3a3c to your computer and use it in GitHub Desktop.
Save kianaditya/644b4eff17de03d0368a19bb34fa3a3c to your computer and use it in GitHub Desktop.
medium express article two
require('dotenv').config()
const express = require('express')
const logger = require('morgan')
const db = require('./models')
const app = express()
const PORT = process.env.PORT
app.use(logger('dev'))
app.use(express.json()) //http://expressjs.com/en/api.html#express.json
app.use(express.urlencoded({ extended: false })) //http://expressjs.com/en/5x/api.html#express.urlencoded
const postRouter = require('./routes/posts')
app.use('/posts', postRouter)
db.sequelize
.sync()
.then(() => {
app.listen(PORT, () => {
console.info(`App listening on port ${PORT}`)
})
})
.catch((err) => {
console.error(err)
})
module.exports = app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment