Last active
February 27, 2022 01:09
-
-
Save edgvi10/413eb2fa76c02d42f65f4ac78e62e8e0 to your computer and use it in GitHub Desktop.
Snippets do caralho, irmão!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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." | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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