清理无效依赖
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
var db = kv.repo("self");
|
||||
if(request.path == "put"){
|
||||
const db = kv.repo("self");
|
||||
if(request.path === "put"){
|
||||
data = db.get('key')
|
||||
if(data == undefined){
|
||||
if(data == null){
|
||||
db.set('key','0')
|
||||
}else {
|
||||
db.set('key',(parseInt(data)+1).toString())
|
||||
@@ -9,11 +9,11 @@ if(request.path == "put"){
|
||||
}
|
||||
response.write("当前存储的数值为 " + db.get('key'))
|
||||
|
||||
var test = kv.repo("test");
|
||||
const test = kv.repo("test");
|
||||
for (let i = 0; i < 500; i++) {
|
||||
test.set("key" + i,"value" + i);
|
||||
}
|
||||
var list = test.list()
|
||||
const list = test.list();
|
||||
console.log(list.keys.length)
|
||||
console.log(list.cursor)
|
||||
console.log(list.hasNext)
|
||||
|
||||
19
global-types/globals.d.ts
vendored
19
global-types/globals.d.ts
vendored
@@ -1,5 +1,6 @@
|
||||
// goja.d.ts
|
||||
|
||||
|
||||
declare global {
|
||||
// WebSocket 相关类型
|
||||
interface WebSocketConnection {
|
||||
@@ -29,7 +30,7 @@ declare global {
|
||||
// Request 相关类型
|
||||
interface RequestObject {
|
||||
method: string;
|
||||
url: URL;
|
||||
url: string;
|
||||
rawPath: string;
|
||||
host: string;
|
||||
remoteAddr: string;
|
||||
@@ -93,17 +94,17 @@ declare global {
|
||||
}
|
||||
|
||||
interface KVOps {
|
||||
get(key: string): Promise<string | null>;
|
||||
set(key: string, value: string): Promise<void>;
|
||||
delete(key: string): Promise<boolean>;
|
||||
putIfNotExists(key: string, value: string): Promise<boolean>;
|
||||
compareAndSwap(key: string, oldValue: string, newValue: string): Promise<boolean>;
|
||||
list(limit?: number, cursor?: string): Promise<KVListResult>;
|
||||
get(key: string): string | null;
|
||||
set(key: string, value: string): void;
|
||||
delete(key: string): boolean;
|
||||
putIfNotExists(key: string, value: string): boolean;
|
||||
compareAndSwap(key: string, oldValue: string, newValue: string): boolean;
|
||||
list(limit?: number, cursor?: string): KVListResult;
|
||||
}
|
||||
|
||||
interface KVSystem {
|
||||
repo(group: string): Promise<KVOps>;
|
||||
org(group: string): Promise<KVOps>;
|
||||
repo(group: string): KVOps;
|
||||
org(group: string): KVOps;
|
||||
}
|
||||
|
||||
const kv: KVSystem;
|
||||
|
||||
37
global-types/package-lock.json
generated
37
global-types/package-lock.json
generated
@@ -1,45 +1,12 @@
|
||||
{
|
||||
"name": "@d7z-project/gitea-pages",
|
||||
"version": "0.0.1-rc1",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@d7z-project/gitea-pages",
|
||||
"version": "0.0.1-rc1",
|
||||
"dependencies": {
|
||||
"@dop251/types-goja_nodejs-url": "^0.0.0-20251015174255-5e94316bedaf"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "next"
|
||||
}
|
||||
},
|
||||
"node_modules/@dop251/types-goja_nodejs-global": {
|
||||
"version": "0.0.0-20251015174255-5e94316bedaf",
|
||||
"resolved": "https://registry.npmmirror.com/@dop251/types-goja_nodejs-global/-/types-goja_nodejs-global-0.0.0-20251015174255-5e94316bedaf.tgz",
|
||||
"integrity": "sha512-K54niz+UY67vH4IYfGJztG049z6RdtZfNGoI6VPC97NtRUR16D/k+iwg6dnbppuj/uBwCowimI+Qj9dWheucpg=="
|
||||
},
|
||||
"node_modules/@dop251/types-goja_nodejs-url": {
|
||||
"version": "0.0.0-20251015174255-5e94316bedaf",
|
||||
"resolved": "https://registry.npmmirror.com/@dop251/types-goja_nodejs-url/-/types-goja_nodejs-url-0.0.0-20251015174255-5e94316bedaf.tgz",
|
||||
"integrity": "sha512-h9v7QtZydYruGj7vdIe/KSCqeywv8L0XruaH3wzSHb7A0PZtaQxRr4ANpKGoTxqPrLYfqbQaG7IRAbg/ylEBEA==",
|
||||
"dependencies": {
|
||||
"@dop251/types-goja_nodejs-global": "0.0.0-20251015174255-5e94316bedaf"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "6.0.0-dev.20251121",
|
||||
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-6.0.0-dev.20251121.tgz",
|
||||
"integrity": "sha512-TrGhGS4hOAKgwizhMuH/3pbTNNBMCpxRA7ia8Lrv4HRMOAOzI5lWhP5uoKRDmmaF3pUVe90MBYjSieM498zUqQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
"version": "0.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,9 @@
|
||||
"name": "@d7z-project/gitea-pages",
|
||||
"version": "0.0.1",
|
||||
"types": "globals.d.ts",
|
||||
"scripts": {
|
||||
"test": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "next"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/d7z-project/gitea-pages.git"
|
||||
},
|
||||
"private": false,
|
||||
"dependencies": {
|
||||
"@dop251/types-goja_nodejs-url": "^0.0.0-20251015174255-5e94316bedaf"
|
||||
}
|
||||
"private": false
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func RequestInject(ctx core.FilterContext, jsCtx *goja.Runtime, req *http.Reques
|
||||
}
|
||||
return jsCtx.GlobalObject().Set("request", map[string]any{
|
||||
"method": req.Method,
|
||||
"url": url,
|
||||
"url": url.String(),
|
||||
"rawPath": req.URL.Path,
|
||||
"host": req.Host,
|
||||
"remoteAddr": req.RemoteAddr,
|
||||
|
||||
Reference in New Issue
Block a user