Skip to content

Instantly share code, notes, and snippets.

@kt3k
Last active April 28, 2021 05:01
Show Gist options
  • Save kt3k/f7a83339c0474279fb0ec37966ea38cf to your computer and use it in GitHub Desktop.
Save kt3k/f7a83339c0474279fb0ec37966ea38cf to your computer and use it in GitHub Desktop.
dts -> ts -> dts
addEventListener("fetch", (e) => {
const pathname = new URL(e.request.url).pathname;
switch (pathname) {
case "/foo.ts": {
e.respondWith(new Response("export * from './bar'", {
headers: {
"content-type": "application/typescript",
}
}));
return;
}
case "/bar": {
e.respondWith(new Response("export {}", {
headers: {
"content-type": "application/typescript",
}
}));
return;
}
default: {
e.respondWith(new Response("404 Not Found", { status: 404 }));
return;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment