C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • Citadel (Admin)
  • Dominion (RBAC)
  • Blocks (Modules)
  • Echo (Realtime)
  • Telescope (Debug)
  • Payment (Midtrans)
Official Package

Citadel

@canxjs/citadel provides a featherweight authentication system for SPAs, mobile applications, and simple token-based APIs. Inspired by Laravel Sanctum.

Installation

terminal
1npm install @canxjs/citadel
2# or
3bun add @canxjs/citadel

Configuration

Register Provider

providers.ts
1// src/app/providers.ts
2import { CitadelServiceProvider } from "@canxjs/citadel";
3
4export const providers = [
5 CitadelServiceProvider,
6];

Run Migrations

terminal
1node canx citadel:install
2node canx migrate

Issuing Tokens

Add the HasApiTokens mixin to your User model, then use createToken() to generate tokens.

AuthController.ts
1import { User } from "./models/User";
2
3// User model must use HasApiTokens mixin
4const user = await User.find(1);
5
6const { plainTextToken } = await user.createToken("my-app", ["*"]);
7
8return response.json({ token: plainTextToken });

Token Abilities

Tokens can be scoped with specific abilities (permissions). Use tokenCan() to check.

example.ts
1// Create a token with specific abilities
2const token = await user.createToken("editor", ["server:create", "server:update"]);
3
4// Check ability
5if (user.tokenCan("server:create")) {
6 // User can create servers
7}

Next Steps

Explore more authentication and authorization options.