https://github.com/ilham-muttaqien17/boiler-fastify-typeorm
Boilerplate powered by Fastify, Typescript, & TypeORM
https://github.com/ilham-muttaqien17/boiler-fastify-typeorm
fastify postgres typeorm typescript
Last synced: 2 months ago
JSON representation
Boilerplate powered by Fastify, Typescript, & TypeORM
- Host: GitHub
- URL: https://github.com/ilham-muttaqien17/boiler-fastify-typeorm
- Owner: Ilham-muttaqien17
- Created: 2025-01-15T05:32:42.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-25T15:19:22.000Z (about 1 year ago)
- Last Synced: 2025-10-24T12:49:09.107Z (8 months ago)
- Topics: fastify, postgres, typeorm, typescript
- Language: TypeScript
- Homepage:
- Size: 357 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Boilerplate Fastify TypeORM
A boilerplate for building REST APIs using **Fastify**, **TypeORM**, and **TypeScript**.
## Table of Contents
- [Pre-requirements](#pre-requirements)
- [Installation](#installation)
- [Scripts](#scripts)
- [Usage](#usage)
## Pre-requirements
Before running this application, ensure you have the following installed and configured on your system:
1. **Redis**:
- Redis is used for caching or queue management.
- Installation guide: [Redis Official Documentation](https://redis.io/docs/getting-started/installation/)
2. **PostgreSQL**:
- The application uses PostgreSQL as the primary database.
- Installation guide: [PostgreSQL Official Documentation](https://www.postgresql.org/download/)
Ensure both services are running and accessible before proceeding with the installation steps.
## Installation
1. **Clone the repository**:
```bash
git clone https://github.com/Ilham-muttaqien17/boiler-fastify-typeorm
cd boiler-fastify-typeorm
```
2. **Install dependencies**:
```bash
npm install
```
3. **Environment Configuration**:
Copy the `config/.env.example` file to `config/.env` to configure your environment variables.
## Scripts
| Command | Description |
|---------------------------------------------------------------------------|-----------------------------------------------------------|
| `npm run prepare` | Sets up git hooks using `simple-git-hooks`. |
| `npm run typecheck` | Perform type checking on each TypeScript file. |
| `npm run dev` | Starts the app in development mode with TypeScript. |
| `npm run build` | Cleans the `dist` directory and compiles TypeScript files.|
| `npm start` | Starts the app in production mode with module aliasing. |
| `npm run lint` | Lints TypeScript files using ESLint. |
| `npm run commitlint` | Lints commit messages. |
| `npm run entity:create ./src/db/entities/.ts` | Creates a new TypeORM entity. |
| `npm run migration:create ./src/db/migrations/.ts` | Creates a new TypeORM migration file. |
| `npm run migration:generate ./src/db/migrations/.ts` | Generates a migration file based on schema changes. |
| `npm run migration:run` | Runs all pending TypeORM migrations. |
| `npm run migration:revert` | Reverts the last executed migration. |
| `npm run migration:show` | Displays the status of all migrations. |
| `npm run seed:create ./src/db/seeds/.ts` | Creates a new database seed file. |
| `npm run seed:run` | Executes all seed files to populate the database. |
| `npm run seed:revert` | Reverts the last seed operation. |
| `npm run db:create` | Creates the database specified in the configuration. |
| `npm run db:drop` | Drops the specified database. |
| `npm run db:refresh` | Drops and recreates the database. |
## Usage
### Database Setup
Before using the application, you need to create the database. This can be done using the following command:
```bash
npm run db:create
```
### Development Mode
To run the application in development mode, use the following command:
```bash
npm run dev
```
### Production Mode
To run the application in production mode, use the following command:
1. **Build the application**:
```bash
npm run build
```
2. **Start the application**:
```bash
npm run start
```
The app will be available at `http://localhost:3300` by default.