diff --git a/src/route/contents.ts b/src/route/contents.ts index b995cce..9ea88e4 100644 --- a/src/route/contents.ts +++ b/src/route/contents.ts @@ -59,6 +59,12 @@ const ContentQueryHandler = (controller : ContentAccessor) => async (ctx: Contex } const UpdateContentHandler = (controller : ContentAccessor) => async (ctx: Context, next: Next) => { const num = Number.parseInt(ctx.params['num']); + if(ctx.request.type !== 'json'){ + sendError(400,"update fail. invalid content type: it is not json."); + } + if(typeof ctx.request.body !== "object"){ + sendError(400,"update fail. invalid argument: not"); + } const content_desc: Partial & {id: number} = { id:num,...ctx.request.body }; @@ -130,7 +136,7 @@ export const getContentRouter = (controller: ContentAccessor)=>{ const ret = new Router(); ret.get("/search",ContentQueryHandler(controller)); ret.get("/:num(\\d+)",ContentIDHandler(controller)); - ret.get("/:num(\\d+)",UpdateContentHandler(controller)); + ret.post("/:num(\\d+)",UpdateContentHandler(controller)); ret.use("/:num(\\d+)/:content_type"); ret.post("/",CreateContentHandler(controller)); ret.get("/:num(\\d+)/tags",ContentTagIDHandler(controller));