Last active
July 27, 2017 06:52
-
-
Save kvedantmahajan/6a03caef27ab9d3e1dea3ef11e3d1a05 to your computer and use it in GitHub Desktop.
React node app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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