Skip to content

Commit 01500f0

Browse files
清理无效依赖
1 parent 309dd52 commit 01500f0

File tree

5 files changed

+19
-60
lines changed

5 files changed

+19
-60
lines changed

examples/js_kv/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
var db = kv.repo("self");
2-
if(request.path == "put"){
1+
const db = kv.repo("self");
2+
if(request.path === "put"){
33
data = db.get('key')
4-
if(data == undefined){
4+
if(data == null){
55
db.set('key','0')
66
}else {
77
db.set('key',(parseInt(data)+1).toString())
88
}
99
}
1010
response.write("当前存储的数值为 " + db.get('key'))
1111

12-
var test = kv.repo("test");
12+
const test = kv.repo("test");
1313
for (let i = 0; i < 500; i++) {
1414
test.set("key" + i,"value" + i);
1515
}
16-
var list = test.list()
16+
const list = test.list();
1717
console.log(list.keys.length)
1818
console.log(list.cursor)
1919
console.log(list.hasNext)

global-types/globals.d.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// goja.d.ts
22

3+
34
declare global {
45
// WebSocket 相关类型
56
interface WebSocketConnection {
@@ -29,7 +30,7 @@ declare global {
2930
// Request 相关类型
3031
interface RequestObject {
3132
method: string;
32-
url: URL;
33+
url: string;
3334
rawPath: string;
3435
host: string;
3536
remoteAddr: string;
@@ -93,17 +94,17 @@ declare global {
9394
}
9495

9596
interface KVOps {
96-
get(key: string): Promise<string | null>;
97-
set(key: string, value: string): Promise<void>;
98-
delete(key: string): Promise<boolean>;
99-
putIfNotExists(key: string, value: string): Promise<boolean>;
100-
compareAndSwap(key: string, oldValue: string, newValue: string): Promise<boolean>;
101-
list(limit?: number, cursor?: string): Promise<KVListResult>;
97+
get(key: string): string | null;
98+
set(key: string, value: string): void;
99+
delete(key: string): boolean;
100+
putIfNotExists(key: string, value: string): boolean;
101+
compareAndSwap(key: string, oldValue: string, newValue: string): boolean;
102+
list(limit?: number, cursor?: string): KVListResult;
102103
}
103104

104105
interface KVSystem {
105-
repo(group: string): Promise<KVOps>;
106-
org(group: string): Promise<KVOps>;
106+
repo(group: string): KVOps;
107+
org(group: string): KVOps;
107108
}
108109

109110
const kv: KVSystem;

global-types/package-lock.json

Lines changed: 2 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

global-types/package.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@
22
"name": "@d7z-project/gitea-pages",
33
"version": "0.0.1",
44
"types": "globals.d.ts",
5-
"scripts": {
6-
"test": "tsc --noEmit"
7-
},
8-
"devDependencies": {
9-
"typescript": "next"
10-
},
115
"repository": {
126
"type": "git",
137
"url": "git+https://github.com/d7z-project/gitea-pages.git"
148
},
15-
"private": false,
16-
"dependencies": {
17-
"@dop251/types-goja_nodejs-url": "^0.0.0-20251015174255-5e94316bedaf"
18-
}
9+
"private": false
1910
}

pkg/filters/goja/var_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func RequestInject(ctx core.FilterContext, jsCtx *goja.Runtime, req *http.Reques
3434
}
3535
return jsCtx.GlobalObject().Set("request", map[string]any{
3636
"method": req.Method,
37-
"url": url,
37+
"url": url.String(),
3838
"rawPath": req.URL.Path,
3939
"host": req.Host,
4040
"remoteAddr": req.RemoteAddr,

0 commit comments

Comments
 (0)