Skip to content

Instantly share code, notes, and snippets.

@phpmaps
Created August 4, 2021 18:56
Show Gist options
  • Select an option

  • Save phpmaps/6dc06a41fbdfd052cce737fa9da39da1 to your computer and use it in GitHub Desktop.

Select an option

Save phpmaps/6dc06a41fbdfd052cce737fa9da39da1 to your computer and use it in GitHub Desktop.
server/api/index.js
const express = require('express');
const exampleRouter = require('./exampleRouter');
const membersRouter = require('./membersRouter');
const router = express.Router()
/**
* main api endpoint
**/
router.route('/')
.get((req, res) => {
res.json({
message: 'API - πŸ‘‹πŸŒŽπŸŒπŸŒ'
});
})
/**
* handle endpoints off of /api
**/
router.use('/example', exampleRouter); // ex. /api/example
router.use('/members', membersRouter); // ex. /api/members
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment