canx-starter-api
v1.0.4
Published
Minimal API Starter Kit for CanxJS - REST API with JWT Authentication
Maintainers
Readme
Canx Starter API
⚡ Minimal REST API template for CanxJS with JWT authentication.
Features
- ✅ JWT Authentication - Token-based auth with refresh tokens
- ✅ API Routes - Clean REST API structure
- ✅ Validation - Request validation with built-in validators
- ✅ Error Handling - Consistent JSON error responses
Quick Start
# Clone or copy this starter
bunx degit chandafa/canx-starters/api my-api
# Install dependencies
cd my-api
bun install
# Start development server
bun run devProject Structure
src/
├── controllers/ # API controllers
│ ├── AuthController.ts
│ └── UserController.ts
├── middlewares/ # Custom middleware
│ └── auth.ts
├── routes.ts # API route definitions
└── app.ts # Application entryAPI Endpoints
| Method | Endpoint | Description |
| ------ | -------------------- | -------------------------- |
| POST | /api/auth/register | Register new user |
| POST | /api/auth/login | Login and get token |
| POST | /api/auth/refresh | Refresh access token |
| GET | /api/users | List all users (protected) |
| GET | /api/users/:id | Get user by ID (protected) |
Available Scripts
| Command | Description |
| --------------- | ---------------------------------------- |
| bun run dev | Start development server with hot reload |
| bun run build | Build for production |
| bun run start | Run production build |
Configuration
Create a .env file:
PORT=3000
JWT_SECRET=your-jwt-secret
JWT_EXPIRES_IN=7dLearn More
License
MIT
