Last active
June 16, 2020 11:20
-
-
Save kianaditya/644b4eff17de03d0368a19bb34fa3a3c to your computer and use it in GitHub Desktop.
medium express article two
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
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