Skip to content

Instantly share code, notes, and snippets.

@donjosef
Created September 24, 2019 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donjosef/b87c4d9071fe1fd9ba2f655eb2c274d2 to your computer and use it in GitHub Desktop.
Save donjosef/b87c4d9071fe1fd9ba2f655eb2c274d2 to your computer and use it in GitHub Desktop.
Define routes for handling requests
const express = require('express');
const controller = require('../controllers/posts');
const router = express.Router(); //router is like a mini express app, that we can plug into app.use()
//With this we are determining how our application will respond to get requests to /posts
router.get('/posts', controller.getPosts);
//With this we are determining how our application will respond to post requests to /post
router.post('/post', controller.createPost);
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment