Skip to content

Instantly share code, notes, and snippets.

@edgvi10
Last active February 27, 2022 01:09
Show Gist options
  • Save edgvi10/413eb2fa76c02d42f65f4ac78e62e8e0 to your computer and use it in GitHub Desktop.
Save edgvi10/413eb2fa76c02d42f65f4ac78e62e8e0 to your computer and use it in GitHub Desktop.
Snippets do caralho, irmão!
{
"Next Routes handler": {
"prefix": [
"nexthandler",
"handler"
],
"body": [
"export default async function (req, res) {",
" console.clear();",
" console.log(`${req.method} ${req.url}`);",
"",
" const $return = {};",
" $return.success = false;",
" $return.message = \"\";",
"",
" if (req.method === \"POST\") {",
"",
" return res.status($return.statusCode || 201).json({ ...$return });",
" } else if (req.method === \"GET\") {",
"",
" return res.status($return.statusCode || 200).json({ ...$return });",
" } else if (req.method === \"PUT\") {",
"",
" return res.status($return.statusCode || 200).json({ ...$return });",
" } else if (req.method === \"DELETE\") {",
"",
" return res.status($return.statusCode || 200).json({ ...$return });",
" }",
"",
" return res.status(405).json({ ...$return, error: \"Method Not Allowed\" });",
"}"
],
"description": "initial handler to nextjs routes."
}
}
{
"Next Package": {
"prefix": [
"package",
"package"
],
"body": [
"{",
" \"name\": \"${1}\",",
" \"version\": \"0.0.1\",",
" \"scripts\": {",
" \"build\": \"next build\",",
" \"start\": \"next start\",",
" \"dev\": \"next dev\"",
" }",
"}"
],
"description": "initial handler to nextjs routes."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment