UNPKG

@mee4dy/crud

Version:

Create a backend and frontend in 5 minutes! With our powerful full stack crud system, customize it to suit you.

99 lines (98 loc) 2.07 kB
import { Get as y, Query as v, Param as h, Post as n, Body as c } from "@nestjs/common"; import { CrudCtx as o } from "./decorators/crud-ctx.decorator.js"; import { QueryParsePipe as f } from "./pipes/query.parse.pipe.js"; import { PK as d } from "../common/constatns/constatns.js"; var P = Object.defineProperty, w = Object.getOwnPropertyDescriptor, p = (i, e, t, a) => { for (var s = w(e, t), m = i.length - 1, l; m >= 0; m--) (l = i[m]) && (s = l(e, t, s) || s); return s && P(e, t, s), s; }, r = (i, e) => (t, a) => e(t, a, i); class u { 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 }) } }; } } p([ y("/"), r(0, o()), r(1, v(new f())) ], u.prototype, "items"); p([ y("/:pk"), r(0, o()), r(1, h(d)), r(2, v(new f())) ], u.prototype, "item"); p([ n("/create"), r(0, o()), r(1, c("data")) ], u.prototype, "create"); p([ n("/update"), r(0, o()), r(1, c(d)), r(2, c("data")) ], u.prototype, "update"); p([ n("/delete"), r(0, o()), r(1, c(d)) ], u.prototype, "delete"); export { u as CrudController }; //# sourceMappingURL=crud.controller.js.map