/ts-api

TS DDD API/REST

Primary LanguageTypeScriptMIT LicenseMIT

ts-api Version

Quality Gate Status

Quality report

Sonarcloud

Security Rating Maintainability Rating Reliability Rating

Vulnerabilities Bugs Code Smells Technical Debt

Lines of Code Duplicated Lines (%) Coverage

License

This project is licensed under the MIT License.

See LICENSE for details.

Changelog

CHANGELOG



Installation

Prerequisites

  • Node.js version >= 20.9.0
  • npm version >= 10.1.0

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

  1. Clone the repository:
git clone https://github.com/vinjatovix/ts-api.git
cd ts-api
  1. Install dependencies:
npm install

Usage

Please rename .env_example to .env And full-fill the variables if needed.

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 Persistence

  1. Starts the mongo db
npm run docker:mongo
  1. Provisioning the db Provisioning the local mongo with cloud $ENV data
npm run restoreDB $ENV 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



Api First

Please, update the openApi.yaml if you need to make critical changes related to your task/issues.

A nice postman collection is provided for you ready to work with in ./doc/postman/collection.

Remember to update and add it to your PR.

We are working to automate this doc with swagger

You can run newman against the provided postman collection. Just rename ENV.postman_environment.json_sample to local.postman_environment.json inside ./doc/postman/environments and full-fill the needed variables.

npm run newman:local

You can run the collection against the PRE deploy if you have the needed rights to do it

npm run newman

Note this only will work if the proper pre.postman_environment.json is set up

Testing

ATDD

We encourage ATDD flow in development phase. Cucumber and jest are ready to work in this repo.

  1. For acceptance tests
npm run test:features
  1. In development For unit tests
npm run test:unit
  1. Full tests routines
npm run test

Note this gathers full coverage info



Prepare release

This repository uses semver, $RELEASE_TYPE could be major, minor or patch.

npm run prepare-release $RELEASE_TYPE


Npm Scripts resume

  • build: Clean the previous build, transpile TypeScript, and copy necessary files to the dist directory.
  • check-dependencies: Check for circular dependencies in the source code using madge.
  • dev: Run the application in development mode using ts-node-dev.
  • docker:local: Build the Docker image and start the application using Docker Compose.
  • docker:mongo: Set up the local mongo docker.
  • newman: Runs the postman collection against the deployed build.
  • newman:local: Once you have your local env up you can check the postman collections with this script.
  • prepare-release: Accepts major, minor, patch. Updates release files, commit and push the new tag.
  • restoreDB: Requires an ENV and a password for restore in local mongo docker some cloud DB
  • restoreDump: Accepts an ENV for restore a previously dumped ENV db stores in the local mongo docker.
  • start: Start the transpiled build in the deployment server.
  • start:local: Start the transpiled application in the local environment.
  • test: Run both unit and feature tests.
  • test:features: Run feature tests using Cucumber.js.
  • test:unit: Run unit tests using Jest.


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.

Repository

https://github.com/vinjatovix/ts-api

Author

Vinjatovix



Dependencies

See package.json for a list of dependencies and their versions.

For more details, visit the project homepage.