From c70837aa5573ae5391cf4e887a10e8ac43b37e93 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Sat, 18 Jul 2020 14:29:22 -0400 Subject: [PATCH] Enforce POSTing --- api/new.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/api/new.js b/api/new.js index a16c60b..67e2823 100644 --- a/api/new.js +++ b/api/new.js @@ -1,9 +1,26 @@ -// process.env. - // https://api.vercel.com/v2/now/files // https://api.vercel/v12/now/files +// Vercel protects against env tokens starting with `VERCEL_`, so we're calling +// it the ZEIT_TOKEN +const zeitToken = process.env.ZEIT_TOKEN + export default (req, res) => { - res.json({ ping: 'pong' }) + if (req.method == 'OPTIONS') { + return res.status(204).json({ status: "YIPPE YAY. YOU HAVE CLEARANCE TO PROCEED." }) + } + if (req.method == 'GET') { + return res.status(405).json({ error: '*GET outta here!* (Method not allowed, use POST)' }) + } + if (req.method == 'PUT') { + return res.status(405).json({ error: '*PUT that request away!* (Method not allowed, use POST)' }) + } + if (req.method !== 'POST') { + return res.status(405).json({ error: 'Method not allowed, use POST' }) + } + + res.send(req.body) + + // res.json({ ping: 'pong' }) } \ No newline at end of file