-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc21663
commit bfda46e
Showing
10 changed files
with
1,288 additions
and
453 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"printWidth": 140, | ||
"singleQuote": true, | ||
"semi": true, | ||
"useTabs": true | ||
} | ||
"$schema": "https://json.schemastore.org/prettierrc", | ||
"semi": false, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"printWidth": 110, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
{ | ||
"name": "ona-prox", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"deploy": "wrangler deploy", | ||
"dev": "wrangler dev", | ||
"start": "wrangler dev", | ||
"test": "vitest", | ||
"cf-typegen": "wrangler types" | ||
"cf-typegen": "wrangler types", | ||
"format": "prettier --write src/" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/vitest-pool-workers": "^0.5.2", | ||
"@cloudflare/vitest-pool-workers": "^0.5.20", | ||
"@cloudflare/workers-types": "^4.20241011.0", | ||
"typescript": "^5.5.2", | ||
"prettier": "^3.3.3", | ||
"typescript": "^5.6.3", | ||
"vitest": "2.0.5", | ||
"wrangler": "^3.60.3" | ||
} | ||
"wrangler": "^3.81.0" | ||
}, | ||
"type": "module" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
/** | ||
* Welcome to Cloudflare Workers! This is your first worker. | ||
* | ||
* - Run `npm run dev` in your terminal to start a development server | ||
* - Open a browser tab at http://localhost:8787/ to see your worker in action | ||
* - Run `npm run deploy` to publish your worker | ||
* | ||
* Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the | ||
* `Env` object can be regenerated with `npm run cf-typegen`. | ||
* | ||
* Learn more at https://developers.cloudflare.com/workers/ | ||
*/ | ||
|
||
export default { | ||
async fetch(request, env, ctx): Promise<Response> { | ||
return new Response('Hello World!'); | ||
}, | ||
} satisfies ExportedHandler<Env>; | ||
async fetch(request): Promise<Response> { | ||
const url: URL = new URL(request.url) | ||
const pathname: string = url.pathname | ||
let hostname: string | undefined = pathname.split('/').filter(Boolean)[0] | ||
let referer: string | null = request.headers.get('Referer') | ||
|
||
if (!hostname?.startsWith('~')) { | ||
hostname = '~i.pximg.net' | ||
referer = 'https://pixiv.net' | ||
} | ||
|
||
url.pathname = pathname.replace(`/${hostname}`, '') | ||
url.hostname = hostname.slice(1) | ||
|
||
return fetch(new Request(url, request), { | ||
headers: { | ||
...(referer && { Referer: referer }) | ||
} | ||
}) | ||
} | ||
} satisfies ExportedHandler<Env> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"] | ||
}, | ||
"include": ["./**/*.ts", "../src/env.d.ts"], | ||
"exclude": [] | ||
} | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": [ | ||
"@cloudflare/workers-types/experimental", | ||
"@cloudflare/vitest-pool-workers" | ||
] | ||
}, | ||
"include": [ | ||
"./**/*.ts", | ||
"../src/env.d.ts" | ||
], | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
{ | ||
"compilerOptions": { | ||
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | ||
|
||
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ | ||
"target": "es2021", | ||
/* Specify a set of bundled library declaration files that describe the target runtime environment. */ | ||
"lib": ["es2021"], | ||
/* Specify what JSX code is generated. */ | ||
"jsx": "react-jsx", | ||
|
||
/* Specify what module code is generated. */ | ||
"module": "es2022", | ||
/* Specify how TypeScript looks up a file from a given module specifier. */ | ||
"moduleResolution": "Bundler", | ||
/* Specify type package names to be included without being referenced in a source file. */ | ||
"types": [ | ||
"@cloudflare/workers-types/2023-07-01" | ||
], | ||
/* Enable importing .json files */ | ||
"resolveJsonModule": true, | ||
|
||
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ | ||
"allowJs": true, | ||
/* Enable error reporting in type-checked JavaScript files. */ | ||
"checkJs": false, | ||
|
||
/* Disable emitting files from a compilation. */ | ||
"noEmit": true, | ||
|
||
/* Ensure that each file can be safely transpiled without relying on other imports. */ | ||
"isolatedModules": true, | ||
/* Allow 'import x from y' when a module doesn't have a default export. */ | ||
"allowSyntheticDefaultImports": true, | ||
/* Ensure that casing is correct in imports. */ | ||
"forceConsistentCasingInFileNames": true, | ||
|
||
/* Enable all strict type-checking options. */ | ||
"strict": true, | ||
|
||
/* Skip type checking all .d.ts files. */ | ||
"skipLibCheck": true | ||
}, | ||
"exclude": ["test"], | ||
"include": ["worker-configuration.d.ts", "src/**/*.ts"] | ||
} | ||
"compilerOptions": { | ||
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | ||
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ | ||
"target": "es2021", | ||
/* Specify a set of bundled library declaration files that describe the target runtime environment. */ | ||
"lib": [ | ||
"es2021" | ||
], | ||
/* Specify what JSX code is generated. */ | ||
"jsx": "react-jsx", | ||
/* Specify what module code is generated. */ | ||
"module": "es2022", | ||
/* Specify how TypeScript looks up a file from a given module specifier. */ | ||
"moduleResolution": "Bundler", | ||
/* Specify type package names to be included without being referenced in a source file. */ | ||
"types": [ | ||
"@cloudflare/workers-types/2023-07-01" | ||
], | ||
/* Enable importing .json files */ | ||
"resolveJsonModule": true, | ||
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ | ||
"allowJs": true, | ||
/* Enable error reporting in type-checked JavaScript files. */ | ||
"checkJs": false, | ||
/* Disable emitting files from a compilation. */ | ||
"noEmit": true, | ||
/* Ensure that each file can be safely transpiled without relying on other imports. */ | ||
"isolatedModules": true, | ||
/* Allow 'import x from y' when a module doesn't have a default export. */ | ||
"allowSyntheticDefaultImports": true, | ||
/* Ensure that casing is correct in imports. */ | ||
"forceConsistentCasingInFileNames": true, | ||
/* Enable all strict type-checking options. */ | ||
"strict": true, | ||
/* Skip type checking all .d.ts files. */ | ||
"skipLibCheck": true | ||
}, | ||
"exclude": [ | ||
"test" | ||
], | ||
"include": [ | ||
"worker-configuration.d.ts", | ||
"src/**/*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'; | ||
|
||
export default defineWorkersConfig({ | ||
test: { | ||
poolOptions: { | ||
workers: { | ||
wrangler: { configPath: './wrangler.toml' }, | ||
}, | ||
}, | ||
}, | ||
test: { | ||
poolOptions: { | ||
workers: { | ||
wrangler: { configPath: './wrangler.toml' }, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters