Skip to content

Instantly share code, notes, and snippets.

@emersxw
Created March 11, 2018 00:53
Show Gist options
  • Save emersxw/35393fad72358dfe197e833a28579f34 to your computer and use it in GitHub Desktop.
Save emersxw/35393fad72358dfe197e833a28579f34 to your computer and use it in GitHub Desktop.
const express = require('express'),
bodyParser = require('body-parser');
app = express();
const todoRoutes = require('./routes/todos');
// body parser conf
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(__dirname + '/views'));
app.use(express.static(__dirname + '/public'));
// Default route
app.get('/', (req, res) => {
// serving a static file
res.sendFile('index.html');
});
// Using /api/todos on every route in todoRoutes
app.use('/api/todos', todoRoutes);
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`App is running on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment