37 lines
1.1 KiB
Plaintext
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",
|
||
|
},
|
||
|
}
|