harvtech-platform-api

The API to manage communication between other services in HarvTech.

CC0-1.0 License

Stars
0
Committers
2

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.
  • Run OWASP ZAP test.

Thanks for read

Product made by Tech Warriors.

Related Projects