Skip to content

Commit acfc272

Browse files
committed
feat: update API documentation and add "Copy Markdown" functionality
- Updated the index.html to reference new JavaScript and CSS files. - Added "Copy Markdown" translation to multiple languages in common.json files. - Implemented a new feature in ApiDocs to copy API documentation in Markdown format to the clipboard. - Enhanced the UI with a button to trigger the copy action and display a success message.
1 parent dcee2b9 commit acfc272

43 files changed

Lines changed: 868 additions & 52 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.wrangler/state/v3/cache/default/blobs/a182819d882eeb5280fedb829bc7ae03037965b74bfc43ef73ef72a11764764a0000019d584559cf renamed to .wrangler/state/v3/cache/default/blobs/be3f75b5f98ce7c2f86a8d39a156b45bc280a3189433fd848ff709c7df065eb00000019d58c2b0dd

File renamed without changes.

.wrangler/state/v3/d1/miniflare-D1DatabaseObject/b9601554bc553160143c0ac4f5392ed7132f0c25a732966b7e3290da1514e2c5.sqlite-wal

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import worker, * as OTHER_EXPORTS from "/Users/songjunxi/Desktop/repos/vmail/worker/src/index.ts";
2+
import * as __MIDDLEWARE_0__ from "/Users/songjunxi/Desktop/repos/vmail/node_modules/.pnpm/wrangler@3.114.15/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts";
3+
import * as __MIDDLEWARE_1__ from "/Users/songjunxi/Desktop/repos/vmail/node_modules/.pnpm/wrangler@3.114.15/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts";
4+
5+
export * from "/Users/songjunxi/Desktop/repos/vmail/worker/src/index.ts";
6+
7+
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
8+
9+
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
10+
]
11+
export default worker;
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// This loads all middlewares exposed on the middleware object and then starts
2+
// the invocation chain. The big idea is that we can add these to the middleware
3+
// export dynamically through wrangler, or we can potentially let users directly
4+
// add them as a sort of "plugin" system.
5+
6+
import ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from "/Users/songjunxi/Desktop/repos/vmail/.wrangler/tmp/bundle-8XMmoz/middleware-insertion-facade.js";
7+
import { __facade_invoke__, __facade_register__, Dispatcher } from "/Users/songjunxi/Desktop/repos/vmail/node_modules/.pnpm/wrangler@3.114.15/node_modules/wrangler/templates/middleware/common.ts";
8+
import type { WorkerEntrypointConstructor } from "/Users/songjunxi/Desktop/repos/vmail/.wrangler/tmp/bundle-8XMmoz/middleware-insertion-facade.js";
9+
10+
// Preserve all the exports from the worker
11+
export * from "/Users/songjunxi/Desktop/repos/vmail/.wrangler/tmp/bundle-8XMmoz/middleware-insertion-facade.js";
12+
13+
class __Facade_ScheduledController__ implements ScheduledController {
14+
readonly #noRetry: ScheduledController["noRetry"];
15+
16+
constructor(
17+
readonly scheduledTime: number,
18+
readonly cron: string,
19+
noRetry: ScheduledController["noRetry"]
20+
) {
21+
this.#noRetry = noRetry;
22+
}
23+
24+
noRetry() {
25+
if (!(this instanceof __Facade_ScheduledController__)) {
26+
throw new TypeError("Illegal invocation");
27+
}
28+
// Need to call native method immediately in case uncaught error thrown
29+
this.#noRetry();
30+
}
31+
}
32+
33+
function wrapExportedHandler(worker: ExportedHandler): ExportedHandler {
34+
// If we don't have any middleware defined, just return the handler as is
35+
if (
36+
__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
37+
__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
38+
) {
39+
return worker;
40+
}
41+
// Otherwise, register all middleware once
42+
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
43+
__facade_register__(middleware);
44+
}
45+
46+
const fetchDispatcher: ExportedHandlerFetchHandler = function (
47+
request,
48+
env,
49+
ctx
50+
) {
51+
if (worker.fetch === undefined) {
52+
throw new Error("Handler does not export a fetch() function.");
53+
}
54+
return worker.fetch(request, env, ctx);
55+
};
56+
57+
return {
58+
...worker,
59+
fetch(request, env, ctx) {
60+
const dispatcher: Dispatcher = function (type, init) {
61+
if (type === "scheduled" && worker.scheduled !== undefined) {
62+
const controller = new __Facade_ScheduledController__(
63+
Date.now(),
64+
init.cron ?? "",
65+
() => {}
66+
);
67+
return worker.scheduled(controller, env, ctx);
68+
}
69+
};
70+
return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
71+
},
72+
};
73+
}
74+
75+
function wrapWorkerEntrypoint(
76+
klass: WorkerEntrypointConstructor
77+
): WorkerEntrypointConstructor {
78+
// If we don't have any middleware defined, just return the handler as is
79+
if (
80+
__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
81+
__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
82+
) {
83+
return klass;
84+
}
85+
// Otherwise, register all middleware once
86+
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
87+
__facade_register__(middleware);
88+
}
89+
90+
// `extend`ing `klass` here so other RPC methods remain callable
91+
return class extends klass {
92+
#fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = (
93+
request,
94+
env,
95+
ctx
96+
) => {
97+
this.env = env;
98+
this.ctx = ctx;
99+
if (super.fetch === undefined) {
100+
throw new Error("Entrypoint class does not define a fetch() function.");
101+
}
102+
return super.fetch(request);
103+
};
104+
105+
#dispatcher: Dispatcher = (type, init) => {
106+
if (type === "scheduled" && super.scheduled !== undefined) {
107+
const controller = new __Facade_ScheduledController__(
108+
Date.now(),
109+
init.cron ?? "",
110+
() => {}
111+
);
112+
return super.scheduled(controller);
113+
}
114+
};
115+
116+
fetch(request: Request<unknown, IncomingRequestCfProperties>) {
117+
return __facade_invoke__(
118+
request,
119+
this.env,
120+
this.ctx,
121+
this.#dispatcher,
122+
this.#fetchDispatcher
123+
);
124+
}
125+
};
126+
}
127+
128+
let WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined;
129+
if (typeof ENTRY === "object") {
130+
WRAPPED_ENTRY = wrapExportedHandler(ENTRY);
131+
} else if (typeof ENTRY === "function") {
132+
WRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY);
133+
}
134+
export default WRAPPED_ENTRY;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function stripCfConnectingIPHeader(input, init) {
2+
const request = new Request(input, init);
3+
request.headers.delete("CF-Connecting-IP");
4+
return request;
5+
}
6+
7+
globalThis.fetch = new Proxy(globalThis.fetch, {
8+
apply(target, thisArg, argArray) {
9+
return Reflect.apply(target, thisArg, [
10+
stripCfConnectingIPHeader.apply(null, argArray),
11+
]);
12+
},
13+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import worker, * as OTHER_EXPORTS from "/Users/songjunxi/Desktop/repos/vmail/worker/src/index.ts";
2+
import * as __MIDDLEWARE_0__ from "/Users/songjunxi/Desktop/repos/vmail/node_modules/.pnpm/wrangler@3.114.15/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts";
3+
import * as __MIDDLEWARE_1__ from "/Users/songjunxi/Desktop/repos/vmail/node_modules/.pnpm/wrangler@3.114.15/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts";
4+
5+
export * from "/Users/songjunxi/Desktop/repos/vmail/worker/src/index.ts";
6+
7+
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
8+
9+
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
10+
]
11+
export default worker;

0 commit comments

Comments
 (0)