Skip to content

Instantly share code, notes, and snippets.

@hoangsetup
Created April 21, 2017 02:10
Show Gist options
  • Save hoangsetup/3fa48c9c7c0936f537cf2beaffd98b9e to your computer and use it in GitHub Desktop.
Save hoangsetup/3fa48c9c7c0936f537cf2beaffd98b9e to your computer and use it in GitHub Desktop.
Default express app
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var cors = require('cors');
var config = require('./config/config.json');
var async = require('async');
var color = require('colors');
var PORT = config.PORT || process.env.PORT || 8080;
app.use(cors());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json({
type: '*/*'
}));
/* Routes */
app.use('/', require('./routes/index'));
async.waterfall([
function (next) {
next();
}
], function (err) {
app.listen(PORT);
console.log('Server is runing on port: '.green + PORT);
});
module.exports = app;
var router = require('express').Router();
router.route('/')
.get(function(req, res) {
res.send('Hello!');
});
module.exports = router;
{
"name": "food-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"async": "^2.1.5",
"body-parser": "^1.17.1",
"colors": "^1.1.2",
"cors": "^2.8.1",
"express": "^4.15.2"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-http": "^3.0.0",
"mocha": "^3.2.0"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment