@vercel/node
Advanced tools
Comparing version 1.7.5-canary.1 to 1.7.5-canary.2
@@ -712,2 +712,13 @@ module.exports = | ||
} | ||
function redirect(res, statusOrUrl, url) { | ||
if (typeof statusOrUrl === 'string') { | ||
url = statusOrUrl; | ||
statusOrUrl = 307; | ||
} | ||
if (typeof statusOrUrl !== 'number' || typeof url !== 'string') { | ||
throw new Error(`Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').`); | ||
} | ||
res.writeHead(statusOrUrl, { Location: url }).end(); | ||
return res; | ||
} | ||
function setCharset(type, charset) { | ||
@@ -872,2 +883,3 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
res.status = statusCode => status(res, statusCode); | ||
res.redirect = (statusOrUrl, url) => redirect(res, statusOrUrl, url); | ||
res.send = body => send(req, res, body); | ||
@@ -874,0 +886,0 @@ res.json = jsonBody => json(req, res, jsonBody); |
@@ -19,3 +19,4 @@ /// <reference types="node" /> | ||
status: (statusCode: number) => NowResponse; | ||
redirect: (statusOrUrl: string | number, url?: string) => NowResponse; | ||
}; | ||
export declare type NowApiHandler = (req: NowRequest, res: NowResponse) => void; |
{ | ||
"name": "@vercel/node", | ||
"version": "1.7.5-canary.1", | ||
"version": "1.7.5-canary.2", | ||
"license": "MIT", | ||
@@ -45,3 +45,3 @@ "main": "./dist/index", | ||
}, | ||
"gitHead": "ad0cc858ed08685d313ccd5d4ac90a3c8ad63b32" | ||
"gitHead": "7945155a0f1c3a3df25e1c1185e270c6d564ec73" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3161765
89187