Skip to content

Commit c5f99d1

Browse files
committed
style: change indentation from tabs to spaces
- Update Biome config: indentStyle from tab to space - Reformat all code files with 2-space indentation - Maintain consistent code style across the project
1 parent 3fe6889 commit c5f99d1

File tree

17 files changed

+10619
-10619
lines changed

17 files changed

+10619
-10619
lines changed

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"files.associations": {
3-
"wrangler.json": "jsonc"
4-
}
2+
"files.associations": {
3+
"wrangler.json": "jsonc"
4+
}
55
}

biome.json

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
3-
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
4-
"files": {
5-
"ignoreUnknown": false,
6-
"experimentalScannerIgnores": ["worker-configuration.d.ts"]
7-
},
8-
"formatter": {
9-
"enabled": true,
10-
"formatWithErrors": false,
11-
"indentStyle": "tab",
12-
"indentWidth": 2,
13-
"lineEnding": "lf",
14-
"lineWidth": 140,
15-
"attributePosition": "auto",
16-
"bracketSameLine": false,
17-
"bracketSpacing": true,
18-
"expand": "auto",
19-
"useEditorconfig": true
20-
},
21-
"linter": { "enabled": true, "rules": { "recommended": true } },
22-
"javascript": {
23-
"formatter": {
24-
"jsxQuoteStyle": "double",
25-
"quoteProperties": "asNeeded",
26-
"trailingCommas": "all",
27-
"semicolons": "always",
28-
"arrowParentheses": "always",
29-
"bracketSameLine": false,
30-
"quoteStyle": "single",
31-
"attributePosition": "auto",
32-
"bracketSpacing": true
33-
}
34-
},
35-
"html": {
36-
"formatter": {
37-
"indentScriptAndStyle": false,
38-
"selfCloseVoidElements": "always"
39-
}
40-
},
41-
"assist": {
42-
"enabled": true,
43-
"actions": { "source": { "organizeImports": "on" } }
44-
}
2+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
3+
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
4+
"files": {
5+
"ignoreUnknown": false,
6+
"experimentalScannerIgnores": ["worker-configuration.d.ts"]
7+
},
8+
"formatter": {
9+
"enabled": true,
10+
"formatWithErrors": false,
11+
"indentStyle": "space",
12+
"indentWidth": 2,
13+
"lineEnding": "lf",
14+
"lineWidth": 140,
15+
"attributePosition": "auto",
16+
"bracketSameLine": false,
17+
"bracketSpacing": true,
18+
"expand": "auto",
19+
"useEditorconfig": true
20+
},
21+
"linter": { "enabled": true, "rules": { "recommended": true } },
22+
"javascript": {
23+
"formatter": {
24+
"jsxQuoteStyle": "double",
25+
"quoteProperties": "asNeeded",
26+
"trailingCommas": "all",
27+
"semicolons": "always",
28+
"arrowParentheses": "always",
29+
"bracketSameLine": false,
30+
"quoteStyle": "single",
31+
"attributePosition": "auto",
32+
"bracketSpacing": true
33+
}
34+
},
35+
"html": {
36+
"formatter": {
37+
"indentScriptAndStyle": false,
38+
"selfCloseVoidElements": "always"
39+
}
40+
},
41+
"assist": {
42+
"enabled": true,
43+
"actions": { "source": { "organizeImports": "on" } }
44+
}
4545
}

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
"name": "anything-md",
3-
"version": "0.0.1",
4-
"private": true,
5-
"scripts": {
6-
"deploy": "wrangler deploy",
7-
"dev": "wrangler dev",
8-
"start": "wrangler dev",
9-
"test": "vitest",
10-
"cf-typegen": "wrangler types",
11-
"format": "biome format --write .",
12-
"format:check": "biome format .",
13-
"lint": "biome lint --write .",
14-
"lint:check": "biome lint .",
15-
"check": "biome check --write .",
16-
"check:ci": "biome check ."
17-
},
18-
"devDependencies": {
19-
"@biomejs/biome": "2.3.14",
20-
"@cloudflare/vitest-pool-workers": "^0.12.4",
21-
"@types/node": "^25.2.2",
22-
"typescript": "^5.5.2",
23-
"vitest": "~3.2.0",
24-
"wrangler": "^4.63.0"
25-
}
2+
"name": "anything-md",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"deploy": "wrangler deploy",
7+
"dev": "wrangler dev",
8+
"start": "wrangler dev",
9+
"test": "vitest",
10+
"cf-typegen": "wrangler types",
11+
"format": "biome format --write .",
12+
"format:check": "biome format .",
13+
"lint": "biome lint --write .",
14+
"lint:check": "biome lint .",
15+
"check": "biome check --write .",
16+
"check:ci": "biome check ."
17+
},
18+
"devDependencies": {
19+
"@biomejs/biome": "2.3.14",
20+
"@cloudflare/vitest-pool-workers": "^0.12.4",
21+
"@types/node": "^25.2.2",
22+
"typescript": "^5.5.2",
23+
"vitest": "~3.2.0",
24+
"wrangler": "^4.63.0"
25+
}
2626
}

r2-cors.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"rules": [
3-
{
4-
"allowed": {
5-
"origins": ["https://anything-md.doocs.org", "https://anything-md.doocs.workers.dev", "https://doocs.org", "https://*.doocs.org"],
6-
"methods": ["GET", "HEAD"],
7-
"headers": ["*"]
8-
},
9-
"maxAgeSeconds": 86400
10-
}
11-
]
2+
"rules": [
3+
{
4+
"allowed": {
5+
"origins": ["https://anything-md.doocs.org", "https://anything-md.doocs.workers.dev", "https://doocs.org", "https://*.doocs.org"],
6+
"methods": ["GET", "HEAD"],
7+
"headers": ["*"]
8+
},
9+
"maxAgeSeconds": 86400
10+
}
11+
]
1212
}

src/config.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@
1414

1515
/** Hostname suffixes allowed for image proxying (comma-separated in env) */
1616
export function allowedImageHosts(env: Env): string[] {
17-
const raw = env.IMAGE_PROXY_HOSTS;
18-
return raw
19-
? raw
20-
.split(',')
21-
.map((s) => s.trim())
22-
.filter(Boolean)
23-
: ['qpic.cn'];
17+
const raw = env.IMAGE_PROXY_HOSTS;
18+
return raw
19+
? raw
20+
.split(',')
21+
.map((s) => s.trim())
22+
.filter(Boolean)
23+
: ['qpic.cn'];
2424
}
2525

2626
/** TTL for cached images in milliseconds */
2727
export function imageTtlMs(env: Env): number {
28-
const hours = Number(env.IMAGE_TTL_HOURS) || 8;
29-
return hours * 60 * 60 * 1000;
28+
const hours = Number(env.IMAGE_TTL_HOURS) || 8;
29+
return hours * 60 * 60 * 1000;
3030
}
3131

3232
/** Max parallel image uploads per request */
3333
export function imageUploadConcurrency(env: Env): number {
34-
return Number(env.IMAGE_UPLOAD_CONCURRENCY) || 5;
34+
return Number(env.IMAGE_UPLOAD_CONCURRENCY) || 5;
3535
}
3636

3737
/** Cache-Control max-age for R2 objects (seconds) */
3838
export function imageCacheMaxAge(env: Env): number {
39-
const hours = Number(env.IMAGE_TTL_HOURS) || 8;
40-
return hours * 60 * 60;
39+
const hours = Number(env.IMAGE_TTL_HOURS) || 8;
40+
return hours * 60 * 60;
4141
}
4242

4343
// ---------------------------------------------------------------------------
@@ -46,12 +46,12 @@ export function imageCacheMaxAge(env: Env): number {
4646

4747
/** Default fetch timeout in milliseconds */
4848
export function fetchTimeout(env: Env): number {
49-
return Number(env.FETCH_TIMEOUT_MS) || 15_000;
49+
return Number(env.FETCH_TIMEOUT_MS) || 15_000;
5050
}
5151

5252
/** Default max fetch attempts */
5353
export function fetchMaxAttempts(env: Env): number {
54-
return Number(env.FETCH_MAX_ATTEMPTS) || 3;
54+
return Number(env.FETCH_MAX_ATTEMPTS) || 3;
5555
}
5656

5757
// ---------------------------------------------------------------------------
@@ -60,5 +60,5 @@ export function fetchMaxAttempts(env: Env): number {
6060

6161
/** Allowed CORS origin (default: "*") */
6262
export function corsOrigin(env: Env): string {
63-
return env.CORS_ORIGIN || '*';
63+
return env.CORS_ORIGIN || '*';
6464
}

src/cors.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ import { corsOrigin } from './config';
77

88
/** Build CORS headers using the configured origin */
99
export function getCorsHeaders(env: Env): Record<string, string> {
10-
return {
11-
'Access-Control-Allow-Origin': corsOrigin(env),
12-
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
13-
'Access-Control-Allow-Headers': 'Content-Type',
14-
'Access-Control-Max-Age': '86400',
15-
};
10+
return {
11+
'Access-Control-Allow-Origin': corsOrigin(env),
12+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
13+
'Access-Control-Allow-Headers': 'Content-Type',
14+
'Access-Control-Max-Age': '86400',
15+
};
1616
}
1717

1818
/** Build a JSON response with CORS headers */
1919
export function jsonResponse(env: Env, data: unknown, status = 200): Response {
20-
return new Response(JSON.stringify(data, null, 2), {
21-
status,
22-
headers: {
23-
'Content-Type': 'application/json; charset=utf-8',
24-
...getCorsHeaders(env),
25-
},
26-
});
20+
return new Response(JSON.stringify(data, null, 2), {
21+
status,
22+
headers: {
23+
'Content-Type': 'application/json; charset=utf-8',
24+
...getCorsHeaders(env),
25+
},
26+
});
2727
}
2828

2929
/** Build a plain-text response with CORS headers */
3030
export function textResponse(env: Env, text: string, status = 200): Response {
31-
return new Response(text, {
32-
status,
33-
headers: {
34-
'Content-Type': 'text/markdown; charset=utf-8',
35-
...getCorsHeaders(env),
36-
},
37-
});
31+
return new Response(text, {
32+
status,
33+
headers: {
34+
'Content-Type': 'text/markdown; charset=utf-8',
35+
...getCorsHeaders(env),
36+
},
37+
});
3838
}
3939

4040
/** Shorthand for an error JSON response */
4141
export function errorResponse(env: Env, message: string, status = 400): Response {
42-
return jsonResponse(env, { success: false, error: message }, status);
42+
return jsonResponse(env, { success: false, error: message }, status);
4343
}
4444

4545
/** Handle CORS preflight (OPTIONS) request */
4646
export function handlePreflight(env: Env): Response {
47-
return new Response(null, { status: 204, headers: getCorsHeaders(env) });
47+
return new Response(null, { status: 204, headers: getCorsHeaders(env) });
4848
}

0 commit comments

Comments
 (0)