How to use?
// model.ts abstract public static updatableFields: string = ; public static privateFields: string = ; public static notUpdatableFields: string = ; @ public id?: number; @ public createdAt?: Date; @ public updatedAt?: Date; { if data thisid = dataid; } @ public title?: string; @ public tours?: Tour; { super; if data thistitle = datatitle; thistours = datatours; }
Create resource and add routes to KoaRouter (package: koa-router)
;;; // custom logger const logger = ; const tourServiceRouter = prefix: "/tour_services"; const tourServiceResource = TourService // for absolute path in uri to next/previous page on getting a list items base_url: configsitebase_url // function for getting body from koa/Context ctxrequestbody /* AVAILABLE OPTIONS: // hooks afterDelete?: (ctx: RequestContext, deleted_item: DeleteResult) => void; preDetail?: IPreGetCallback<Entity>; afterDetail?: (ctx: RequestContext, item: Entity) => Promise<Entity>; preList?: IPreGetCallback<Entity>; afterList?: (ctx: RequestContext, items: Entity[]) => Promise<Entity[]>; prePatch?: IPreInsertCallback<Entity>; afterPatch?: IAfterInsertCallback<Entity>; prePost?: IPreInsertCallback<Entity>; afterPost?: IAfterInsertCallback<Entity>; filter?: () => void; take?: number; list_fields?: string[]; relations?: string[]; select?: string[]; order?: { [P in keyof T]?: "DESC" | "ASC" }; */ tourServiceRouter logger;
Response example
> curl http://example.com/tour_services
TODO
- Check correct work of preparing data for post/patch
- More examples and documentation
- Ordering
- Resource for Express