A full-featured sample application demonstrating core AntelopeJS patterns: database models with decorators, JWT authentication, RESTful controllers, and automatic CRUD generation.
-
Install dependencies:
pnpm install
-
Start development mode:
pnpm run dev
Note: The
antelope.config.tsfile defines the required modules (API server, MongoDB, auth-jwt, etc.) and their configuration. Adjust connection strings and secrets before running.
src/
├── index.ts # Entry point — initializes the database schema
├── db/
│ ├── tables/ # Table definitions with decorators
│ │ ├── user.table.ts
│ │ └── task.table.ts
│ └── models/ # Data models with business logic
│ ├── user.model.ts
│ └── task.model.ts
├── routes/
│ └── auth.ts # Authentication controller
└── data-api/
└── tasks.ts # Auto-generated CRUD controller
antelope.config.ts # AntelopeJS project configuration
The User table uses the HashModifier mixin to automatically hash passwords via the @Hashed decorator. The Task table stores tasks linked to a user through a userId index.
UserModel and TaskModel extend BasicDataModel to provide typed access to the database. Each model adds custom query methods like getUserByEmail and getTasksByUserId.
The AuthController handles registration, login, and profile retrieval. Passwords are automatically hashed on insert and compared transparently on login. The SignRaw function generates JWT tokens, and the @Authentication decorator protects routes.
The TaskDataAPI controller extends DataController to generate CRUD endpoints automatically. All routes require authentication through a custom route definition that prepends the @Authentication decorator.
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Login and receive a JWT |
| GET | /auth/me |
Get the authenticated user |
All task endpoints require a valid JWT token.
| Method | Endpoint | Description |
|---|---|---|
| GET | /tasks |
List all tasks |
| GET | /tasks/:id |
Get a specific task |
| POST | /tasks |
Create a new task |
| PUT | /tasks/:id |
Update a task |
| DELETE | /tasks/:id |
Delete a task |
For a detailed walkthrough of this template, see the Full-Stack App Tutorial in the AntelopeJS documentation.