Public
Script
March 12, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
export const upgradeExpress = (handler: (request: Request) => Response | PromiseLike<Response>) =>
function(request: Request | express.Request, response?: express.Response): Response | Promise<Response> {
if (request instanceof Request) {
const response = handler(request);
if (response instanceof Response) {
return response;
} else {
return Promise.resolve(response);
}
}
const domain: string = request.get("host").replace(/\.express\.val\.run$/, ".web.val.run");
response!.redirect(`https://${domain}${request.originalUrl}`);
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 12, 2024