Skip to content

Commit

Permalink
fix: controller type error
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-hh-aa committed Dec 11, 2024
1 parent 9699618 commit 682b704
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions api.planx.uk/modules/analytics/metabase/collection/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createCollectionIfDoesNotExist } from "./service.js";
import type { NewCollectionRequestHandler } from "./types.js";

export const MetabaseCollectionsController: NewCollectionRequestHandler =
async (_req, res) => {
try {
const params = res.locals.parsedReq.body;
const collection = await createCollectionIfDoesNotExist(params);
res.status(201).json({ data: collection });
} catch (error) {
res.status(400).json({
error:
error instanceof Error
? error.message
: "An unexpected error occurred",
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const createCollectionIfDoesNotExistSchema = z.object({

export type NewCollectionRequestHandler = ValidatedRequestHandler<
typeof createCollectionIfDoesNotExistSchema,
ApiResponse<NewCollectionResponse>
ApiResponse<number>
>;

export interface NewCollectionResponse {
Expand Down

0 comments on commit 682b704

Please sign in to comment.