Skip to content

tech-warriors-corporation/harvtech-platform-api

Repository files navigation

HarvTech logo

HarvTech (API platform)

The API to manage communication between other services in HarvTech.

Code style is Prettier GitHub license GitHub repository size


Install prerequisites

  1. NodeJS and NPM.
  2. Yarn.

Setup project

Follow all commands bellow.

Environment

Create .env file in root folder with content.

WEB_URL=<set Web URL πŸ”‘>
AI_URL=<set AI URL πŸ”‘>
JWT_SECRET=<set JWT secret πŸ”‘>
JWT_EXPIRES=<set JWT expires πŸ”‘>
AZURE_ACCOUNT_NAME=<set Azure account name πŸ”‘>
AZURE_ACCOUNT_KEY=<set Azure account key πŸ”‘>
AZURE_STORAGE_CONTAINER_URL=<set storage container URL πŸ”‘>
DB_HOST=<set database host πŸ”‘>
DB_DOCKER_PORT=<set Docker database port πŸ”‘>
DB_PORT=<set database port πŸ”‘>
DB_NAME=<set database name πŸ”‘>
DB_USERNAME=<set database username πŸ”‘>
DB_PASSWORD=<set database password πŸ”‘>
CRYPTO_ALGORITHM=<set crypto algorithm πŸ”‘>
CRYPTO_KEY=<set crypto key πŸ”‘>
CRYPTO_IV=<set crypto IV πŸ”‘>
PORT=<set port πŸ”‘>
MODE=<set mode πŸ”‘>

Install packages

yarn

Active Husky hooks (if not automatically configured)

yarn prepare

Database in Docker

yarn db

Development

yarn dev

Production

yarn prod:build && yarn prod:start

Tests

Our tests are made with Jest. Use *.test.ts for integration tests and *.spec.ts for unit tests. Run the commands below.

Default

yarn test 

Watch

yarn test:watch

Quiet

yarn test:quiet

Coverage

yarn test:coverage

Migrations (TypeORM):

In this project we use TypeORM for migrations. Run the commands below.

Run

yarn migration:run

Generate

yarn migration:generate src/migrations/<name>

Synchronize

yarn schema:sync

Setup JetBrains (IDE)

Configure Lint

Go to File > Settings > Languages & Frameworks > JavaScript > Code Quality Tools > ESLint, select Automatic ESLint configuration and check Run eslint --fix on save, or read the ESLint documentation for WebStorm.

Configure Prettier

Go to File > Settings > Languages & Frameworks > JavaScript > Prettier, check On 'Reformat Code' action and check On save, or read the Prettier documentation for WebStorm.

Lint

Run commands:

Check

yarn lint

Fix

yarn lint:fix

Prettier

Run commands:

Check

yarn prettier

Fix

yarn prettier:fix

Format code

yarn format

File patterns

You should be very specific in file names.

Roadmap

  • Add Axios.
  • Add Jest.
  • Study about Azure SDK for JS.
  • Review code in review directory.
  • Config project.
  • Add coverage code.
  • Review project.
  • Storage in Danilo's Azure.
  • Add CORS and test it.
  • Add PostgreSQL.
  • Use Crypto from NodeJS with algorithm AES-256-CTR.
  • Add JWT to authenticate requests.
  • Use an ORM for PostgreSQL.
  • Add a logger.
  • Protect passwords with a pattern with numbers, chars and symbols, use minlength too.
  • Add test in CI/CD.
  • Add environment variables in Cloud.
  • Protect routes with token.
  • UUID to avoid sequential ids.
  • Render or Neon for PostgreSQL.
  • Remove TODO comments.
  • Coverage badge in this README.md.
  • Study about TypeORM.
  • Add header with secret key for validate request to AI.
  • Make the code more agnostic of framework, library and other tools.
  • Validate our requests with access token.
  • Protect routes with account types.
  • Create SanitizeHelper for entries.
  • Maybe use Bcrypt.
  • Add health check.
  • Verify user quantities and cultive quantities by account plan.

Thanks for read

Product made by Tech Warriors.