Node.js best practices (80,500 stars)
Generate a Node.js app that is packed with best practices AND simplicity in mind. Based off our repo Discord discussions |
Twitter |
Documentation site
A One Paragraph Overview
Although Node.js has great frameworks
1 min video
Table of Contents
Super-Quick Setup
Our Philosophies and Unique Values
Practices and Features
The People Behind Practica.js
Our best practices guide, 78,000 stars ✨
Contribution guide
Documentation site
YouTube
- Coming Soon:
- Example Applications
- Express, PostgreSQL, with common best practices
- Express, mongo-db, with common best practices
- Express, PostgreSQL, with all best practices (advanced)
- Minimal with project setup configuration only
More Flavours
- Fastify, PostgreSQL - Fastify, mongo-db - Generate Your Own Interactively - More coming soon
- Example Applications
Super-Quick Setup
Run Practica.js from the Command Line
Run practica CLI and generate our default app (you can customize it using different flags):
npx @practica/create-node-app immediate --install-dependencies
We also have a CLI interactive mode:
npx @practica/create-node-app interactive
Note that for now, it can generate an app that is based on Express and PostgreSQL only. Other options will get added soon
Start the Project
cd {your chosen folder name}
npm install
Then choose whether to start the app:
npm run
or run the tests:
npm test
Pretty straight forward, right?
You just got a Node.js Monorepo solution with one example component/Microservice and multiple libraries. Based on this hardened solution you can build a robust application. The example component/Microservice is located under: {your chosen folder name}/services/order-service. This is where you'll find the API and a good spot to start your journey from.
Next Steps
✅ Start coding. The code we generate is minimal by design and based on known libraries. This should help you get up to speed quickly.✅ Read our 'coding with practica' guide✅ Master it by reading our docs at https://practica.dev.
Our Philosophies and Unique Values
1. Best Practices on top of known Node.js frameworks
We don't re-invent the wheel. Rather, we use your favorite framework and empower it with structure and real examples. With a single command you can get an Express/Fastify-based codebase with ~100 examples of best practices inside.
2. Simplicity, how Node.js was intended
Keeping it simple, flat, and based on native Node/JS capabilities is part of this project's DNA. We believe that too many abstractions, high-complexity or fancy language features can quickly become a stumbling block for the team.
To name a few examples, our code flow is flat with almost no level of indirection, although using TypeScript - almost no features are being used besides types, for modularization we simply use Node.js modules.
3. Supports many technologies and frameworks
Good Practices and Simplicity is the name of the game with Practica. There is no need to narrow our code to a specific framework or database. We aim to support a majority of popular Node.js frameworks and databases.
Practices and Features
We apply more than 100 practices and optimizations. You can opt in or out for most of these features using option flags on our CLI. The following table lists just a few examples out of the full list of features we provide.
Feature | Explanation | Flag | Docs |
---|---|---|---|
Monorepo setup | Generates two components (e.g., Microservices) in a single repository with interactions between the two | --mr, --monorepo | Docs here |
Output escaping and sanitizing | Clean-out outgoing responses from potential HTML security risks like XSS | --oe, --output-escape | Docs here |
Integration (component) testing | Generates full-blown component/integration tests setup including DB | --t, --tests | Docs here |
Unique request ID (Correlation ID) | Generates module that creates a unique correlation/request ID for every incoming request. This is available for any other object during the request life-span. Internally it uses Node's built-in AsyncLocalStorage | --coi, --correlation-id | Docs here |
Dockerfile | Generates dockerfile that embodies >20 best practices | --df, --docker-file | Docs here |
Strong-schema configuration | A configuration module that dynamically load run-time configuration keys and includes a strong schema so it can fail fast | Built-in with basic app | Docs here |
The People Behind Practica.js
Steering Committee
Practica is a community-driven open-source project. It's being led voluntarily by engineers from many different companies. These companies are just a few who encourage their engineers to contribute and keep this project moving.
A Nasdaq 100 company, a world leader in design software
Leader IoT provider, part of 'Cox Communication', the 3rd largest cable company in the US
Core Team
Partners
These companies are keen for continuous improvement and their engineers to have been known to contribute during work hours.
💚
Our Amazing Contributors A million thanks to these great people who have contributed code to our project: