Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Nov 26, 2021
1 parent db3c4ac commit 9957e94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ export function getRender({
appModule: App,
documentModule: documentMod,
errorModule: errorMod,
// notFoundModule: ${
// absolute404Path
// ? `require(${stringifyRequest(this, absolute404Path)})`
// : undefined
// },
pageGetStaticProps: pageMod.getStaticProps,
pageGetStaticPaths: pageMod.getStaticPaths,
pageGetServerSideProps: pageMod.getServerSideProps,
Expand All @@ -111,7 +106,7 @@ export function getRender({
buildManifest,
reactLoadableManifest,

// rewrites: combinedRewrites,
// FIXME: implement rewrites
rewrites: [],
i18n: restRenderOpts.i18n,
page,
Expand Down Expand Up @@ -178,7 +173,7 @@ export function getRender({

if (typeof result === 'string') {
return new Response(result, {
headers: { 'x-middleware-ssr': '1' },
headers: createHeaders(),
status: statusCode,
})
}
Expand Down
12 changes: 6 additions & 6 deletions packages/next/server/request-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const NEXT_REQUEST_META = Symbol('NextRequestMeta')
interface NextIncomingMessage extends IncomingMessage {
[NEXT_REQUEST_META]?: RequestMeta
}
interface WebRequestBasedNextIncomingMessage extends WebIncomingMessage {
interface NextWebIncomingMessage extends WebIncomingMessage {
[NEXT_REQUEST_META]?: RequestMeta
}

Expand All @@ -26,31 +26,31 @@ interface RequestMeta {
}

export function getRequestMeta(
req: NextIncomingMessage | WebRequestBasedNextIncomingMessage,
req: NextIncomingMessage | NextWebIncomingMessage,
key?: undefined
): RequestMeta
export function getRequestMeta<K extends keyof RequestMeta>(
req: NextIncomingMessage | WebRequestBasedNextIncomingMessage,
req: NextIncomingMessage | NextWebIncomingMessage,
key: K
): RequestMeta[K]
export function getRequestMeta<K extends keyof RequestMeta>(
req: NextIncomingMessage | WebRequestBasedNextIncomingMessage,
req: NextIncomingMessage | NextWebIncomingMessage,
key?: K
): RequestMeta | RequestMeta[K] {
const meta = req[NEXT_REQUEST_META] || {}
return typeof key === 'string' ? meta[key] : meta
}

export function setRequestMeta(
req: NextIncomingMessage | WebRequestBasedNextIncomingMessage,
req: NextIncomingMessage | NextWebIncomingMessage,
meta: RequestMeta
) {
req[NEXT_REQUEST_META] = meta
return getRequestMeta(req)
}

export function addRequestMeta<K extends keyof RequestMeta>(
request: NextIncomingMessage | WebRequestBasedNextIncomingMessage,
request: NextIncomingMessage | NextWebIncomingMessage,
key: K,
value: RequestMeta[K]
) {
Expand Down
4 changes: 3 additions & 1 deletion packages/next/server/web/http-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class WebServerResponse {

statusCode: number = 200

// FIXME
// FIXME: The internal states should support correctly throwing errors when
// using improperly. And in the future it should be able to be translated to
// the Node HTTP OutgoingMessage.
finished: boolean = false
headersSent: boolean = false
body: [] = []
Expand Down

0 comments on commit 9957e94

Please sign in to comment.