Skip to content

Instantly share code, notes, and snippets.

@mirajehossain
Last active August 22, 2017 11:12
Show Gist options
  • Save mirajehossain/f69a0de0e46a7d402b7c794b7f2a9bd1 to your computer and use it in GitHub Desktop.
Save mirajehossain/f69a0de0e46a7d402b7c794b7f2a9bd1 to your computer and use it in GitHub Desktop.
This is for basic express server configuration for API
const express = require('require');
const app = express();
const bodyParser = require('body-parser');
const morgan = require('morgan');
const port = process.env.PORT || 8080;
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(morgan('dev'));
app.get('/', function(req, res) {
res.send('Hello! The API is at http://localhost:' + port + '/api');
});
app.listen(port,function(){
console.log('Server running at http://localhost:'+port);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment