-
-
Save amandeepmittal/f6d5a02c1103ae96e92a99840fc54692 to your computer and use it in GitHub Desktop.
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
import express from 'express'; | |
import cookieParser from 'cookie-parser'; | |
import config from './server/config'; | |
// DB connection | |
require('./server/config/dbConnection'); | |
const app = express(); | |
// middleware functions | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); | |
app.use(cookieParser()); | |
// Error handling middleware | |
app.use((err, req, res, next) => { | |
if (err.name === 'UnauthorizedError') { | |
res.status(401).json({ error: err.name + ':' + err.message }); | |
} | |
}); | |
app.listen(config.port, () => { | |
console.log(`🚀 at port ${config.port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment