diff --git a/src/modules/collection/controllers/addItemToCollection.controller.ts b/src/modules/collection/controllers/addItemToCollection.controller.ts new file mode 100644 index 0000000..5024e0e --- /dev/null +++ b/src/modules/collection/controllers/addItemToCollection.controller.ts @@ -0,0 +1,10 @@ +import { Context, Static } from "elysia"; +import { returnWriteResponse } from "../../../helpers/callback/httpResponse"; +import { addItemToCollectionSchema } from "../schemas/addItemToCollection.schema"; + +export const addItemToCollectionController = async (ctx: { + set: Context["set"]; + headers: Static; +}) => { + return returnWriteResponse(ctx.set, 200, "Item added to collection successfully" + ctx.headers.cookie); +}; diff --git a/src/modules/collection/index.ts b/src/modules/collection/index.ts new file mode 100644 index 0000000..781d87c --- /dev/null +++ b/src/modules/collection/index.ts @@ -0,0 +1,9 @@ +import Elysia from "elysia"; +import { addItemToCollectionController } from "./controllers/addItemToCollection.controller"; +import { addItemToCollectionSchema } from "./schemas/addItemToCollection.schema"; + +export const collectionModule = new Elysia({ prefix: "/collections", tags: ["Collections"] }).post( + "/:name", + addItemToCollectionController, + addItemToCollectionSchema, +); diff --git a/src/modules/collection/schemas/addItemToCollection.schema.ts b/src/modules/collection/schemas/addItemToCollection.schema.ts new file mode 100644 index 0000000..36bda47 --- /dev/null +++ b/src/modules/collection/schemas/addItemToCollection.schema.ts @@ -0,0 +1,35 @@ +import { t } from "elysia"; +import { AppRouteSchema } from "../../../helpers/types/AppRouteSchema"; + +export const addItemToCollectionSchema = { + headers: t.Object({ + 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({ + itemId: t.String({ description: "ID of the item to be added to the collection", examples: ["12345"] }), + }), + detail: { + summary: "Add an item to a collection", + description: "Adds a specified item to a collection identified by its name.", + responses: { + 200: { + description: "The item was successfully added to the collection.", + content: { + "application/json": { + schema: { + type: "object", + properties: { + success: { type: "boolean", example: true }, + status: { type: "number", example: 200 }, + message: { type: "string", example: "Item added to collection successfully" }, + }, + }, + }, + }, + }, + }, + }, +} satisfies AppRouteSchema;