-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
24 lines (18 loc) · 868 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import express from 'express';
import { signup, login, getUser } from './controllers/userController.js';
import { addNote, editNote, getAllNotes, deleteNote, pinNote, searchNotes } from './controllers/noteController.js';
import { authenticate } from './utils/jwt.js';
const router = express.Router();
router.post('/users/signup', signup);
router.post('/users/login', login);
router.get('/users/me', authenticate, getUser);
router.post('/notes', authenticate, addNote);
router.put('/notes/:noteId', authenticate, editNote);
router.get('/notes', authenticate, getAllNotes);
router.delete('/notes/:noteId', authenticate, deleteNote);
router.put('/notes/:noteId/pin', authenticate, pinNote);
router.get('/notes/search', authenticate, searchNotes);
router.get('/', (req, res) => {
res.json({ message: 'Welcome to the Notes App API' });
});
export default router;