···1+/**
2+ * Welcome to Cloudflare Workers! This is your first worker.
3+ *
4+ * - Run `npm run dev` in your terminal to start a development server
5+ * - Open a browser tab at http://localhost:8787/ to see your worker in action
6+ * - Run `npm run deploy` to publish your worker
7+ *
8+ * Bind resources to your worker in `wrangler.jsonc`. After adding bindings, a type definition for the
9+ * `Env` object can be regenerated with `npm run cf-typegen`.
10+ *
11+ * Learn more at https://developers.cloudflare.com/workers/
12+ */
13+14+export default {
15+ async fetch(request, env, ctx): Promise<Response> {
16+ /*const url = new URL(request.url);
17+ const proxyUrl = new URL(request.url);
18+ proxyUrl.host = "rocksky.apidog.io";
19+ proxyUrl.hostname = "rocksky.apidog.io";
20+ // set headers
21+ const headers = new Headers(request.headers);
22+ headers.set("X-Apidog--Docs-Site-ID", "rocksky");
23+ return fetch(proxyUrl.toString(), {
24+ method: request.method,
25+ headers,
26+ });*/
27+28+ // redirect to fmqouwwzmr.apidog.io
29+ return Response.redirect("https://docs.rocksky.app", 301);
30+ },
31+} satisfies ExportedHandler<Env>;
+25
rockskyapi/rocksky-doc/test/index.spec.ts
···0000000000000000000000000
···1+// test/index.spec.ts
2+import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
3+import { describe, it, expect } from 'vitest';
4+import worker from '../src/index';
5+6+// For now, you'll need to do something like this to get a correctly-typed
7+// `Request` to pass to `worker.fetch()`.
8+const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;
9+10+describe('Hello World worker', () => {
11+ it('responds with Hello World! (unit style)', async () => {
12+ const request = new IncomingRequest('http://example.com');
13+ // Create an empty context to pass to `worker.fetch()`.
14+ const ctx = createExecutionContext();
15+ const response = await worker.fetch(request, env, ctx);
16+ // Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
17+ await waitOnExecutionContext(ctx);
18+ expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
19+ });
20+21+ it('responds with Hello World! (integration style)', async () => {
22+ const response = await SELF.fetch('https://example.com');
23+ expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
24+ });
25+});
···1+{
2+ "compilerOptions": {
3+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4+5+ /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
6+ "target": "es2021",
7+ /* Specify a set of bundled library declaration files that describe the target runtime environment. */
8+ "lib": ["es2021"],
9+ /* Specify what JSX code is generated. */
10+ "jsx": "react-jsx",
11+12+ /* Specify what module code is generated. */
13+ "module": "es2022",
14+ /* Specify how TypeScript looks up a file from a given module specifier. */
15+ "moduleResolution": "Bundler",
16+ /* Specify type package names to be included without being referenced in a source file. */
17+ "types": [
18+ "@cloudflare/workers-types/2023-07-01"
19+ ],
20+ /* Enable importing .json files */
21+ "resolveJsonModule": true,
22+23+ /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
24+ "allowJs": true,
25+ /* Enable error reporting in type-checked JavaScript files. */
26+ "checkJs": false,
27+28+ /* Disable emitting files from a compilation. */
29+ "noEmit": true,
30+31+ /* Ensure that each file can be safely transpiled without relying on other imports. */
32+ "isolatedModules": true,
33+ /* Allow 'import x from y' when a module doesn't have a default export. */
34+ "allowSyntheticDefaultImports": true,
35+ /* Ensure that casing is correct in imports. */
36+ "forceConsistentCasingInFileNames": true,
37+38+ /* Enable all strict type-checking options. */
39+ "strict": true,
40+41+ /* Skip type checking all .d.ts files. */
42+ "skipLibCheck": true
43+ },
44+ "exclude": ["test"],
45+ "include": ["worker-configuration.d.ts", "src/**/*.ts"]
46+}