Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AntelopeJS Todo App Template

License Discord

A full-featured sample application demonstrating core AntelopeJS patterns: database models with decorators, JWT authentication, RESTful controllers, and automatic CRUD generation.

Quick start

  1. Install dependencies:

    pnpm install
  2. Start development mode:

    pnpm run dev

Note: The antelope.config.ts file defines the required modules (API server, MongoDB, auth-jwt, etc.) and their configuration. Adjust connection strings and secrets before running.

Application structure

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

Included components

Database tables

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.

Data models

UserModel and TaskModel extend BasicDataModel to provide typed access to the database. Each model adds custom query methods like getUserByEmail and getTasksByUserId.

Authentication

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.

Task management API

The TaskDataAPI controller extends DataController to generate CRUD endpoints automatically. All routes require authentication through a custom route definition that prepends the @Authentication decorator.

API endpoints

Authentication

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

Task management

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

Learn more

For a detailed walkthrough of this template, see the Full-Stack App Tutorial in the AntelopeJS documentation.

About

Sample typescript template for AntelopeJS module.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages