1.3.2 • Published 2 years ago

autoapprove.titles v1.3.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
2 years ago

Titles Engine Server

This repository is the server for the titles engine. It uses the Approve Engine (AE) API and title vendor API (currently WKLS) to create and update leads in AE.

Setup

  1. Make sure you have node and yarn installed. Install the version of node that this project uses (the version can be found in package.json). Installing NVM is described below.
  2. Clone the repository.
  3. Get access to the Auto Approve 1Password vault.
  4. Pull the .env file (sample .env file for local dev) down from the vault. Place the file in the root of this repository.
  5. Run yarn install to download node modules.

Database Setup

  1. You will need Docker Compose. If you're using a Mac or Windows, you can download Docker Desktop, which also installs Docker Compose.
  2. Run docker-compose up from the root of this repository. This will use the Dockerfile and docker-compose.yml file to create a few images and a container. The container will contain the postgreSQL DB.
  3. Run prisma migrate dev in a new terminal to create the titles-engine database within the postgres server and apply migrations to the database. If it cannot find prisma, you may need to install it globally (npm install -g prisma).

Note: You can run docker-compose up -d to run it in the background. To stop it, you'll need to run docker-compose down.

Running Tests

You can run tests by simply typing yarn test in a terminal at the root of this repository.

You can use the TestNamePattern flag if you'd like to run an individual test.

If you look at individual test files, you'll see that there is a comment block at the top of each one of them that defines groups. You can run groups of tests by following the documentation here.

Node Versions

You may find that you have a different node version installed than what this project requires. You can use Node Version Manager to install and switch between different node versions. You can see the version of node being used in the package.json.

Semantic Versioning & Commit Naming Convention

Our commit message format is as follows:

Tag: Short description (fixes #1234)

Longer description here if necessary

The first line of the commit message (the summary) must have that specific format. This format is checked by semantic-release.

The Tag is one of the following:

  • Fix - for a bug fix.
  • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
  • New - implemented a new feature.
  • Breaking - for a backwards-incompatible enhancement or feature.
  • Docs - changes to documentation only.
  • Build - changes to build process only.
  • Upgrade - for a dependency upgrade.
  • Chore - for refactoring, adding tests, etc. (anything that isn't user-facing).

Learn more about how versioning changes by Tag here: https://github.com/semantic-release/commit-analyzer/blob/master/lib/default-release-rules.js

Deploying Container Locally

Create docker.env File

The .env file stored in 1Password had double-quotes around each value. Docker does not like this so we create a new .env file specifically for local docker containers.

  1. Copy your .env file and make a new file called docker.env.
  2. Delete all the double quotes in docker.env.
  3. In the database URL variable, update localhost to host.docker.internal. Your variable should look something like this - DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/dev-titles-engine?schema=public. Note that we should be able to specify the DB container name instead of host.docker.internal, however we found that did not work. You can read more about this issue here.

Build Docker Container

docker build -t test-image-name . --no-cache --progress=plain

Run Docker Container

docker run --env-file docker.env -it -p 3000:3000 test-image-name

Troubleshooting Local Docker Containers

Output During Docker Build

If you add echo or output commands like run ls, by default the output will not show up in the terminal. You need to add --progress=plain for output to show up. See this page for more information.

Looking at Docker Image Files

You can look at the container that docker build outputs by running the following command.

docker build -o out .

This outputs the image to a directory named out in the current directory. You can find more information here.

Postman

You can download postman and in the root of this repository there is a postman folder that contains collections for calling the titles engine API. Make sure to set the environment you're using to TE Local if you're testing locally.

Technologies Used

Getting familiar with these technologies will help you understand what this repository is doing.