Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize JS API for startServer() #1344

Merged
merged 1 commit into from
Oct 18, 2020
Merged

Finalize JS API for startServer() #1344

merged 1 commit into from
Oct 18, 2020

Conversation

FredKSchott
Copy link
Owner

@FredKSchott FredKSchott commented Oct 17, 2020

Changes

  • Tackles a large chunk of Finalize SSR & JS API #1339
  • Finalizes our startServer() JS API (no longer __unstable_startServer(), now covered by semver)
  • Previously, the functions returned by the startServer() API had been implemented as JS wrappers around HTTP calls to the dev server. To build a better JS API, we flipped it: the dev server is now an HTTP layer on top of this same exported JS API.

New API

export function startServer(commandOptions: CommandOptions): Promise<ServerResult>;
export interface ServerResult {
    loadUrl: (reqUrl: string, options?: {isSSR: boolean; allowStale: boolean}) => Promise<LoadResult>;
    handleRequest: (req: http.IncomingMessage, res: http.ServerResponse, options?: {handleError?: boolean}) => Promise<void>;
    sendResponseFile: typeof sendResponseFile;
    sendResponseError: typeof sendResponseError;
    shutdown(): Promise<void>;
}

Testing

  • Still TODO (this API is still experimental, undocumented, and not yet supported. Will tackle in follow up PR!)

Docs

  • Still TODO

@vercel
Copy link

vercel bot commented Oct 17, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/5gqdvkwtn
✅ Preview: https://snowpack-git-improve-dev.pikapkg.vercel.app

export {getUrlForFile as unstable__getUrlForFile} from './build/file-urls';

/** DEPRECATED: Promoted to startServer() **/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General note: if you make this /** @deprecated Promoted to startServer() **/ then it shows up in the editor with a line through

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great tip, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants