Skip to content

Commit

Permalink
Merge branch 'feat/nestjs' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Maelstromeous committed Apr 3, 2023
2 parents 658bc4b + 7861879 commit 081427c
Show file tree
Hide file tree
Showing 143 changed files with 2,993 additions and 2,773 deletions.
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"

0 comments on commit 081427c

Please sign in to comment.