Files
komodo/.vscode/fastify.code-snippets

60 lines
1.3 KiB
Plaintext

{
"service": {
"scope": "typescript",
"prefix": "plugin",
"body": [
"import { FastifyInstance } from \"fastify\";",
"import fp from \"fastify-plugin\";",
"",
"const ${1:$TM_FILENAME_BASE} = fp((app: FastifyInstance, _: {}, done: () => void) => {",
"\t${0}",
"\tdone();",
"});",
"",
"export default ${1:$TM_FILENAME_BASE};"
]
},
"schema": {
"scope": "typescript",
"prefix": "schema",
"body": [
"import { FastifyInstance } from \"fastify\";",
"import fp from \"fastify-plugin\";",
"import { Schema } from \"mongoose\";",
"import model from \"../../util/model\";",
"",
"const ${2:$TM_FILENAME_BASE} = fp((app: FastifyInstance, _: {}, done: () => void) => {",
"\tconst schema = new Schema({",
"\t\t${0}",
"\t});",
"\t",
"\tapp.decorate(\"${2:$TM_FILENAME_BASE}\", model(app, \"${1}\", schema));",
"\t",
"\tdone();",
"});",
"",
"export default ${2:$TM_FILENAME_BASE};"
]
},
"get-auth": {
"scope": "typescript",
"prefix": "get-auth",
"body": [
"app.get(\"/${1}\", { onRequest: [app.auth, app.userEnabled] }, async (req, res) => {",
"\t${0}",
"});"
]
},
"post-auth": {
"scope": "typescript",
"prefix": "post-auth",
"body": [
"app.post(\"/${1}\", { onRequest: [app.auth, app.userEnabled] }, async (req, res) => {",
"\t${0}",
"});"
]
}
}