Download • Documentation • Community
./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>
Server is up, sqlite database is used since we did not specify mysql or postgres.
call the signup "action" api to create a new 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]"}}'
On a fresh instance all actions are allowed to be executed by guests, so you shouldn't see this
[
{
"Attributes": {
"message": "http error (403) forbidden and 0 more errors, forbidden",
"title": "failed",
"type": "error"
},
"ResponseType": "client.notify"
}
]
You should see this
[
{
"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"
}
]
We will use
export TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFydHBhckBnbWFpbC5jb20iLCJleHAiOjE3MjkzMjExMjIsImlhdCI6MTcyOTA2MTkyMiwiaXNzIjoiZGFwdGluLTAxOTIyOCIsImp0aSI6IjAxOTI5NDFmLTI2MGUtN2I0Ni1hMWFlLWYxMGZhZTcwMDE3OSIsIm5hbWUiOiJhcnRwYXJAZ21haWwuY29tIiwibmJmIjoxNzI5MDYxOTIyLCJzdWIiOiIwMTkyMmUxYS1kNWVhLTcxYzktYmQzZS02MTZkMjM3ODBmOTMifQ.H-GLmXCT-o7RxXrjo5Of0K8Nw5mpOOw6jgoXnd5KUxo
for the rest of the api calls. This is a JWT token with following data
{
"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
}
So you have an account and a token to authenticate as that account. But do you need it? No. Call to fetch all user accounts works without any authorization
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": { /// ...}
}
]
}
And so does all the data in all other tables (eg site, cloud_store, document, usergroup). And you can call update and delete APIs as well (not demonstrated here, but you can try, delete the sqlite database file after you are done playing to reset it all)
As the first user, it is an option for you to leave it open or enable the multi-tier permission and becoming the Administrator
curl 'http://localhost:6336/action/world/become_an_administrator' --compressed -X POST
-H "Authorization: Bearer $TOKEN" --data-raw '{}'
At this point, all other apis are locked-down and only accessible by administrator, that is you. You want to open up few or many of actions to guests or users.
... Will be updated soon
https://github.com/daptin/daptin-js-client
Starter kit: https://github.com/daptin/vue_typescript_starter_kit
Define Schema
Find
Get By Id
Create
Delete
Delete relations
List relations
Ruby | Python | Javascript |
Typescript | PHP | Dart |
.NET | Java | iOS |
Elixir | R | Perl |
OpenAPI V3 spec is auto generated for each endpoint exposed. This can be use to generate further documentation and clients.
curl http://localhost/apispec.yaml