feat/collection #29
@ -7,13 +7,12 @@ import { mainErrorHandler } from "../../../helpers/error/handler";
|
|||||||
export const addItemToCollectionController = async (ctx: {
|
export const addItemToCollectionController = async (ctx: {
|
||||||
set: Context["set"];
|
set: Context["set"];
|
||||||
headers: Static<typeof addItemToCollectionSchema.headers>;
|
headers: Static<typeof addItemToCollectionSchema.headers>;
|
||||||
params: Static<typeof addItemToCollectionSchema.params>;
|
|
||||||
body: Static<typeof addItemToCollectionSchema.body>;
|
body: Static<typeof addItemToCollectionSchema.body>;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
const savedItem = await addItemToCollectionService({
|
const savedItem = await addItemToCollectionService({
|
||||||
cookie: ctx.headers.cookie,
|
cookie: ctx.headers.cookie,
|
||||||
collectionName: ctx.params.name,
|
collectionName: ctx.body.name,
|
||||||
mediaId: ctx.body.itemId,
|
mediaId: ctx.body.itemId,
|
||||||
});
|
});
|
||||||
return returnWriteResponse(ctx.set, 200, "Item added to collection successfully", savedItem);
|
return returnWriteResponse(ctx.set, 200, "Item added to collection successfully", savedItem);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { addItemToCollectionController } from "./controllers/addItemToCollection
|
|||||||
import { addItemToCollectionSchema } from "./schemas/addItemToCollection.schema";
|
import { addItemToCollectionSchema } from "./schemas/addItemToCollection.schema";
|
||||||
|
|
||||||
export const collectionModule = new Elysia({ prefix: "/collections", tags: ["Collections"] }).post(
|
export const collectionModule = new Elysia({ prefix: "/collections", tags: ["Collections"] }).post(
|
||||||
"/:name",
|
"/sys",
|
||||||
addItemToCollectionController,
|
addItemToCollectionController,
|
||||||
addItemToCollectionSchema,
|
addItemToCollectionSchema,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -5,10 +5,8 @@ export const addItemToCollectionSchema = {
|
|||||||
headers: t.Object({
|
headers: t.Object({
|
||||||
cookie: t.String({ description: "Authentication token in cookie format, e.g., auth_token=your_jwt_token;" }),
|
cookie: t.String({ description: "Authentication token in cookie format, e.g., auth_token=your_jwt_token;" }),
|
||||||
}),
|
}),
|
||||||
params: t.Object({
|
|
||||||
name: t.String({ description: "Name of the collection to which the item will be added" }),
|
|
||||||
}),
|
|
||||||
body: t.Object({
|
body: t.Object({
|
||||||
|
name: t.String({ description: "Name of the collection to which the item will be added" }),
|
||||||
itemId: t.String({ description: "ID of the item to be added to the collection", examples: ["12345"] }),
|
itemId: t.String({ description: "ID of the item to be added to the collection", examples: ["12345"] }),
|
||||||
}),
|
}),
|
||||||
detail: {
|
detail: {
|
||||||
|
|||||||
Reference in New Issue
Block a user