Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: switched from inversify to nestjs #626

Merged
merged 48 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ce7818c
refactor: switched from inversify to nestjs
microwavekonijn Sep 22, 2022
83746e4
fix: compile error
microwavekonijn Sep 22, 2022
953868b
chore: removed deprecated interfaces
microwavekonijn Sep 22, 2022
e93e36d
chore: removed deprecated class
microwavekonijn Sep 24, 2022
c2475c0
fix: potential side-effect
microwavekonijn Sep 24, 2022
542f1c7
fix: throw unhandled rejections
microwavekonijn Sep 24, 2022
f63fc05
fix: changes some silly logs that are now more verbose :P
microwavekonijn Sep 25, 2022
2300564
feat: health check via http
microwavekonijn Sep 25, 2022
e017704
feat: added dependent services to health check
microwavekonijn Sep 25, 2022
817e27d
fix: internal api healthcheck
microwavekonijn Sep 28, 2022
54dc506
chore: removed unused dependencies
microwavekonijn Sep 28, 2022
fe0cffe
fix(lint): fix linting errors
microwavekonijn Sep 28, 2022
c191992
feat(error): added error handler
microwavekonijn Sep 29, 2022
0e460b5
feat: added exit log
microwavekonijn Sep 29, 2022
80f7625
fix(dependencies): install nestjs axios for the healthcheck
microwavekonijn Sep 29, 2022
d218c8d
fix(constants): improved import maps
microwavekonijn Sep 29, 2022
32df1ea
chore: removed redundant copy pasta scripts
microwavekonijn Sep 29, 2022
f682544
chore: resolve merge conflict
microwavekonijn Oct 15, 2022
e6efd7c
fix: incorrect log call
microwavekonijn Oct 15, 2022
27b0c05
chore: resolve merge conflict
microwavekonijn Mar 28, 2023
22319d4
fix: issues after merge
microwavekonijn Mar 29, 2023
b7e72f1
Merge branch 'dev' into feat/nestjs
microwavekonijn Mar 29, 2023
2c9753e
fix: yarn lock out of sync
microwavekonijn Mar 29, 2023
4c09383
Merge branch 'dev' into feat/nestjs
microwavekonijn Mar 29, 2023
b07b50a
fix: yarn lock out of sync the sequel
microwavekonijn Mar 29, 2023
e87978e
fix: accidental ps2census update and missing dotenv
microwavekonijn Mar 29, 2023
58d76e9
Merge branch 'dev' into feat/nestjs
microwavekonijn Mar 29, 2023
7a1027c
chore: bumped some dependencies
microwavekonijn Mar 29, 2023
2519d93
Added defaults for .env.example
Maelstromeous Mar 29, 2023
6775f35
revert: zonedataparser
microwavekonijn Mar 29, 2023
eb42620
Constants sync
Maelstromeous Mar 29, 2023
3795742
Merge branch 'feat/nestjs' of github.com:ps2alerts/aggregator into fe…
Maelstromeous Mar 29, 2023
e1bd15c
Revert "revert: zonedataparser"
Maelstromeous Mar 29, 2023
bff9595
Updated bootstrap process
Maelstromeous Mar 30, 2023
5c733fa
Refactored the retrieval of map data to hit the PS2A API rather than …
Maelstromeous Mar 31, 2023
0d22a1f
Added debug to default log levels
Maelstromeous Mar 31, 2023
ec2ecb7
Purge the herecy that is momentjs.
Maelstromeous Mar 31, 2023
60abd65
Constants sync
Maelstromeous Mar 31, 2023
1bc1609
Changed how cache keys are generated, using colons to logically names…
Maelstromeous Apr 3, 2023
e73d1ea
Fixed metrics key oddity.
Maelstromeous Apr 3, 2023
3fe6e12
Fixed dev env issue
Maelstromeous Apr 3, 2023
ab5ba06
Refactored table interfaces for InstanceAuthority
Maelstromeous Apr 3, 2023
d7f5676
Painfully added metrics logging for PS2Alerts API requests.
Maelstromeous Apr 3, 2023
d3368e2
Added new metrics around item broker and it's cache hit/miss rate. Re…
Maelstromeous Apr 3, 2023
b1d9b36
Facility data should be namespaced by environment
Maelstromeous Apr 3, 2023
0e8a362
Added OoP to territory logs
Maelstromeous Apr 3, 2023
66ba970
Added instance IDs to warnings for overdues etc.
Maelstromeous Apr 3, 2023
7861879
Tidied up things surrounding deployments
Maelstromeous Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
NODE_ENV=development
VERSION=v4.5.0

# Change this!
CENSUS_SERVICE_ID=example

CENSUS_ENVIRONMENT=ps2

INTERNAL_API_HOST=http://ps2alerts-api:3000
INTERNAL_API_USER=ps2alerts
INTERNAL_API_PASS=foobar

RABBITMQ_HOST=ps2alerts-mq
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASS=guest
RABBITMQ_EXCHANGE=ps2alerts
RABBITMQ_TOPIC_EXCHANGE=ps2alerts-topic
RABBITMQ_VHOST=/
RABBITMQ_API_QUEUE=api-queue
RABBITMQ_API_QUEUE_DELAY=api-queue-delay

REDIS_HOST=ps2alerts-redis
REDIS_PORT=6379
REDIS_PASS=
REDIS_DB=0
84 changes: 43 additions & 41 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module.exports = {
],
"rules": {
// @typescript-eslint rules
"@typescript-eslint/no-unsafe-argument": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/naming-convention": 0,
"@typescript-eslint/array-type": [
"error",
{
Expand All @@ -27,7 +30,6 @@ module.exports = {
"error",
"interface"
],
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
Expand Down Expand Up @@ -85,46 +87,46 @@ module.exports = {
"error",
"method"
],
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "variableLike",
"format": ["camelCase"]
},
{
"selector": "memberLike",
"format": ["camelCase"]
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"]
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "property",
"modifiers": ["static", "readonly"],
"types": ["boolean", "string", "number"],
"format": ["UPPER_CASE"]
},
{
"selector": "enumMember",
"format": ["UPPER_CASE"]
}
],
// "@typescript-eslint/naming-convention": [
// "warn",
// {
// "selector": "variableLike",
// "format": ["camelCase"]
// },
// {
// "selector": "memberLike",
// "format": ["camelCase"]
// },
// {
// "selector": "typeLike",
// "format": ["PascalCase"]
// },
// {
// "selector": "variable",
// "format": ["camelCase", "UPPER_CASE"]
// },
// {
// "selector": "parameter",
// "format": ["camelCase"],
// "leadingUnderscore": "allow"
// },
// {
// "selector": "memberLike",
// "modifiers": ["private"],
// "format": ["camelCase"],
// "leadingUnderscore": "allow"
// },
// {
// "selector": "property",
// "modifiers": ["static", "readonly"],
// "types": ["boolean", "string", "number"],
// "format": ["UPPER_CASE"]
// },
// {
// "selector": "enumMember",
// "format": ["UPPER_CASE"]
// }
// ],
"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-dynamic-delete": "error",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
node_modules
dist
config/census.serviceid.js
Expand Down
6 changes: 0 additions & 6 deletions .yamllint.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ For first time runs, you must run `ps2alerts-aggregator-init`, which goes ahead

Run `ps2alerts-start` to start all associated services including this module. Dependencies will be handled via the bootstrap process.

Before first running the aggregator, you need to copy `.env.example` to `.env` and fill in your census service ID, as well as any other dependencies e.g. remote redis etc.

To start the aggregator for development, run `ps2alerts-aggregator-dev`. This will bootstrap the container with ENV vars etc and tail the docker logs, as you would if you ran it manually via NPM.

#### Workarounds
Expand Down
5 changes: 5 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
71 changes: 34 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"name": "ps2alerts-aggregator",
"version": "4.0.6",
"description": "The aggregator collection script that powers PS2Alerts.com.",
"main": "./dist",
"version": "4.5.0",
"description": "Aggregation engine that powers PS2Alerts.com.",
"scripts": {
"start": "node dist/index.js",
"start:dev": "ts-node-dev src/index.ts",
"start:dev:debug": "tsc && cp -r src/ps2alerts-constants/maps dist/ps2alerts-constants && node --inspect=0.0.0.0:9229 dist/index.js",
"build": "tsc && cp -r src/ps2alerts-constants/maps dist/ps2alerts-constants",
"build:watch": "tsc -w",
"wipe": "rm -rf dist",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ./src --ext .ts",
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"prepare": "husky install",
"lint:check": "eslint ./src --ext .ts",
"lint:fix": "eslint ./src --ext .ts --fix",
"prepare": "husky install"
"lint:fix": "eslint ./src --ext .ts --fix"
},
"repository": {
"type": "git",
Expand All @@ -27,40 +26,38 @@
},
"homepage": "https://github.com/ps2alerts/aggregator#readme",
"dependencies": {
"amqp-connection-manager": "^4.1.11",
"amqplib": "^0.10.3",
"@nestjs/axios": "^2.0.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/microservices": "^9.1.2",
"@nestjs/platform-fastify": "^9.1.2",
"@nestjs/terminus": "^9.1.1",
"amqp-connection-manager": "^4.1.4",
"amqplib": "^0.10.0",
"axios": "^1.3.4",
"body-parser": "^1.20.2",
"bufferutil": "^4.0.7",
"cli-color": "^2.0.3",
"clone": "^2.1.2",
"cors": "^2.8.5",
"express": "^4.18.2",
"inversify": "^6.0.1",
"ioredis": "^5.3.1",
"date-fns": "^2.29.3",
"dotenv": "^16.0.3",
"ioredis": "^5.2.2",
"lodash": "^4.17.21",
"logform": "^2.5.1",
"moment": "^2.29.4",
"moment-timezone": "^0.5.42",
"ps2census": "^4.5.5",
"reflect-metadata": "^0.1.13",
"utf-8-validate": "^6.0.3",
"winston": "^3.8.2",
"winston-transport": "^4.4.0"
"ps2census": "^4.4.1",
"reflect-metadata": "^0.1.13"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@types/amqplib": "^0.10.1",
"@types/lodash": "^4.14.192",
"@types/node": "^18.15.10",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"axios-debug-log": "^1.0.0",
"eslint": "^8.36.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.32.0",
"eslint": "^8.21.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.6.2"
},
"lint-staged": {
Expand Down
1 change: 0 additions & 1 deletion provisioning/dev/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions provisioning/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@ services:
networks:
- "ps2alerts"
environment:
NODE_ENV: "development"
VERSION: "12345"
CENSUS_ENVIRONMENT: "ps2"
CENSUS_SERVICE_ID: "$CENSUS_SERVICE_ID"
REDIS_HOST: "ps2alerts-redis"
REDIS_DB: "0"
INTERNAL_API_HOST: "http://ps2alerts-api:3000"
INTERNAL_API_USER: "ps2alerts"
INTERNAL_API_PASS: "foobar"
LOGGER_TRANSPORTS: "console"
labels:
traefik.enable: "false"

Expand All @@ -34,16 +25,7 @@ services:
networks:
- "ps2alerts"
environment:
NODE_ENV: "development"
VERSION: "12345"
CENSUS_ENVIRONMENT: "ps2ps4eu"
CENSUS_SERVICE_ID: "$CENSUS_SERVICE_ID"
REDIS_HOST: "ps2alerts-redis"
REDIS_DB: "0"
LOGGER_TRANSPORTS: "console"
INTERNAL_API_HOST: "http://ps2alerts-api:3000"
INTERNAL_API_USER: "ps2alerts"
INTERNAL_API_PASS: "foobar"
labels:
traefik.enable: "false"

Expand All @@ -57,16 +39,7 @@ services:
networks:
- "ps2alerts"
environment:
NODE_ENV: "development"
VERSION: "12345"
CENSUS_ENVIRONMENT: "ps2ps4us"
CENSUS_SERVICE_ID: "$CENSUS_SERVICE_ID"
REDIS_HOST: "ps2alerts-redis"
REDIS_DB: "0"
LOGGER_TRANSPORTS: "console"
INTERNAL_API_HOST: "http://ps2alerts-api:3000"
INTERNAL_API_USER: "ps2alerts"
INTERNAL_API_PASS: "foobar"
labels:
traefik.enable: "false"
networks:
Expand Down
2 changes: 0 additions & 2 deletions provisioning/dev/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
- hosts: localhost
vars:
root_dir: "{{ playbook_dir }}/../../"
vars_files:
- ../../vars.local.yml
tasks:
- debug:
msg: "========= 📡 Initializing Aggregator Module 📡 ========="
Expand Down
23 changes: 2 additions & 21 deletions provisioning/dev/start-multi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
vars:
root_dir: "{{ playbook_dir }}/../../"
debug: "false"
vars_files:
- ../../vars.local.yml
tasks:
- debug:
msg: "========= 📡 Starting Aggregator Module - MULTI ENVIRONMENT MODE 📡 ========="
Expand All @@ -14,35 +12,18 @@
path: "{{ root_dir }}/dist"
state: absent

- name: Make a sanitised copy of the docker-compose file
copy:
src: docker-compose.yml
dest: docker-compose-local.yml

# Replace $CENSUS_SERVICE_ID from the user's local vars. DO NOT COMMIT THIS FILE!
- name: Inject census service ID into docker-compose-local.yml file
lineinfile:
path: "{{ playbook_dir }}/docker-compose-local.yml"
search_string: '{{ item }}'
line: ' CENSUS_SERVICE_ID: "{{ census_service_id }}"'
with_items:
- '$CENSUS_SERVICE_ID'
- '$CENSUS_SERVICE_ID'
- '$CENSUS_SERVICE_ID' # Yes, we have to loop it 3 times...
register: output

- name: Stop any running aggregator modules
register: output
docker_compose:
project_src: .
files:
- docker-compose-local.yml
- docker-compose.yml
state: absent

- name: Start up aggregator modules
register: output
docker_compose:
project_src: .
files:
- docker-compose-local.yml
- docker-compose.yml
state: present
12 changes: 0 additions & 12 deletions provisioning/dev/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
vars:
root_dir: "{{ playbook_dir }}/../../"
debug: "false"
vars_files:
- ../../vars.local.yml
tasks:
- debug:
msg: "========= 📡 Starting Aggregator Module - PC ONLY 📡 ========="
Expand Down Expand Up @@ -35,15 +33,5 @@
networks:
- name: "ps2alerts"
tty: true
env:
NODE_ENV: "development"
VERSION: "12345"
CENSUS_ENVIRONMENT: "ps2"
CENSUS_SERVICE_ID: "{{ census_service_id }}"
REDIS_HOST: "ps2alerts-redis"
REDIS_DB: "0"
INTERNAL_API_HOST: "http://ps2alerts-api:3000"
LOGGER_TRANSPORTS: "console"
NODE_DEBUG: "{{ debug }}"
labels:
traefik.enable: "false"
Loading