Template setup for a separate backend app that may be hosted on a different node from the frontend app, so it is communicated with via an API.
-
Copy & rename directory
-
Do a find-replace of all files contained, replacing:
app-apiwith the name of the app
APP_APIwith the name of the app
BASE_URL=/app-apiwith the base URL from which the package will run
app_api_pgwith the name of the database
appApiPgGuestwith the name of the database userIf using REST: \
If using GraphQL:
app-frontent-urlwith the URL route(s) leading to the API. Also directory name underapollo-gql. Duplicate if more than one.
mountAppFrontendUrlGQLwith the camelCase of the url route(s) named above. If more than one, add additional imports inapp.ts -
Customize supporting files as desired.
-
Run
yarn install
This template is set up to streamline CI/CD procedures & DevOps. Fundamentaliy this means that most if not all command line interaction with the app should be by issuing commands to scripts defined in one file, depending on the level of engagement with the app.
When working locally, such as for running tests, issue package.json scripts using yarn, such as:
yarn build- Builds the project locallyyarn start-dev- Runs the project locally
When working with multiple apps, which includes this one, issue Makefile scripts at the top level in the overall project, such as:
make init- Initialize project from scratch, including database migrations, container image generation, running containers, etc.make clear_project- Tears down all built aspects of the project, including shutting down containers and removing images.
See the project root ReadMe for more information.
There are 3 types of tests run (unit, integration, acceptance), which are run in two different environments (default, and dev). Dev environments run tests from within a running container.
Unit and integration tests for a given file are located in a separate testing file at the same directory location as the tested file.
Acceptance tests are located in a dedicated directory at the root: /test/acceptance
Test files are designated by the following format: {fileTested}.[u|i|a]spec.ts.
Unit tests should mock any and all calls to database repos or calls to other services. Unit tests are typically designated by u.
Filename:
{fileTested}.spec.ts
Commands:
yarn test:u- Runs all unit tests directlyyarn test:u:dev- Runs all unit tests within a container environmentmake run_unit_tests- Runs all unit tests within a container environment
Any tests that may include limited calls to a database or service is an integration test. These require database migration and seeding test data before testing. Integration tests are typically designated by i.
Filename:
{fileTested}.ispec.ts
Commands:
yarn test:i- Runs all integration tests directlyyarn test:i:dev- Runs all integration tests within a container environmentmake run_integration_tests- Runs all integration tests within a container environment
Acceptance tests run on a more fully functional environment and test complex interactions and flow that align more with user stories rather than basic functionality. Acceptance tests are typically designated by a.
Filename:
{fileTested}.aspec.ts
Commands:
yarn test:a- Runs all acceptance tests directlyyarn test:a:dev- Runs all acceptance tests within a container environmentmake run_acceptance_tests- Runs all acceptance tests within a container environment
Postgres is the default database set up to be used.
Postgres is the default database set up to be used. Most of this implementation is pulled over from the Common package.
Mongo is another database option to be used. Most of this implementation is pulled over from the Common package.
The app is set up to be containerized using Docker. Images are built & managed by calling docker-compose at the project root.
Dockerfile- Default docker file for building the imageDockerfile.dev-
RabbitMQ is set up in the basic supporting files for easy hooks for further setup. It currently is not running.