notes/.vscode/extensions/paulzhang.fastify-snippets-0.0.5/snippets/snippets.json
2021-11-05 11:26:45 -07:00

175 lines
5.9 KiB
JSON

{
"fastify_module": {
"prefix": "f.module",
"body":
"'use strict' \n module.exports = async function(fastify, opts, next) { \n\t $0 \n}\n",
"description": "Create fastify module"
},
"fastify_method_get": {
"prefix": "f.get",
"body":
"\tfastify.get('${1:path}', async function(request, reply) {\n\t $0 \n})\n",
"description": "a get router."
},
"fastify_method_post": {
"prefix": "f.post",
"body":
"\tfastify.post('${1:path}', async function(request, reply) {\n\t $0 \n})\n",
"description": "a post router."
},
"fastify_request_body": {
"prefix": "f.request.body",
"body": "const body = request.body$0",
"description": "the request body"
},
"fastify_request_query": {
"prefix": "f.request.query",
"body": "const query = request.query$0",
"description": "the parsed querystring"
},
"fastify_request_params": {
"prefix": "f.request.params",
"body": "const params = request.params$0",
"description": "the params matching the URL"
},
"fastify_request_headers": {
"prefix": "f.request.headers",
"body": "const headers = request.headers$0",
"description": "the headers"
},
"fastify_request_raw": {
"prefix": "f.request.raw",
"body": "const rawReq = request.raw$0",
"description":
"the incoming HTTP request from Node core (you can use the alias req)"
},
"fastify_request_id": {
"prefix": "f.request.id",
"body": "const requestId = request.id$0",
"description": "the request id"
},
"fastify_reply_code": {
"prefix": "f.reply.code",
"body": "reply.code(${1:200})$0",
"description": "Sets the status code"
},
"fastify_reply_header": {
"prefix": "f.reply.code",
"body": "reply.header(${2:name}, ${1:value})$0",
"description": "Sets a response header"
},
"fastify_reply_getHeader": {
"prefix": "f.reply.getHeader",
"body": "reply.getHeader(${1:name})$0",
"description": "Retrieve value of already set header"
},
"fastify_reply_removeHeader": {
"prefix": "f.reply.removeHeader",
"body": "reply.removeHeader(${1:name})$0",
"description": "Removed the value of a previously set header"
},
"fastify_reply_hasHeader": {
"prefix": "f.reply.hasHeader",
"body": "reply.hasHeader(${1:name})$0",
"description": "Determine if a header has been set"
},
"fastify_reply_type": {
"prefix": "f.reply.type",
"body": "reply.type(${1:value})$0",
"description": "Sets the header Content-Type"
},
"fastify_reply_redirect": {
"prefix": "f.reply.redirect",
"body": "reply.redirect([${2:code}],${1:url}$0",
"description":
"Redirect to the specified url, the status code is optional (default to 302)"
},
"fastify_reply_serialize": {
"prefix": "f.reply.serialize",
"body": "reply.serialize(${1:payload}$0",
"description":
"Serializes the specified payload using the default json serializer and returns the serialized payload"
},
"fastify_reply_serializer": {
"prefix": "f.reply.serializer",
"body": "reply.serializer(${1:function}$0",
"description": "Sets a custom serializer for the payload"
},
"fastify_reply_send": {
"prefix": "f.reply.send",
"body": "reply.send(${1:payload}$0",
"description":
"Sends the payload to the user, could be a plain text, a buffer, JSON, stream, or an Error object"
},
"fastify_reply_sent": {
"prefix": "f.reply.sent",
"body": "reply.sent(${1:payload}$0",
"description":
"A boolean value that you can use if you need to know if send has already been called"
},
"fastify_reply_res": {
"prefix": "f.reply.res",
"body": "const rawRes = reply.res",
"description": "The http.ServerResponse from Node core"
},
"fastify_request_log_info": {
"prefix": "f.request.log.info",
"body": "request.log.info(${1:msg})$0",
"description": "Print the request log with info level"
},
"fastify_request_log_fatal": {
"prefix": "f.request.log.fatal",
"body": "request.log.fatal(${1:msg})$0",
"description": "Print the request log with fatal level"
},
"fastify_request_log_error": {
"prefix": "f.request.log.error",
"body": "request.log.error(${1:msg})$0",
"description": "Print the request log with error level"
},
"fastify_request_log_warn": {
"prefix": "f.request.log.warn",
"body": "request.log.warn(${1:msg})$0",
"description": "Print the request log with warn level"
},
"fastify_request_log_debug": {
"prefix": "f.request.log.debug",
"body": "request.log.debug(${1:msg})$0",
"description": "Print the request log with debug level"
},
"fastify_request_log_trace": {
"prefix": "f.request.log.trace",
"body": "request.log.trace(${1:msg})$0",
"description": "Print the request log with trace level"
},
"fastify_log_info": {
"prefix": "f.log.info",
"body": "fastify.log.info(${1:msg})$0",
"description": "Print the fastify log with info level"
},
"fastify_log_fatal": {
"prefix": "f.log.fatal",
"body": "fastify.log.fatal(${1:msg})$0",
"description": "Print the fastify log with fatal level"
},
"fastify_log_error": {
"prefix": "f.log.error",
"body": "fastify.log.error(${1:msg})$0",
"description": "Print the fastify log with error level"
},
"fastify_log_warn": {
"prefix": "f.log.warn",
"body": "fastify.log.warn(${1:msg})$0",
"description": "Print the fastify log with warn level"
},
"fastify_log_debug": {
"prefix": "f.log.debug",
"body": "fastify.log.debug(${1:msg})$0",
"description": "Print the fastify log with debug level"
},
"fastify_log_trace": {
"prefix": "f.log.trace",
"body": "fastify.log.trace(${1:msg})$0",
"description": "Print the fastify log with trace level"
}
}