Package Exports
- @momocow/cloudflare-worker-leetcode-progress
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@momocow/cloudflare-worker-leetcode-progress) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Cloudflare Worker LeetCode Progress
Generate LeetCode progress as a SVG deployed on Cloudflare Workers.
Usage
const createHandler = require('@momocow/cloudflare-worker-leetcode-progress').default
const handleRequest = createHandler({ /* options */ });
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event) ?? new Response('', { status: 405 }));
});Remember to configure your
wrangler.tomlto build with webpack.type = "webpack"
Options
cacheName: string = undefinedIf it is
undefined, no caches will be used. If it's"default", the default cache will be used; otherwise a new cache is opened using the provided name. Seeawait caches.open(name).cacheTTL: number = 300000 (in ms)The value is used to generate the max age of
Cache-Controland compute theExpirestime.cors: boolean = falseAllow CORS or not. If set, CORS headers will be generated and OPTIONS method will be handled.
hashAlgorithm: "sha1" | "sha256" | "sha384" | "sha512" = "sha1"Hash algorithm to use to generate ETag.
leetcodeGraphqlUrl: string = "https://leetcode.com/graphql"LeetCode GraphQL endpoint.
progressType: "global" | "session" = "global"Type of LeetCode progress to display. If it's "session", the statistics of the current active session is fetched.
This option is set for the default progress type; however, at each request, ones can provided
progress-typeparameter in the query string to change the value.userlist: Set<string> = undefinedAccess control for your Worker. If provided, only usernames appear in the set is allowed to generate the progress; otherwise, 403 forbidden is responsed.
Note that leave it undefined means access control disabled, every is allowed to access the Worker.
fetch: typeof fetch = fetchThis option is passed to
graphql-requestto avoid using XMLHttpRequest (No such API in Worker Runtime).
Query String Parameters
username: stringprogress-type: "global" | "session"