Node.js best practices (77,000 stars)
Generate a Node.js app that is packed with best practices AND simplicty in mind. Based on our repoβ£οΈ Alpha stage: It's a very premature work-in-progress, we're only kicking-off now, please revisit by June 2022π
What in here for you in one paragraph
Node.js has great frameworks π, they never meant to be production ready - Practica.js bridges this gap. Based on your preferred framework, we generate a small code that demonstrates a full flow, from API to DB, that is packed with good practices. For example, we incude a hardened dockerfile, N-Tier folder structure, great testing templates, and more. This can save a great deal of time and painful mistakes. All our decisions are being made, thoughtfully and neatly documented, we strive to keep things as simple and standard as possible and base our work on the popular guide 'Node.js best practices'
Table of contents
-
Example applications (place holder, not ready yet)
- Express, Postgresql, with common best practices
- Express, Mongodb, with common best practices
- Express, Postgresql, with all best practices (advanced)
- Minimal with project setup configuration only
More flavours
-
[soon] fastify, postgresql
-
[soon] fastify, mongo
-
More coming soon
A very quick start
π Alpha project: This project is very premature WIP, please revisit by June 2022
Run this command from terminal
Interactive mode with UI:
npx @practica/create-node-app interactive
Or a typical terminal command using flags (without UI):
npx @practica/create-node-app immediate
β¨ That's it, the code was generated for you
Start the project
npm start
or
npm test
Standard, ah?
Enjoy
- β Start coding. The code is short by design and you should get up to speed quick
- β Understand the project structure by watch this 5 min YouTube (coming soon) πΉ
- β Optional: Skim through the code, all the best practices are tagged inside the code
- β Master it by visiting our documentation website (coming soon)
60-sec-explainer.mp4
Our philosophy and unique value
1. Best practices on top of known Node.js frameworks
We don't invent new wheels rather use your favorite framework and empower it with more structure and practices. For example, with a single command you get express/fastify based code base with ~100 additional best practices inside
2. SIMPLE like Node.js was meant to be
Keeping it simple, flat and based on native Node/JS capabilities is part of this project DNA. We believe that too many abstractions, high-complexity and fancy language features become soon a strategic slowdown for the team. To name a few example, 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
Since it's about good practices and simplicity, there is no need to narrow this code to specific framework or DB. We aim to support the major 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 our CLI flags. Following is few examples of features, to learn about the full list of features, please visit here
Feature | Explanation | Flag | Documentation link |
---|---|---|---|
Monorepo setup | Generates two components (e.g., Microservices) in a single repository with interactions between the two | --monorepo, --mr | Docs here |
Output escaping and sanitizing | Clean-out outgoing responses from potential HTML security risks like XSS | --output-escape, --oe | Docs here |
Integration (component) testing | Generates full-blown component/integration tests setup including DB | --tests, --t | 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 | --correlation-id, --coi | Docs here |
Dockerfile | Generates dockerfile that embodies 20> best practices | --docker-file, --df | 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 |
π Full features list - 100+ more
The people behind this project
Steering committee
Practica is a community-driven open-source project. It's being led voluntarily by engineers from many companies. On top of this, these companies below which are keen to great engineeting practices chose to let their engineers contribute massively and push this project firmly π
A Nasdaq 100 company, world-leader in design software
Leader IoT provider, part of 'Cox Communication', 3rd largest US cable company
Core team
Let's put our pictures here really soon
Partners
These companies are keen for continous improvements and encouraging their engineers to contribute during work hours
Amazing contributors π
Million thanks to these great people who contributed code:
Brian Clark π» |
Raz Luvaton π |
Michael Solomon π» |
itainoam π» |
shanizlo π» |
Ron Dahan π» |
AlonK π» |
Jose Luis Alvarez Herrera π |