Skip to main content
Home
This release is 2 versions behind 0.16.1 — the latest version of @dklab/oak-routing-ctrl. Jump to latest

Built and signed on GitHub Actions

TypeScript Decorators for easy scaffolding API services with the oak framework (jsr:@oak/oak)

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
5 months ago (0.15.2)
Package root>src>Delete.ts
import { debug } from "./utils/logger.ts"; import { register } from "./Store.ts"; import { getUserSuppliedDecoratedMethodName } from "./utils/getUserSuppliedDecoratedMethodName.ts"; import type { OakOpenApiSpec } from "./utils/schema_utils.ts"; import { updateOas } from "./oasStore.ts"; type MethodDecorator = ( // deno-lint-ignore ban-types arg1: Function | object, arg2: ClassMethodDecoratorContext | string, ) => void; /** * Decorator that should be used on the Controller Class Method * for `DELETE` endpoints * @example * ```ts * import { Controller, Delete } from "@dklab/oak-routing-ctrl" * * ;@Controller() * class ExampleClass { * ;@Delete("/:resource") * async deleteSomething() { * // implementation * } * } * ``` */ export const Delete = ( path: string = "", openApiSpec?: OakOpenApiSpec, ): MethodDecorator => (arg1, arg2): void => { const fnName: string = getUserSuppliedDecoratedMethodName(arg1, arg2); debug( `invoking Delete MethodDecorator for ${fnName} with pathPrefix ${path} -`, `runtime provides context:`, arg2, ); register("delete", path, fnName); updateOas(fnName, "delete", path, openApiSpec); }; export const _internal = { Delete };