@mee4dy/crud
Version:
Create a backend and frontend in 5 minutes! With our powerful full stack crud system, customize it to suit you.
3 lines (2 loc) • 1.56 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@nestjs/common"),c=require("./decorators/crud-ctx.decorator.cjs"),y=require("./pipes/query.parse.pipe.cjs"),p=require("../common/constatns/constatns.cjs");var l=Object.defineProperty,P=Object.getOwnPropertyDescriptor,n=(u,e,t,a)=>{for(var i=P(e,t),d=u.length-1,m;d>=0;d--)(m=u[d])&&(i=m(e,t,i)||i);return i&&l(e,t,i),i},s=(u,e)=>(t,a)=>e(t,a,u);class o{constructor(e){this.service=e,this.pk=this.service.getPK()}async items({params:e},t){return{status:!0,data:{items:await this.service.getItems({params:e,query:t})}}}async item({params:e},t,a){return{status:!0,data:{item:await this.service.getItem({params:e,query:{filters:{[this.pk]:t,...a.filters}}})}}}async create({params:e},t){return{status:!0,data:{item:await this.service.create(t)}}}async update({params:e},t,a){return{status:!0,data:{item:await this.service.update(t,a)}}}async delete({params:e},t){return{status:!0,data:{result:await this.service.delete({[this.pk]:t})}}}}n([r.Get("/"),s(0,c.CrudCtx()),s(1,r.Query(new y.QueryParsePipe))],o.prototype,"items");n([r.Get("/:pk"),s(0,c.CrudCtx()),s(1,r.Param(p.PK)),s(2,r.Query(new y.QueryParsePipe))],o.prototype,"item");n([r.Post("/create"),s(0,c.CrudCtx()),s(1,r.Body("data"))],o.prototype,"create");n([r.Post("/update"),s(0,c.CrudCtx()),s(1,r.Body(p.PK)),s(2,r.Body("data"))],o.prototype,"update");n([r.Post("/delete"),s(0,c.CrudCtx()),s(1,r.Body(p.PK))],o.prototype,"delete");exports.CrudController=o;
//# sourceMappingURL=crud.controller.cjs.map