The Starter Kit offers tools and features tailored for efficient application development using Node.js. It aims to streamline the process, especially for MVPs and scalable applications.
- Modular Structure: Organized pattern for application development.
- Latest Node.js Capabilities: Utilize contemporary Node.js features without relying on Babel or TypeScript.
- Fastify Integration: Fast and efficient HTTP servers with asynchronous support.
- Drizzle-orm Integration: Simplified database connectivity and operations.
- Architectural Flexibility: Suitable for MVPs, with easy adaptability for future architectural shifts.
- Alternative to Nest.js: Offers core functionalities without additional complexities.
- Optimized Infrastructure: Prioritizes efficiency and performance.
- Clear Code Base: Organized structure for easier navigation and modification.
- Adaptable Components: Components designed for customization based on project requirements.
We assume that everyone who comes here is programmer with intermediate knowledge
and we also need to understand more before we begin in order to reduce the knowledge gap.
- Understand Fastify Fundamental, Main Framework. Fast and low overhead web framework, for Node.js
- Understand Express Fundamental, NodeJs Base Framework. Since the project is based on fastify, which is trying to solve problems specifically express
- Understand The YAGNI Principle and KISS Principle for better write the code.
- Optional. UnderstandTypescript Fundamental, Programming Language. It will help to write us contacts of types
- Optional. Understanding The Twelve Factor Apps. It can help to serve the project.
- Optional. Understanding Docker. It can help to run the project.
Name | Version |
---|---|
Node | v20.11.x |
Typescript | v5.4.x |
PostgreSQL | v15.0.x |
Yarn | v1.22.x |
NPM | v8.19.x |
Docker | v18.10.x |
Docker Compose | v1.23.x |
Before start, we need to install some packages and tools. The recommended version is the LTS version for every tool and package.
Make sure to check that the tools have been installed successfully.
- Clone the project with git.
git clone https://github.com/256Taras/fastify-drizzle-orm-starter-kit
Optional: Use nvm use
command which automatically will setup node
of specified version in .nvmrc
file.
- This project needs some dependencies. Let's go install it.
yarn install
- Create
.environment
file inconfigs
folder. Use.environment.example
as example..environment.example
has already fully functional settings, so server can be started with it without changes
cp .environment.example .environment
- Run migrations
yarn typeorm:migration:run
- Run infrastructure in docker (db, etc.):
yarn docker:infra:up
- Run server on local machine without docker:
yarn start
Finally, Cheers 🍻🍻 !!! you passed all steps.
You can check The ApiSpec after running this project. here
- Run infrastructure in docker (db, etc.):
yarn docker:infra:up
- split by modules (scalability & better dev experience)
- store as much as can boilerplate code in shared
- has additional layers for easy cognitive perception:
- handlers
- services
- scopes (extracted from infra)
Prefer to use Git Flow process.
Commit culture is based on this article, here are seven simple rules:
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
Commit Convention is described in this article, here are seven simple rules:
- Each commit message consists of a header, a body, and a footer.
<header>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
- The header is mandatory and must conform to the Commit Message Header format.
- The body is mandatory for all commits except for those of type "docs". When the body is present it must be at least 20 characters long and must conform to the Commit Message Body format.
- The footer is optional. The Commit Message Footer format describes what the footer is used for and the structure it must have.
- Commit Message Header
<type>(<scope>): <short summary>
│ │ │
│ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│ │
│ └─⫸ Commit Scope: common|core|account-crud|migrations
│
└─⫸ Commit Type: build|docs|feat|fix|refactor|test
The and
-
Type
Must be one of the following:
- build: Changes that affect the build system or external dependencies (example scopes: npm, infra)
- docs: Documentation only changes
- feat: A new feature
- fix: A bug fix
- refactor: A code change that neither fixes a bug nor adds a feature
- test: Adding missing tests or correcting existing tests
-
Scope
Usually the scope should be the name of task.
- none/empty string: useful for test and refactor changes that are done across all packages (e.g.
test: add missing unit tests
) and for docs changes that are not related to a specific package (e.g.docs: fix typo in tutorial
).
-
Summary
Use the summary field to provide a succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end
-
Commit Message Body
Use the body to explain what and why vs. how
-
Commit Message Footer
The footer can contain information about breaking changes and deprecations and is also the place to reference GitHub issues, Jira tickets, and other PRs that this commit closes or is related to.
- production ready
- automatic loading of modules and plugins
- validate environment:
- main script: initialize infra for proper server start, start server, add server stop handlers
- graceful shutdown
- configs: separate folder, split by files, setup using process environment
- fastify application server
- auto documentation: fastify-swagger. *Require fastify input & output schemas
- routers with input/output validation
- separate router handler
- logger powered by 'pino'
- console interface
- log levels
- trace ID
- loggerService service implementation with LOG_LEVELs: wrapped pino into console.log interface
- containerize in docker server and all 3rd parties if possible:
- server
- db (postgres)
- DI: At the file system level
- TDD: node:test or tap, DI, unit-tests, e2e
- [N-layer architecture] (#architecture-description-&-maintain-instructions)
- [] db:
- drizzle-orm
- postgres-js
- separate loggerService for db logging
- cursor pagination
- local code style support:
- esLint setup
- prettier setup
- editorconfig
- optional: words spelling checker (VScode plugin)
- [] built-in Auth:
- bearer token (JWT) (Manually)
- [] API_KEY (Manually)
- permissions checks:
- rate limiting (https://www.npmjs.com/package/fastify-rate-limit)
- global rate limit
- rate limit per route
- request timeouts (implement manually)
- request-scoped storage support, based on Asynchronous Local Storage to receive data without mutation request
- templates rendering support
- ability to run CPU intensive tasks in the Piscina worker pool
- covering utilities with .d.ts files
- support Docker installation