mirror of
https://github.com/nfonteyne/octane-website.git
synced 2026-09-03 23:24:48 +02:00
update: user can add musics, concerts and all
This commit is contained in:
parent
0683108c8e
commit
692b19a846
7 changed files with 92 additions and 42 deletions
|
|
@ -1,6 +1,5 @@
|
|||
const express = require('express');
|
||||
const setlistsRepo = require('../repositories/setlistsRepo');
|
||||
const { requireAdmin } = require('../auth/middleware');
|
||||
const asyncHandler = require('../lib/asyncHandler');
|
||||
|
||||
const router = express.Router();
|
||||
|
|
@ -37,7 +36,6 @@ router.get(
|
|||
|
||||
router.post(
|
||||
'/',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { name, venue, concertDate } = req.body || {};
|
||||
if (!concertDate) return res.status(400).json({ error: 'concert_date_required' });
|
||||
|
|
@ -48,7 +46,6 @@ router.post(
|
|||
|
||||
router.patch(
|
||||
'/:id',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { name, venue, concertDate } = req.body || {};
|
||||
if (!concertDate) return res.status(400).json({ error: 'concert_date_required' });
|
||||
|
|
@ -60,7 +57,6 @@ router.patch(
|
|||
|
||||
router.delete(
|
||||
'/:id',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
await setlistsRepo.remove(req.params.id);
|
||||
res.status(204).end();
|
||||
|
|
@ -69,7 +65,6 @@ router.delete(
|
|||
|
||||
router.put(
|
||||
'/:id/songs',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { songs } = req.body || {};
|
||||
if (!Array.isArray(songs)) return res.status(400).json({ error: 'songs_array_required' });
|
||||
|
|
@ -93,7 +88,6 @@ router.put(
|
|||
|
||||
router.post(
|
||||
'/:id/songs',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { songId, position, note, isEncore } = req.body || {};
|
||||
if (!songId || typeof position !== 'number') {
|
||||
|
|
@ -113,7 +107,6 @@ router.post(
|
|||
|
||||
router.delete(
|
||||
'/:id/songs/:setlistSongId',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
await setlistsRepo.removeSong(req.params.id, req.params.setlistSongId);
|
||||
res.status(204).end();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
const express = require('express');
|
||||
const songsRepo = require('../repositories/songsRepo');
|
||||
const { requireAdmin } = require('../auth/middleware');
|
||||
const asyncHandler = require('../lib/asyncHandler');
|
||||
const { isValidYoutubeUrl } = require('../lib/youtube');
|
||||
const { isValidSpotifyUrl } = require('../lib/spotify');
|
||||
|
|
@ -32,7 +31,6 @@ router.get(
|
|||
|
||||
router.post(
|
||||
'/',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { title, artist, notes, youtubeUrl, spotifyUrl } = req.body || {};
|
||||
if (!title || !title.trim() || !artist || !artist.trim()) {
|
||||
|
|
@ -54,7 +52,6 @@ router.post(
|
|||
|
||||
router.patch(
|
||||
'/:id',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { title, artist, notes, youtubeUrl, spotifyUrl } = req.body || {};
|
||||
if (!title || !title.trim() || !artist || !artist.trim()) {
|
||||
|
|
@ -76,7 +73,6 @@ router.patch(
|
|||
|
||||
router.delete(
|
||||
'/:id',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
try {
|
||||
await songsRepo.remove(req.params.id);
|
||||
|
|
@ -94,7 +90,6 @@ router.delete(
|
|||
|
||||
router.post(
|
||||
'/:id/tutorials',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
const { instrumentId, url, label } = req.body || {};
|
||||
if (!instrumentId || !url || !url.trim()) {
|
||||
|
|
@ -114,7 +109,6 @@ router.post(
|
|||
|
||||
router.delete(
|
||||
'/:songId/tutorials/:id',
|
||||
requireAdmin,
|
||||
asyncHandler(async (req, res) => {
|
||||
await songsRepo.removeTutorial(req.params.songId, req.params.id);
|
||||
res.status(204).end();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue