fix bug
This commit is contained in:
parent
6b2cd65434
commit
790df54525
@ -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<Content> & {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));
|
||||
|
Loading…
Reference in New Issue
Block a user