Skip to content

Instantly share code, notes, and snippets.

@agustinfece
Created June 16, 2021 14:46
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 agustinfece/8059754189c582a0d991149f3a2ed27c to your computer and use it in GitHub Desktop.
Save agustinfece/8059754189c582a0d991149f3a2ed27c to your computer and use it in GitHub Desktop.
routes.js
import express from 'express';
import { signup, login, isAuth } from '../controllers/auth.js';
const router = express.Router();
router.post('/login', login);
router.post('/signup', signup);
router.get('/private', isAuth);
router.get('/public', (req, res, next) => {
res.status(200).json({ message: "here is your public resource" });
});
// will match any other path
router.use('/', (req, res, next) => {
res.status(404).json({error : "page not found"});
});
export default router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment