Add daily averages endpoint / move authentication

This commit is contained in:
2019-08-01 21:12:20 +02:00
parent c36391321c
commit 31bbcb52c7
5 changed files with 19 additions and 24 deletions

View File

@@ -1,9 +1,8 @@
const router = require('express').Router();
const { authenticate } = require('../auth/authenticate');
const Sessions = require('../sessions/sessionsModel');
router.post('/sessions', authenticate, (req, res) => {
router.post('/sessions', (req, res) => {
Sessions.addSession(req.body)
.then(response => {
res.status(200).json(response);
@@ -14,7 +13,7 @@ router.post('/sessions', authenticate, (req, res) => {
});
});
router.get('/:id/sessions', authenticate, (req, res) => {
router.get('/:id/sessions', (req, res) => {
Sessions.findUserSessions(req.params.id)
.then(users => {
res.status(200).json(users);
@@ -22,7 +21,7 @@ router.get('/:id/sessions', authenticate, (req, res) => {
.catch(err => res.send(err));
});
router.put('/sessions/:id', authenticate, async (req, res) => {
router.put('/sessions/:id', async (req, res) => {
Sessions.updateSession(req.params.id, req.body)
.then(session => {
if (session) {
@@ -36,7 +35,7 @@ router.put('/sessions/:id', authenticate, async (req, res) => {
});
});
router.delete("/sessions/:id", authenticate, async (req, res) => {
router.delete("/sessions/:id", async (req, res) => {
Sessions.removeSession(req.params.id)
.then(() => res.status(200).json({ message: 'The session has been successfully deleted' }))
.catch(err => res.json(err));