mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 12:30:06 +02:00
Adjust route structure
- Items now accessed through servers/:serverId - Auth middleware blanketly applied on routes - Merge params on routes
This commit is contained in:
+27
-14
@@ -1,20 +1,33 @@
|
||||
import { Router } from 'express';
|
||||
import { albumArtistsRouter } from './album-artists.route';
|
||||
import { albumsRouter } from './albums.route';
|
||||
import { artistsRouter } from './artists.route';
|
||||
import { authRouter } from './auth.route';
|
||||
import { serversRouter } from './servers.route';
|
||||
import { songsRouter } from './songs.route';
|
||||
import { tasksRouter } from './tasks.route';
|
||||
import { usersRouter } from './users.route';
|
||||
import { helpers } from '../helpers';
|
||||
import { authenticate } from '../middleware';
|
||||
import { router as albumArtistsRouter } from './album-artists.route';
|
||||
import { router as albumsRouter } from './albums.route';
|
||||
import { router as artistsRouter } from './artists.route';
|
||||
import { router as authRouter } from './auth.route';
|
||||
import { router as serversRouter } from './servers.route';
|
||||
import { router as songsRouter } from './songs.route';
|
||||
import { router as tasksRouter } from './tasks.route';
|
||||
import { router as usersRouter } from './users.route';
|
||||
|
||||
export const routes = Router();
|
||||
export const routes = Router({ mergeParams: true });
|
||||
|
||||
routes.use('/api/auth', authRouter);
|
||||
routes.use('/api/servers', serversRouter);
|
||||
|
||||
routes.use(authenticate, (_req, _res, next) => {
|
||||
next();
|
||||
});
|
||||
|
||||
routes.use('/api/tasks', tasksRouter);
|
||||
routes.use('/api/users', usersRouter);
|
||||
routes.use('/api/album-artists', albumArtistsRouter);
|
||||
routes.use('/api/artists', artistsRouter);
|
||||
routes.use('/api/albums', albumsRouter);
|
||||
routes.use('/api/songs', songsRouter);
|
||||
routes.use('/api/servers', serversRouter);
|
||||
|
||||
routes.param('serverId', (req, _res, next, serverId) => {
|
||||
helpers.shared.checkServerPermissions(req.auth, { serverId });
|
||||
next();
|
||||
});
|
||||
|
||||
routes.use('/api/servers/:serverId/album-artists', albumArtistsRouter);
|
||||
routes.use('/api/servers/:serverId/artists', artistsRouter);
|
||||
routes.use('/api/servers/:serverId/albums', albumsRouter);
|
||||
routes.use('/api/servers/:serverId/songs', songsRouter);
|
||||
|
||||
Reference in New Issue
Block a user