https://github.com/adonisjs/api-starter-kit
Starter kit for creating JSON API server using AdonisJS
https://github.com/adonisjs/api-starter-kit
Last synced: 8 months ago
JSON representation
Starter kit for creating JSON API server using AdonisJS
- Host: GitHub
- URL: https://github.com/adonisjs/api-starter-kit
- Owner: adonisjs
- Created: 2023-04-20T11:32:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-29T15:25:05.000Z (11 months ago)
- Last Synced: 2025-10-11T05:32:04.903Z (8 months ago)
- Language: TypeScript
- Size: 322 KB
- Stars: 10
- Watchers: 3
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AdonisJS API Starter Kit
This repo contains an AdonisJS application tailored for building an API server that responds with JSON.
## What's included
- TypeScript setup with commands to run developments server using `ts-node + swc` and create production build.
- ESLint and Prettier setup extending the [AdonisJS tooling config](https://github.com/adonisjs/tooling-config) presets.
- Ace command line framework.
- Everything else you get with the core of AdonisJS.
On top of the framework core and dev-tooling, the following features are enabled by the API starter kit.
- Lucid ORM ( Installed, but not configured )
- Auth module ( Installed, but not configured )
- CORS
- VineJS for validations
## Usage
You can create a new app using the `api` boilerplate by executing the following command. The command will perform the following steps.
- Clone the repo
- Install dependencies
- Copy `.env.example` to `.env`
- Set app key using `node ace generate:key` command.
- Configure `@adonisjs/lucid` package.
- Install and configure `@adonisjs/session` package (if using auth session guard).
- Configure `@adonisjs/auth` package.
```sh
npm init adonisjs -- -K=api
```
### Configuring Lucid database dialect
By default, the `npm init adonisjs` command configures Lucid to use `sqlite`. However, you can define a custom database dialect as follows.
```sh
npm init adonisjs -- -K=api --db=postgres
```
Available options for the `--db` flag.
- sqlite
- postgres
- mysql
- mssql
### Configuring Auth package guard
By default, the `npm init adonisjs` command configures the Auth package to use `session` guard. However, you can define a custom auth guard as follows.
```sh
npm init adonisjs -- -K=api --auth-guard=access_tokens
```
Available options for the `--auth-guard` flag.
- session
- basic_auth
- access_tokens