Skip to content

Instantly share code, notes, and snippets.

@nitish24p
Last active June 26, 2018 16:33
Show Gist options
  • Save nitish24p/a771c79dff3e8787f66c3bf9774d0a47 to your computer and use it in GitHub Desktop.
Save nitish24p/a771c79dff3e8787f66c3bf9774d0a47 to your computer and use it in GitHub Desktop.
index.js for sever
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