Last active
June 26, 2018 16:33
-
-
Save nitish24p/a771c79dff3e8787f66c3bf9774d0a47 to your computer and use it in GitHub Desktop.
index.js for sever
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
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
const userController = require('./userController'); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.post('/user', userController.createOrAddUser); | |
app.use((err, req, res, next) => { | |
res | |
.status(err.status || 500) | |
.send({ status: err.status ? `${err.status}` : 500, message: err.message }); | |
}); | |
app.listen(3000, () => { | |
console.log('listening on port 3000'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment