Skip to content

Instantly share code, notes, and snippets.

@kvedantmahajan
Last active July 27, 2017 06:52
Show Gist options
  • Save kvedantmahajan/6a03caef27ab9d3e1dea3ef11e3d1a05 to your computer and use it in GitHub Desktop.
Save kvedantmahajan/6a03caef27ab9d3e1dea3ef11e3d1a05 to your computer and use it in GitHub Desktop.
React node app
'use strict';
const express = require('express'),
notes = require('./routes/rs_notes');
const app = express();
const router = express.Router();
// route middleware that will happen on every request
router.use((req, res, next) => {
// log each request to the console
console.log(req.method, req.url);
// continue doing what we were doing and go to the route
next();
});
router.get('/', (req, res) => {
res.send('Home');
});
app.use('/api', router);
app.use('/api/notes', notes);
module.exports = app;
const PORT = process.env.PORT || 9001;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}!`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment