Welcome! This repository is your starting point for creating modern APIs with Express, TypeScript, and a polished workflow thanks to Husky. Put on your helmet, because we're going to do awesome things. 🌐🔗
- Node.js >= 22.15.0
- yarn ≥ 4.9.1 (or npm ≥ 6)
- Willingness to learn cool stuff
-
Clone this repository
git clone git@gitlab.com:template-gagzu/api-express.git cd api-express.git -
Install dependencies
yarn install
-
Prepare Husky (runs only once when the repo is cloned for the first time)
yarn prepare
-
Start in development mode
yarn dev
All useful commands are ready in the package.json to automate your workflow:
| Script | Description |
|---|---|
build |
Compiles TypeScript (tsc). |
start |
Runs the compiled app (node dist/index.js). |
dev |
Starts the server in watch mode (tsx watch src/index.ts). |
lint |
Runs ESLint to check the code. |
lint:fix |
Runs ESLint and automatically fixes errors. |
format |
Applies Prettier to the entire project. |
doc |
Generates documentation with JSDoc (jsdoc -c jsdoc.json). |
migrate |
Runs migrations with TypeScript (tsx scripts/migrate.ts). |
typeorm |
TypeORM CLI (tsx ./node_modules/typeorm/cli.js). |
prepare |
Husky hook: installs Git hooks. |
test |
Runs all tests inside tests folder |
dev:docker |
Runs the backend inside a docker container |
-
Development:
yarn dev
Edit your code and see live changes.
-
Build and run:
yarn build yarn start
-
Verify linters before committing:
git add . && git commit -m "your message"
Thanks to Husky, ESLint and Prettier run automatically before the commit.
├─ src/
| |─ __tests__/ # Tests for controllers and middlewares
│ ├─ controllers/ # Controllers and business logic
│ ├─ database/ # Configuration, data access, entity and schema definitions
│ ├─ libs/ # Shared libraries and utilities
│ ├─ middlewares/ # Express middlewares for requests
│ ├─ routes/ # Express routers
│ ├─ typescript/ # Additional typings for external and internal libraries
│ └─ index.ts # Application entry point
├─ scripts/
│ └─ migrate.ts # Migration script
├─ .husky/ # Git hooks (Husky)
├─ package.json # Dependencies and scripts
└─ tsconfig.json # TypeScript configuration