Skip to content

Commit

Permalink
[fix] expose init and render for adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Oct 5, 2021
1 parent 0245ce0 commit 1511a92
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-bags-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] expose init and render for adapters
2 changes: 1 addition & 1 deletion packages/kit/src/core/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function preview({

const app_file = resolve(cwd, `${SVELTE_KIT}/output/server/app.js`);

/** @type {import('types/app').App} */
/** @type {import('types/internal').App} */
const app = await import(pathToFileURL(app_file).href);

/** @type {import('sirv').RequestHandler} */
Expand Down
19 changes: 10 additions & 9 deletions packages/kit/types/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { ReadOnlyFormData, RequestHeaders } from './helper';
import { ServerResponse } from './hooks';

export interface Init {
(): void;
}

export interface Render {
(incoming: IncomingRequest): Promise<ServerResponse>;
}

export interface App {
init(options?: {
paths: {
base: string;
assets: string;
};
prerendering: boolean;
read(file: string): Buffer;
}): void;
render(incoming: IncomingRequest): Promise<ServerResponse>;
init: Init;
render: Render;
}

export type RawBody = null | Uint8Array;
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import './ambient-modules';

export { App, IncomingRequest, RawBody } from './app';
export { App, IncomingRequest, Init, RawBody, Render } from './app';
export { Adapter, AdapterUtils, Config, PrerenderErrorHandler, ValidatedConfig } from './config';
export { EndpointOutput, RequestHandler } from './endpoint';
export { ErrorLoad, ErrorLoadInput, Load, LoadInput, LoadOutput, Page } from './page';
Expand Down
9 changes: 9 additions & 0 deletions packages/kit/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export interface PrerenderOptions {
}

export interface App extends PublicApp {
init(options?: {
paths: {
base: string;
assets: string;
};
prerendering: boolean;
read(file: string): Buffer;
}): void;

render(
incoming: IncomingRequest,
options?: {
Expand Down

0 comments on commit 1511a92

Please sign in to comment.