# Appointment Service [![Build Status](https://jenkins.audibene.net/buildStatus/icon?job=Audibene-GMBH%2Fta-appointment-service%2Fdevelop&style=plastic)](https://jenkins.audibene.net/job/Audibene-GMBH/job/ta-appointment-service/job/develop/) ๐Ÿ“… &nbsp;A service for creating and updating appointments ## Requirements - [Docker](https://docs.docker.com/get-docker/) - [docker-compose](https://docs.docker.com/compose/install/) - [Node v14.4.0](https://nodejs.org/en/download/current/) - [nvm](https://github.com/nvm-sh/nvm) is recommend ## โœจ Getting Started ### โš™๏ธ The Environment File ```bash # Copy .env.example and update contents accordingly cp -n .env.example .env ``` <details> <summary>View Environment Variables</summary> <table> <thead> <tr> <th>Name</th> <th>Description</th> <th>Default</th> </tr> </thead> <tbody> <tr> <td><code>APP_ENV</code></td> <td>The environment the service assumes at runtime</td> <td><code>development</code></td> </tr> <tr> <td><code>APP_HOST</code></td> <td>The hostname of the service at runtime (used in tests)</td> <td><code>localhost</code></td> </tr> <tr> <td><code>APP_PORT</code></td> <td>The port of the service runs on</td> <td><code>3000</code></td> </tr> <tr> <td><code>APP_SECRET</code></td> <td>The secret used to encrypt/decrypt calendar integration credentials. Must be 32 characters in length.</td> <td>-</td> </tr> <tr> <td><code>AUTH0_URL</code></td> <td>The domain that is used to validate Auth0 tokens</td> <td>-</td> </tr> <tr> <td><code>CORE_AUTH_URL</code></td> <td>The domain that is used to validate CoreAuth tokens</td> <td>-</td> </tr> <tr> <td><code>NEW_RELIC_APP_NAME</code></td> <td>The application name as it appears in New Relic</td> <td>-</td> </tr> <tr> <td><code>NEW_RELIC_KEY</code></td> <td>Secret key for New Relic</td> <td>-</td> </tr> <tr> <td><code>NODE_ENV</code></td> <td>The node environment of the service at runtime</td> <td><code>development</code></td> </tr> <tr> <td><code>OUTLOOK_APP_CLIENT_ID</code></td> <td>The client id of the custom app registered with Microsoft&#39;s OpenGraph api</td> <td>-</td> </tr> <tr> <td><code>OUTLOOK_APP_CLIENT_SECRET</code></td> <td>The client secret of the custom app registered with Microsoft&#39;s OpenGraph api</td> <td>-</td> </tr> <tr> <td><code>OUTLOOK_APP_TENANT</code></td> <td>The tenant of the custom app registered with Microsoft&#39;s OpenGraph api</td> <td>-</td> </tr> <tr> <td><code>PORTAL_URL</code></td> <td>The base url of the Partner Portal</td> <td>-</td> </tr> <tr> <td><code>PULSAR_APPOINTMENT_DOMAIN_EVENTS_TOPIC</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>PULSAR_APPOINTMENT_TOPIC</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>PULSAR_CONTACT_TOPIC</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>PULSAR_CUSTOMER_TOPIC</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>PULSAR_ENDPOINT</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>PULSAR_SECRET_NAME</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>PULSAR_SHOP_TOPIC</code></td> <td>???</td> <td>-</td> </tr> <tr> <td><code>RDS_DBNAME</code></td> <td>The database name</td> <td><code>ta-appointment-service</code></td> </tr> <tr> <td><code>RDS_HOST</code></td> <td>The database host</td> <td><code>localhost</code></td> </tr> <tr> <td><code>RDS_PASSWORD</code></td> <td>The database password</td> <td><code>password</code></td> </tr> <tr> <td><code>RDS_PORT</code></td> <td>The database port</td> <td><code>5432</code></td> </tr> <tr> <td><code>RDS_USER</code></td> <td>The database user name</td> <td><code>user</code></td> </tr> <tr> <td><code>SYCLE_URL</code></td> <td>The url of the Sycle api</td> <td>-</td> </tr> <tr> <td><code>SYCLE_PASSWORD</code></td> <td>The password to access the Sycle api</td> <td>-</td> </tr> <tr> <td><code>SYCLE_USERNAME</code></td> <td>The username to access the Sycle api</td> <td>-</td> </tr> <tr> <td><code>UI_URL</code></td> <td>The url of the scheduling UI</td> <td>-</td> </tr> </tbody> </table> </details> ### ๐Ÿค“ Development ```bash # Set CODEARTIFACT_AUTH_TOKEN environment variable to be able to pull from audibene registry make assume-role && export CODEARTIFACT_AUTH_TOKEN=$(make codeartifact-token) # Install dependencies locally for code editor linting, type checking, and interactive test runs npm install # Start up make up # Teardown make down ``` ### ๐Ÿงช Running Tests ```bash # Unit tests (interactive) npm run test:watch -- --coverage src/ # Unit tests (CI) make test-unit # Integration tests (CI) make test-integration ``` ## ๐Ÿ“ฉ Pulsar Topics ??? ## ๐Ÿ—„๏ธ Database ### โžก๏ธ Migrations Migrations handled by Knex.js. For further readings you can check [the docs](http://knexjs.org/#Installation-migrations). _NOTE: Migrations always run before the app runs automatically_ <details> <summary>See Migration Commands</summary> <table> <thead> <tr> <th>Command</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>npm run db:migrate:make migration_name</code></td> <td>Creates new migration files</td> </tr> <tr> <td><code>npm run db:migrate:up</code></td> <td>Runs the next migration that has not yet been run</td> </tr> <tr> <td><code>npm run db:migrate:down</code></td> <td>To undo the last migration that was run</td> </tr> <tr> <td><code>npm run db:migrate:latest</code></td> <td>Runs migrations if there are any pending</td> </tr> <tr> <td><code>npm run db:migrate:rollback</code></td> <td>Rollback the last batch of migrations</td> </tr> <tr> <td><code>npm run db:migrate:list</code></td> <td>Lists both completed and pending migrations</td> </tr> </tbody> </table> </details> ### ๐ŸŒฑ Seeding <details> <summary>See Seed Commands</summary> <table> <thead> <tr> <th>Command</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>npm run db:clean</code></td> <td>Wipes the database of all data</td> </tr> <tr> <td><code>npm run db:seed:test</code></td> <td>Seeds some test domain objects</td> </tr> <tr> <td><code>npm run db:seed:make {seed_name}</code></td> <td>Creates a seed file</td> </tr> <tr> <td><code>npm run db:seed</code></td> <td>Runs seed files</td> </tr> </tbody> </table> </details>