wikipedia-game-solver/.vscode/adonis.code-snippets
Théo LUDWIG 4e707008f8
All checks were successful
Chromatic / chromatic (push) Successful in 1m55s
CI / ci (push) Successful in 4m33s
CI / commitlint (push) Successful in 15s
chore(api): improve DX (Developer Experience)
2024-08-19 22:11:33 +01:00

37 lines
1.1 KiB
Plaintext

{
"Adonis Controller and Route": {
"scope": "typescript",
"prefix": "apic",
"body": [
"import { throttle } from \"#start/limiter.ts\"",
"import type { HttpContext } from \"@adonisjs/core/http\"",
"import router from \"@adonisjs/core/services/router\"",
"import vine from \"@vinejs/vine\"",
"",
"export const ${1:controller_name}_validator = vine.compile(",
" vine.object({})",
")",
"",
"export default class ${1:controller_name} {",
" public async handle(context: HttpContext): Promise<{",
" __response: unknown",
" __status: 200",
" }> {",
" const payload = await context.request.validateUsing(${1:controller_name}_validator)",
" return context.response.ok(payload)",
" }",
"}",
"",
"router",
" .get(\"${2:/router-path}\", [${1:controller_name}])",
" .use(throttle)",
" .openapi({",
" description: \"Description.\",",
" tags: [\"tag\"],",
" })",
"",
],
"description": "Adonis Controller and Route",
},
}