Skip to content

First Project

github-actions[bot] edited this page Apr 26, 2026 · 2 revisions

First Project, Build a Todo API

This guide builds a simple Todo API end-to-end using ɳSelf. No frontend, pure backend API with GraphQL and JWT auth.

1. Initialize the Project

mkdir todo-api && cd todo-api
nself init --name todo-api --domain localhost

Accept all defaults. This generates a .env file with secure random secrets.

2. Start the Stack

nself build
nself start

Wait for all services to show healthy. Then confirm URLs:

nself urls

3. Open the Hasura Console

nself db hasura console

This opens https://localhost/hasura/console in your browser. The admin secret is in your .env as HASURA_GRAPHQL_ADMIN_SECRET.

4. Create the todos Table

In the Hasura Console:

  1. Click DataCreate Table
  2. Table name: todos
  3. Add columns:
  • id, UUID, primary key, default: gen_random_uuid()
  • title, Text, not null
  • done, Boolean, not null, default: false
  • created_at, Timestamptz, default: now()
  1. Click Add Table

5. Track the Table

Hasura will prompt you to track the new table. Click Track to expose it in the GraphQL API.

6. Insert and Query Data

In the GraphiQL explorer, insert a todo:

mutation {
  insert_todos_one(object: { title: "Learn nSelf" }) {
    id
    title
    done
    created_at
  }
}

Then query all todos:

query {
  todos {
    id
    title
    done
    created_at
  }
}

7. Test JWT Auth

The Auth service is running at https://localhost/auth/. Register a user:

curl -X POST https://localhost/auth/signup/email-password \
  -H "Content-Type: application/json" \
  -d '{"email":"dev@example.com","password":"password123"}'

The response includes a JWT token. Use it in subsequent GraphQL requests:

curl -X POST https://localhost/v1/graphql \
  -H "Authorization: Bearer <jwt_token>" \
  -H "Content-Type: application/json" \
  -d '{"query":"{ todos { id title } }"}'

Set up row-level security in Hasura permissions to restrict rows by user ID.

8. Stop When Done

nself stop

Next: Architecture · Plugin-Overview

Home


Getting Started


Commands


Features


Configuration


Plugins (87 + 10 monitoring)

Free (25)
Pro (62)
Planned (26)
  • plugin-audit
  • plugin-blog
  • plugin-checkout
  • plugin-commerce
  • plugin-drm
  • plugin-export
  • plugin-flow
  • plugin-import
  • plugin-ldap
  • plugin-mailgun
  • plugin-media
  • plugin-oauth-providers
  • plugin-pages
  • plugin-postmark
  • plugin-rate-limit
  • plugin-reports
  • plugin-saml
  • plugin-scheduler
  • plugin-sendgrid
  • plugin-sso
  • plugin-subscription
  • plugin-thumb
  • plugin-transcoder
  • plugin-twilio
  • plugin-waf
  • plugin-watermark

Guides


Architecture


Reference


Licensing


Security


Brand


Operations


Contributing


Changelog

Clone this wiki locally