MCPcopy Create free account
hub / github.com/Forward-Future/loopy / fetch

Method fetch

loop-library/worker/src/index.js:828–864  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

826 }
827
828 async fetch(request) {
829 const url = new URL(request.url);
830
831 if (request.method !== "POST") {
832 return jsonResponse({ error: "Method not allowed" }, 405);
833 }
834
835 let body;
836
837 try {
838 body = await request.json();
839 } catch {
840 return jsonResponse({ error: "Invalid request" }, 400);
841 }
842
843 if (url.pathname === "/rate") {
844 return this.rate(body);
845 }
846
847 if (url.pathname === "/dedupe/reserve") {
848 return this.reserve(body);
849 }
850
851 if (url.pathname === "/dedupe/release") {
852 return this.release(body);
853 }
854
855 if (url.pathname === "/idempotency/check") {
856 return this.idempotency(body, false);
857 }
858
859 if (url.pathname === "/idempotency/bind") {
860 return this.idempotency(body, true);
861 }
862
863 return jsonResponse({ error: "Not found" }, 404);
864 }
865
866 async scheduleCleanup(expiresAt) {
867 const scheduledAt = await this.state.storage.getAlarm();

Callers 7

handleAuthVoteRouteFunction · 0.45
isPublishedLoopFunction · 0.45
voteStoreFetchFunction · 0.45
handleRequestFunction · 0.45
callGuardFunction · 0.45
handleLoopRouteFunction · 0.45
catalogFetchFunction · 0.45

Calls 5

rateMethod · 0.95
reserveMethod · 0.95
releaseMethod · 0.95
idempotencyMethod · 0.95
jsonResponseFunction · 0.70

Tested by

no test coverage detected