This repository is intended to serve as a starting point if you want to bootstrap a more complexTypeScript project.
- No proper DI framework/container/tool (just simple DI via constructor injection)
- Logging tied to the framework (Fastify)
- Ready for events, but not yet implemented
If these issues don't matter for your intended use, or you know how to fix them, this will be a fast way to run a quick script or program. If you're looking for a simpler setup, check out my TypeScript API Template or my TypeScript Simple Setup
It is opinionated, but easily adaptable to your needs and preferences. Check out below for more details.
- Pure DI. If you prefer using containers, check out:
- tsyringe
- typescript-ioc
- TypeDI
- NestJS
- InversifyJS
- Awilix
- If you prefer mocking dependencies (no DI) use proxyquire
- TypeScript
- pnpm for package management
- Biome for formatting and linting.
- Node Test Runner for testing.
- Fastify for the server with multiple plugins:
- cors
- helmet
- rate-limit
- sensible
- type-provider-typebox
- swagger - Commented
- swagger-ui - Commented
- GitHub Action workflows set up to run build, tests and formatting (with an automatic commit) on push.
You'll need to duplicate the .env.example
file and rename it to .env
and to .env.test
first.
Action | Command | Description |
---|---|---|
Install dependencies | pnpm i |
Installs the necessary dependencies |
Compile | pnpm build |
Transpiles TS into JS |
Run | pnpm start |
Runs the compiled JS |
Dev | pnpm dev |
Runs the TypeScript code and watches for changes |
Action | Command | Description |
---|---|---|
Test | pnpm test |
Runs all the tests |
Action | Command | Description |
---|---|---|
Format | pnpm format |
Ensures code follows style guides |
Lint | pnpm lint |
Runs the linter and points out mistakes |