daptin
0.10.3
下载 • 文档 • 社区
./daptin
.
. // logs truncated for brevity
.
INFO[2024-10-16 11:08:58] Listening websocket server at ... /live
INFO[2024-10-16 11:08:58] Our admin is [[email protected]]
INFO[2024-10-16 11:08:58] [ProcessId = 86403] Listening at port: :6336
INFO[2024-10-16 11:08:58] Get certificate for [Parths-MacBook-Pro.local]: true
INFO[2024-10-16 11:08:58] Listening at: [:6336]
INFO[2024-10-16 11:08:58] TLS server listening on port :6443
INFO[2024-10-16 11:09:03] Member says: Message < members: Joining from 192.168.0.125: 5336>
服务器已启动,使用 sqlite 数据库,因为我们没有指定 mysql 或 postgres。
调用注册“action”api来创建一个新的user_account
curl ' http://localhost:6333/action/user_account/signup ' -X POST
--data-raw ' {"attributes":{"email":"[email protected]","password":"[email protected]","name":"[email protected]","passwordConfirm":"[email protected]"}} '
在新实例上,所有操作都允许由来宾执行,因此您不应该看到此内容
[
{
"Attributes" : {
"message" : " http error (403) forbidden and 0 more errors, forbidden " ,
"title" : " failed " ,
"type" : " error "
},
"ResponseType" : " client.notify "
}
]
你应该看到这个
[
{
"ResponseType" : " client.notify " ,
"Attributes" : {
"__type" : " client.notify " ,
"message" : " Sign-up successful. Redirecting to sign in " ,
"title" : " Success " ,
"type" : " success "
}
},
{
"ResponseType" : " client.redirect " ,
"Attributes" : {
"__type" : " client.redirect " ,
"delay" : 2000 ,
"location" : " /auth/signin " ,
"window" : " self "
}
}
]
curl ' http://localhost:6336/action/user_account/signin '
--data-raw ' {"attributes":{"email":"[email protected]","password":"[email protected]"}} '
[
{
" Attributes " : {
" key " : " token " ,
" value " : " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFydHBhckBnbWFpbC5jb20iLCJleHAiOjE3MjkzMjExMjIsImlhdCI6MTcyOTA2MTkyMiwiaXNzIjoiZGFwdGluLTAxOTIyOCIsImp0aSI6IjAxOTI5NDFmLTI2MGUtN2I0Ni1hMWFlLWYxMGZhZTcwMDE3OSIsIm5hbWUiOiJhcnRwYXJAZ21haWwuY29tIiwibmJmIjoxNzI5MDYxOTIyLCJzdWIiOiIwMTkyMmUxYS1kNWVhLTcxYzktYmQzZS02MTZkMjM3ODBmOTMifQ.H-GLmXCT-o7RxXrjo5Of0K8Nw5mpOOw6jgoXnd5KUxo "
},
" ResponseType " : " client.store.set "
},
{
" Attributes " : {
" key " : " token " ,
" value " : " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFydHBhckBnbWFpbC5jb20iLCJleHAiOjE3MjkzMjExMjIsImlhdCI6MTcyOTA2MTkyMiwiaXNzIjoiZGFwdGluLTAxOTIyOCIsImp0aSI6IjAxOTI5NDFmLTI2MGUtN2I0Ni1hMWFlLWYxMGZhZTcwMDE3OSIsIm5hbWUiOiJhcnRwYXJAZ21haWwuY29tIiwibmJmIjoxNzI5MDYxOTIyLCJzdWIiOiIwMTkyMmUxYS1kNWVhLTcxYzktYmQzZS02MTZkMjM3ODBmOTMifQ.H-GLmXCT-o7RxXrjo5Of0K8Nw5mpOOw6jgoXnd5KUxo; SameSite=Strict "
},
" ResponseType " : " client.cookie.set "
},
{
" Attributes " : {
" message " : " Logged in " ,
" title " : " Success " ,
" type " : " success "
},
" ResponseType " : " client.notify "
},
{
" Attributes " : {
" delay " : 2000,
" location " : " / " ,
" window " : " self "
},
" ResponseType " : " client.redirect "
}
]
我们将使用
export TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFydHBhckBnbWFpbC5jb20iLCJleHAiOjE3MjkzMjExMjIsImlhdCI6MTcyOTA2MTkyMiwiaXNzIjoiZGFwdGluLTAxOTIyOCIsImp0aSI6IjAxOTI5NDFmLTI2MGUtN2I0Ni1hMWFlLWYxMGZhZTcwMDE3OSIsIm5hbWUiOiJhcnRwYXJAZ21haWwuY29tIiwibmJmIjoxNzI5MDYxOTIyLCJzdWIiOiIwMTkyMmUxYS1kNWVhLTcxYzktYmQzZS02MTZkMjM3ODBmOTMifQ.H-GLmXCT-o7RxXrjo5Of0K8Nw5mpOOw6jgoXnd5KUxo
对于其余的 api 调用。这是一个带有以下数据的 JWT 令牌
{
"email" : " [email protected] " , // user email
"exp" : 1729321122 , // token expiry
"iat" : 1729061922 , // token issued at time
"iss" : " daptin-019228 " , // token issuer (your daptin instance)
"jti" : " 0192941f-260e-7b46-a1ae-f10fae700179 " , // unique identifier for this token
"name" : " [email protected] " , // user name
"nbf" : 1729061922 , // token valid not before timestamp
"sub" : " 01922e1a-d5ea-71c9-bd3e-616d23780f93 " // user reference id
}
因此,您有一个帐户和一个用于验证该帐户的令牌。但你需要它吗?否。无需任何授权即可调用获取所有用户帐户
curl http://localhost:6333/api/user_account
{
"links" : {
"current_page" : 1 ,
"from" : 0 ,
"last_page" : 1 ,
"per_page" : 10 ,
"to" : 10 ,
"total" : 1
},
"data" : [
{
"type" : " user_account " ,
"id" : " 01929429-3d8f-7e53-8f15-a663e05fb01b " ,
"attributes" : {
"__type" : " user_account " ,
"confirmed" : 0 ,
"created_at" : " 2024-10-16T07:09:43.86360642Z " ,
"email" : " [email protected] " ,
"name" : " [email protected] " ,
"password" : " " ,
"permission" : 2097151 ,
"reference_id" : " 01929429-3d8f-7e53-8f15-a663e05fb01b " ,
"updated_at" : " 2024-10-16T07:09:43.863622045Z " ,
"user_account_id" : " 01929429-3d8f-7e53-8f15-a663e05fb01b "
},
"relationships" : { /// ... }
}
]
}
所有其他表(例如站点、云存储、文档、用户组)中的所有数据也是如此。并且你还可以调用更新和删除API(这里没有演示,但你可以尝试,玩完后删除sqlite数据库文件以将其全部重置)
作为第一个用户,您可以选择将其保持打开状态或启用多层权限并成为管理员
curl ' http://localhost:6336/action/world/become_an_administrator ' --compressed -X POST
-H " Authorization: Bearer $TOKEN " --data-raw ' {} '
此时,所有其他 api 都被锁定,只有管理员(即您)可以访问。您希望向访客或用户开放少量或大量操作。
...将很快更新
https://github.com/daptin/daptin-js-client
入门套件:https://github.com/daptin/vue_typescript_starter_kit
定义模式
寻找
通过 ID 获取
创造
删除
删除关系
列出关系
红宝石 | Python | JavaScript |
打字稿 | PHP | 镖 |
。网 | 爪哇 | iOS系统 |
灵丹妙药 | 右 | 珀尔 |
OpenAPI V3 规范是为每个公开的端点自动生成的。这可用于生成更多文档和客户。
curl http://localhost/apispec.yaml