This application server will be hosted by Render in a Docker container and a PostgreSQL database by Neon. Additionally a cron-job is set up to keep the service alive on Render due to 15-min inactivity on free tier plan.
The development process is structured by the TDD (test driven development) principle.
- 🪲 support/bug-ticket handling including client + user data
- 🔍 filtered search for ticket + user data (properties + timespan)
- 🔐 maintenance mode can en/disable application via single request
- 🔑 request verification by api-keys
- 🕵️ request rate limiting + violation handling
To monitor errors the logging framework Winston is used in combination with Logtail from Betterstack as a Singleton: config
While working within local (DEV) or test environment, error messages are logged into the consoles. For the deployed environments (STAG/PROD) the logging is set to send logtails to Betterstack (longer storage time than app-hosting service). For easy access and monitoring of error messages, the Betterstack UI client dashboard comes in handy (see Figure 1).
Testing of the application server can be done automatically via Jest tests (next chapter) or manually by a separate demonstration route.
POST: /meta/demo
using the body payload to control the response - use the demo route to get exceptions, info message or the current application version number. With the implemented observation middleware, the demo route will be limited to 20 daily requests. As the demo route is not authenticated, you only need the following data:
[ROUTE] {{url}}/api/v1/meta/demo
[PAYLOAD] { "demo_mode": "success" }Use https://support-0hsq.onrender.com for {{url}} to test on live conditions.
See Figure 2 for the different use cases & responses (Postman, v11.73.5) - from left to right:
[PAYLOAD]: { "mode_enum": "success" } => retrieve current version number as request without fail
[PAYLOAD]: undefined (none) or empty obj/array => retrieve exception for undefined body
[PAYLOAD]: { "mode_enum": "%§$" } => retrieve exception due to invalid value
[PAYLOAD]: { "mode_enum": "error" } => retrieve exception for intended failing db query (see data.message: SEL instead of SELECT)
Added jest testing framework to project providing unit tests and integration tests for the backend.
Install the packages @jest/globals, @types/jest, supertest, @testcontainers/postgresql and testcontainers additional to jest:
npm install jest @jest/globals @types/jest supertest @testcontainers/postgresql testcontainers --save-dev250+ tests exist currently for models, utils, validators and workflows (integration tests) - see tests.
Run tests on local device by including setup for dotenv/config to provide environment variables:
set NODE_ENV=test && jest --setupFiles dotenv/configor simply save as script command in package.json to run npm test:
"scripts": {
"start:dev": "ts-node --files src/server.ts",
"test": "set NODE_ENV=test && jest --setupFiles dotenv/config"
}To automatically check tests before merging feature/development branch further up, a GitHub Action is set up, see main.yml.
Preventing an unwanted merge with unfinished/failed test run, the project is set up to disable merging until all tests have passed (see Figure 3 to Figure 4).
-
$\textsf{\color{teal}Addition:}$ Added logic to handle penalties (limit violations only currently). -
$\textsf{\color{orange}Patch:}$ Added migration to update 'clients' table by adding 'flag' property.v
- - cloudflare setup
- - jenkins setup
- - host setup
- - mail setup




