@now/node
Advanced tools
+12
-0
@@ -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); |
+1
-0
@@ -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; |
+1
-1
| { | ||
| "name": "@now/node", | ||
| "version": "1.7.5-canary.1", | ||
| "version": "1.7.5-canary.2", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index", |
3151566
0.02%89187
0.01%