Last active
February 27, 2022 01:09
-
-
Save edgvi10/413eb2fa76c02d42f65f4ac78e62e8e0 to your computer and use it in GitHub Desktop.
Revisions
-
edgvi10 revised this gist
Feb 27, 2022 . 1 changed file with 23 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,18 +5,29 @@ "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." -
edgvi10 created this gist
Feb 12, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ { "Next Routes handler": { "prefix": [ "nexthandler", "handler" ], "body": [ "export default async function handler(req, res) {", " if (req.method === \"PUT\") {", " res.status(200).json({});", " } else if (req.method === \"GET\") {", " res.status(200).json({});", " } else if (req.method === \"POST\") {", " res.status(200).json({});", " } else if (req.method === \"DELETE\") {", " res.status(204).json({});", " } else {", " res.status(405).json({error: true});", " }", "}" ], "description": "initial handler to nextjs routes." } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ { "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." } }