Skip to content

:atom: 🚀 (WORK IN PROGRESS) Blogfy: API - 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

Notifications You must be signed in to change notification settings

wilsonneto-dev/Blogfy_API

Repository files navigation

🚀 Blogfy CMS

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


Using:

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

Running in Dev Enviroment / Scripts

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


Migrations

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');
  }
}

Utils:

Generating a secret key:
node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"

About

:atom: 🚀 (WORK IN PROGRESS) Blogfy: API - 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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages