tp
02/07/2021, 2:11 AMtp
02/07/2021, 2:11 AMtp
02/07/2021, 2:11 AMtp
02/07/2021, 2:11 AMkenton
02/07/2021, 2:15 AMkenton
02/07/2021, 2:15 AMtp
02/07/2021, 2:17 AMtp
02/07/2021, 2:17 AMkenton
02/07/2021, 2:22 AMtp
02/07/2021, 2:22 AMjed
02/08/2021, 11:05 AMjed
02/08/2021, 11:12 AMwaitUntil
make it to DO... @User, can you clarify whether this is a method or a function? ie, does it need to be bound to the state
object? https://discord.com/channels/595317990191398933/802187271067140107/807309699544121384Greg Brimble | Cloudflare Pages
02/08/2021, 11:14 AMGreg Brimble | Cloudflare Pages
02/08/2021, 11:14 AMstate.waitUntil(promise: Promise)
jed
02/08/2021, 11:15 AMthis.waitUntil = state.waitUntil
or whether the function is indeed a method that needs to be bound to its object.jed
02/08/2021, 11:16 AMwaitUntil
for the "parent" worker of a DO?Greg Brimble | Cloudflare Pages
02/08/2021, 11:17 AMstate.waitUntil(...)
. Seemingly nothing stopping you from saving this.state = state
and then just calling this.state.waitUntil
though 🙂eidam | SuperSaaS
02/08/2021, 11:43 AMGreg Brimble | Cloudflare Pages
02/08/2021, 11:50 AMeidam | SuperSaaS
02/08/2021, 11:52 AMGreg Brimble | Cloudflare Pages
02/08/2021, 11:55 AMtypescript
export class Route {
constructor(method, pathRegex) {
this.method = method.toLowerCase();
this.pathRegex = pathRegex;
}
matches(request) {
if (request.method.toLowerCase() !== this.method) return false;
const url = new URL(request.url);
if (!url.pathname.match(this.pathRegex)) return false;
// I'm re-reading this now, and I can only apologize.
return true;
}
}
export class Router {
constructor() {
this.routes = [];
}
handle(request, ...args) {
const route = this.routes.find(([route, handler]) =>
route.matches(request)
);
if (route) return route[1](request, ...args);
return new Response(null, { status: 404 });
}
}
I got that wrangler branch working though, so it should be more than possible to pull in any router you like (e.g. https://github.com/glenstack/glenstack/tree/master/packages/cf-workers-router)eidam | SuperSaaS
02/08/2021, 11:58 AMkenton
02/08/2021, 3:52 PMwaitUntil()
in a regular (non-DO) worker that uses modules syntax; we're still figuring out where we want to stick that in. Probably a third parameter to the fetch handler...jed
02/08/2021, 11:50 PMGreg Brimble | Cloudflare Pages
02/08/2021, 11:51 PMGreg Brimble | Cloudflare Pages
02/08/2021, 11:51 PMjed
02/08/2021, 11:51 PMjed
02/08/2021, 11:53 PMGreg Brimble | Cloudflare Pages
02/08/2021, 11:53 PMjed
02/08/2021, 11:53 PM