From eab0dcd7965811c1ebaa2f691f415b4842139497 Mon Sep 17 00:00:00 2001 From: liximomo Date: Tue, 30 Jun 2020 18:34:11 +0800 Subject: [PATCH] fix: typing --- packages/shuvi/src/server/types.ts | 1 + packages/shuvi/src/shuvi/shuvi.base.ts | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/shuvi/src/server/types.ts b/packages/shuvi/src/server/types.ts index d6962b407..8720b973a 100644 --- a/packages/shuvi/src/server/types.ts +++ b/packages/shuvi/src/server/types.ts @@ -3,6 +3,7 @@ import { UrlWithParsedQuery } from 'url'; import { Server, NextFunction } from 'connect'; export interface IIncomingMessage extends http.IncomingMessage { + url: string; parsedUrl: UrlWithParsedQuery; originalUrl?: http.IncomingMessage['url']; [x: string]: any; diff --git a/packages/shuvi/src/shuvi/shuvi.base.ts b/packages/shuvi/src/shuvi/shuvi.base.ts index 3454c7c35..92c0818c1 100644 --- a/packages/shuvi/src/shuvi/shuvi.base.ts +++ b/packages/shuvi/src/shuvi/shuvi.base.ts @@ -1,4 +1,5 @@ import { IShuviMode, APIHooks, Runtime } from '@shuvi/types'; +import { ServerResponse } from 'http'; import { IHTTPRequestHandler, IIncomingMessage, @@ -34,13 +35,11 @@ export default abstract class Shuvi { } async renderToHTML( - req: IIncomingMessage, - res: IServerResponse + req: Runtime.IRequest, + res: ServerResponse ): Promise { - req.url = req.url || '/'; - const renderRequest = req as Runtime.IRequest; return renderToHTML({ - req: renderRequest, + req, api: this._api, onRedirect(redirect) { res.writeHead(redirect.status ?? 302, { Location: redirect.path });