Add genres route

This commit is contained in:
jeffvli
2022-11-01 11:30:40 -07:00
parent 97486b23ee
commit 73fff64a75
9 changed files with 136 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import { Response } from 'express';
import { toApiModel } from '@helpers/api-model';
import { service } from '@services/index';
import { ApiSuccess } from '@utils/api-success';
import { getSuccessResponse } from '@utils/get-success-response';
import { validation } from '@validations/index';
import { TypedRequest } from '@validations/shared.validation';
const getList = async (
req: TypedRequest<typeof validation.genres.list>,
res: Response
) => {
const { serverId } = req.params;
const data = await service.genres.findManyByServer({ serverId });
const success = ApiSuccess.ok({ data: toApiModel.genres(data) });
return res.status(success.statusCode).json(getSuccessResponse(success));
};
export const genresController = {
getList,
};
+2
View File
@@ -2,6 +2,7 @@ import { albumArtistsController } from '@controllers/album-artists.controller';
import { albumsController } from '@controllers/albums.controller';
import { artistsController } from '@controllers/artists.controller';
import { authController } from '@controllers/auth.controller';
import { genresController } from '@controllers/genres.controller';
import { serversController } from '@controllers/servers.controller';
import { songsController } from '@controllers/songs.controller';
import { tasksController } from '@controllers/tasks.controller';
@@ -12,6 +13,7 @@ export const controller = {
albums: albumsController,
artists: artistsController,
auth: authController,
genres: genresController,
servers: serversController,
songs: songsController,
tasks: tasksController,