Daptin
Daptin - Backend As A Service - GraphQL/JSON-API Headless CMS
Install / Use
/learn @daptin/DaptinREADME
./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 [artpar@gmail.com]
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.
signup, signin, user_account and usergroup
signup
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":"artpar@gmail.com","password":"artpar@gmail.com","name":"artpar@gmail.com","passwordConfirm":"artpar@gmail.com"}}'
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"
}
}
]
Sign in to get a JWT Bearer token
curl 'http://localhost:6336/action/user_account/signin' \
--data-raw '{"attributes":{"email":"artpar@gmail.com","password":"artpar@gmail.com"}}'
[
{
"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": "artpar@gmail.com", // 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": "artpar@gmail.com", // 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": "artpar1@gmail.com",
"name": "artpar1@gmail.com",
"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
📊 Self-Documentation Progress (Multi-Session Project)
Overall Progress: 71% Complete (37/52 features documented)
Session Tracking:
- Session 1: Foundation (7 features) - Configuration, Statistics, Meta, Health, JS Models, Aggregation ✅
- Session 2: Real-time & Communication (12 features) - WebSocket, YJS, SMTP, CalDAV, FTP, Feeds ✅
- Session 3: Advanced Data & Analytics (8 features) - Aggregation, GraphQL, Import/Export, Relationships ✅
- Session 4: Infrastructure & Configuration (10 features) - Config API, Rate Limiting, GZIP, Caching, CORS, TLS ✅
- Session 5: Workflow & Automation (Planned)
- Session 6: Client Integration & Developer Experience (Planned)
- Session 7: Final Documentation & Polish (Planned)
Documentation Artifacts:
/openapi.yaml- Self-updating API documentationSELF_DOCUMENTATION_MASTER_PLAN.md- Complete roadmapSESSION_HANDOFF.md- Progress trackingNEXT_SESSION_PROMPT.md- Next session guide
Overview
- Database backed persistence, 3NF normalized tables
- JSON API/GraphQL for CRUD apis
- User and group management and access control
- Social login with OAuth: tested with google, github, linkedin
- Actions for abstracting out business flows
- Extensive state tracking APIs
- Enable Data Auditing from a single toggle
- Synchronous Data Exchange with 3rd party APIs
- [Multil
