切换为 goja

This commit is contained in:
dragon
2025-11-17 17:33:40 +08:00
parent b20207de4c
commit 7778e95194
29 changed files with 634 additions and 575 deletions

10
examples/kv/.pages.yaml Normal file
View File

@@ -0,0 +1,10 @@
routes:
- path: "get"
js:
exec: "index.js"
debug: true
- path: "put"
js:
exec: "index.js"
debug: true

14
examples/kv/index.html Normal file
View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JS 概念验证</title>
</head>
<body>
<a href="/get">查询数据</a>
<a href="/put">更新数据</a>
</body>
</html>

10
examples/kv/index.js Normal file
View File

@@ -0,0 +1,10 @@
var db = kv.repo("self");
if(request.path == "put"){
data = db.get('key')
if(data == undefined){
db.set('key','0')
}else {
db.set('key',(parseInt(data)+1).toString())
}
}
response.write("当前存储的数值为 " + db.get('key'))