A simple and ready-to-use Blog CMS for people who just want to write articles without worrying about tech stuff!
Watch the project development live on twitch: twitch.tv/wilsonnetodev
- TypeORM
- We need a good ORM to deal with persistence stuff
- Clean Architecture
- Using a modular DDD approach with Clean Architecture
- Celebrate and JOI
- Libs for validatint inputs from clients
- Express
- The API framework
- Bcryptjs
- Lib to deal with criptography stuff
- jsonwebtoken
- Lib to deal with JWT tokens
- Jest
- Using jest for the unity tests
- Tsyringe
- Dependency Injection library
- Supertest
- Using supertest for integrations tests
- Typescript
- For typing the JS
- Eslint and Prettier
- Used to guarantee code standards
First of all, you will need to install the dependencies:
npm install
Running the app:
npm run dev
Running the tests:
npm run test
Running the tests on watch mode:
npm run test:watch
Running the integration tests:
npm run test:integration
Running the Postgres in a container:
docker run --name my_container_postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
docker run -d --name blogfy-database -p 5432:5432 -e POSTGRES_PASSWORD=blogfy123 -e POSTGRES_USER=blogfy -e POSTGRES_DB=blogfy postgres
Running a TypeORM migrations:
npm run typeorm migration:run
Reverting a TypeORM migrations:
npm run typeorm migration:revert
Creating a TypeORM migration:
npm run typeorm -- migration:create --name CreateUsers --dir ./src/modules/identity/infra/data/typeorm/migrations
TypeORM Migration example:
/* eslint-disable class-methods-use-this */
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
export default class CreateAppointments1600772700374
implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'appointments',
columns: [
{
name: 'id',
type: 'varchar',
isPrimary: true,
generationStrategy: 'uuid',
},
{
name: 'provider',
type: 'varchar',
isNullable: false,
},
{
name: 'date',
type: 'timestamp with time zone',
isNullable: false,
},
],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('appointments');
}
}
Generating a secret key:
node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"