Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

227 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agro-back Version

Quality report

Sonarcloud

Quality Gate Status

Security Rating

Coverage

Architecture TL;DR

  • Express (layered architecture)
  • Domain-driven design (light, bounded contexts)
  • Awilix DI container per request scope
  • OpenAPI-driven contract validation
  • MongoDB persistence layer
  • Jest + Cucumber testing pyramid (unit / feature / contract)

Installation

Prerequisites

  • Node.js version = 24.x (>= 24.22.1)
  • npm version >= 10.1.0

A .tool-versions file is provided to easily work with asdf

  • Clone the repository:
git clone https://github.com/vinjatovix/agro-back.git
cd agro-back
  • Install dependencies:
npm install

Usage

Please rename .env_example to .env And fill in the variables.

Run in dev mode

Run the development server:

npm run dev

Run the build

You can build and run it locally with:

npm run start:local

Or just with:

npm run docker:local

Setup Local Persistence

  • Starts the mongo db
npm run docker:mongo
  • Provisioning the db Provisioning the local mongo with cloud $ENV data
npm run restoreDB <env> <database> <user> <password>
  • Or restore previous dumped data.
npm run restoreDump $ENV

Note this will only work if previous data for such $ENV was dumped and restored before


Testing Strategy

  • Unit tests → domain logic (pure)

  • Feature tests → HTTP API (controllers + flow)

  • Contract tests → OpenAPI schema validation

  • Acceptance tests

npm run test:features
  • Unit tests
npm run test:unit        # both groups in parallel, with coverage
npm run test:unit:nodb   # tests that need no database (Mongo can be stopped)
npm run test:unit:db     # *.db.test.ts files, against the Docker MongoDB
npm run test:unit:leaks  # slow diagnostic: shows where a leaked timer/socket was opened

A test file opens a real Mongo connection if and only if it is named *.db.test.ts. A file that leaves timers, sockets or servers open fails with a pointer to npm run test:unit:leaks. Application logs are silent in tests and log files are never written; run any test command with TEST_LOGS=1 to print them.

Repository tests run against the Docker MongoDB. Jest workers run in parallel and each one gets its own database (test-1, test-2…, see tests/shared/infrastructure/persistence/mongo/testDBConfig.ts); docker/mongo/mongo-init.js lets the test user write to test-1…test-16. A container created before this rule needs the grant once:

docker exec agro-api-mongo mongosh -u root -p rootPassword --quiet --eval 'db.getSiblingDB("test").grantRolesToUser("localUser", Array.from({length:16},(_,i)=>({role:"readWrite",db:"test-"+(i+1)})))'
  • Full tests routines
npm run test

Contributing

Feel free to contribute to this project but keep in mind the guidelines in CONTRIBUTING.md

Open an issue or create a pull request.

Bugs and Issues

Please report bugs, issues or Report a vulnerability at GitHub Issues.

License

This project is licensed under the MIT License.

See LICENSE for details.

Changelog

CHANGELOG

Repository

https://github.com/vinjatovix/agro-back

Author

Vinjatovix

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages