-
Notifications
You must be signed in to change notification settings - Fork 220
Factor out redirect middleware and run in dev server #513
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
Conversation
Simplifies things like gitignore
Makes it easier to find in vscode etc.
A live preview of this PR will be available at the URL(s) below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Also checked it in manually and navigated to a redirect. 👏
/** | ||
* Creates a Koa middleware that performs lit.dev redirection logic. | ||
*/ | ||
export const redirectMiddleware = (): Koa.Middleware => async (ctx, next) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor
@@ -1,13 +1,13 @@ | |||
{ | |||
"compilerOptions": { | |||
"incremental": true, | |||
"tsBuildInfoFile": "./tsconfig.tsbuildinfo", | |||
"tsBuildInfoFile": "./lib/.tsbuildinfo", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: Other packages kept this as "./lib/tsconfig.tsbuildinfo"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm interesting. The default is actually <outdir>/.tsbuildinfo
which matches this path (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html). So we could also just omit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might go through and standardize these in a followup.
Previously, our redirect logic did not work when running in dev mode, since that code was only present in the production server. Now that logic is factored out into a Koa middleware, so that it can run in both places.
I also made a few other changes to make working on the server easier going forward.
In an upcoming PR, I'll be adding a middleware to deal with GitHub auth tokens, so now it will be easier to run that both in production and during local development.