SB Clean Blog Node is an open-source Node.js backend boilerplate for a blog application, built with TypeScript, Fastify, and TypeORM, that pairs with the Angular-based SB Clean Blog frontend.
What is SB Clean Blog Node?
It is the backend API for the SB Clean Blog starter from StartBootstrap. It takes database connection settings and a JWT secret from an environment file and produces a REST API that serves blog posts, runs database migrations, and seeds sample data. The project runs on Node.js and uses Postgres as the default database, with TypeORM as the ORM layer. It is distributed as open source and includes a Dockerfile for containerized deployment.
What makes SB Clean Blog Node stand out?
- TypeScript-first backend: The entire server is written in TypeScript, with separate tsconfig files for the app and test specs.
- Fastify web framework: The HTTP layer is built on Fastify and exposes a REST API with a health check at /api/latest/health.
- TypeORM with Postgres support: Database access goes through TypeORM, and while Postgres is the default, TypeORM can connect to most major databases.
- Database migrations: npm scripts wrap the TypeORM CLI for generating and running migrations.
- Database reset and seed: The db:reset script drops and recreates the database, runs migrations, creates a root user, and seeds it with random posts.
- Docker support: A Dockerfile and scripts are included to build and run the API in a container, with the README noting that production use requires pointing to a production Postgres instance.
- Unit tests: Tests are named .test.ts and sit alongside the source, runnable with npm, plus a watch mode and a coverage server.
- Linting and formatting: Lint and lint:fix scripts are provided, along with a check to detect conflicts between tslint rules and prettier.
Who is it for?
- Backend developers: Build a blog API quickly and customize post endpoints, authentication via JWT, and data models on a TypeScript foundation.
- Full-stack teams: Pair this backend with the sb-clean-blog-angular frontend to run a complete blog site with posts served from a real database.
- Developers learning TypeORM: Use the migration, seed, and configuration patterns as a reference for structuring a TypeORM project with Postgres.
What can you do with SB Clean Blog Node?
- Full-stack blog setup: Clone both this backend and the Angular frontend, run the db:reset command, and get a working blog with seeded posts.
- Containerized API deployment: Build a Docker image with npm run docker:build and run it with npm run docker:run, adjusting environment variables in the run script for production.
- Database experimentation: Swap the database by changing TypeORM connection options, keeping in mind that the provided db scripts are only tested against Postgres.
How does SB Clean Blog Node work?
After cloning the repo, copy .env.sample to .env and fill in the database passwords, postgres user, and a JWT secret. Then run npm install, npm run db:reset to initialize the database, and npm start to launch the server on port 8200. The health endpoint http://localhost:8200/api/latest/health confirms the server is running.
Pros and cons
- Pros: Open source, built with modern TypeScript tooling, includes tests and Docker support, and the db:reset script simplifies initial setup.
- Cons: Requires a local Postgres instance, and the db scripts are only tested against Postgres; you may need to run npm run db:uuid if the uuid-ossp extension is missing.
Pricing
SB Clean Blog Node is open source and free to use.
FAQ
Is SB Clean Blog Node free?
Yes, it is an open source project, so the source code is available freely for personal and commercial use under the license specified in the repository.
What database does SB Clean Blog Node use?
The default and recommended database is Postgres. TypeORM supports most major databases, so switching is possible, but the included database scripts at scripts/db/ are only tested with Postgres.
How do I run the tests?
Run npm run test to execute the unit tests, which are colocated as .test.ts files. For continuous testing, use npm run test:watch, and to view coverage, run npm run serve:coverage.
How do I set up the environment variables?
Copy .env.sample to .env and update DB_ROOT_USER_PASSWORD, TYPE_ORM_USERNAME, TYPE_ORM_PASSWORD, and JWT_SECRET. These values are used for database creation, TypeORM connections, and JWT signing.





