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

Feat/japa tests, proper close() function on TracManager class #22

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
42 changes: 42 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Enable or disable REST API functionality
# Values: "true" or "false"
# ENABLE_REST=false

# Enable Rest API /docs swagger endpoint
ENABLE_REST_API_DOCS=false

# Port on which the REST API will run
REST_PORT=3333

# Cache control max age for REST API responses
REST_CACHE_CONTROL_MAX_AGE=1111

# Whether cache control should be public for REST API responses
# Values: "true" or "false"
REST_CACHE_CONTROL_PUBLIC=false

# Custom headers for REST API responses, in JSON format
REST_HEADERS=[{"name": "X-Powered-By", "value": "TracCore"}, {"name": "Access-Control-Allow-Origin", "value": "*"}]

# Enable or disable metrics exporter
# Values: "true" or "false"
ENABLE_METRICS=false

# Port on which the metrics exporter will run
METRICS_PORT=2222

# Enable or disable WebSocket functionality
# Values: "true" or "false"
ENABLE_WEBSOCKETS=false

# Port on which the WebSocket server will run
WEBSOCKET_PORT=5095

# CORS setting for WebSocket server
WEBSOCKET_CORS=*

# Default channel ID
CHANNEL=729c91276e20b8e270ea589ac437f24e6c7c66c969b4acfe99bd82faab391e68

# Default test channel ID
CHANNEL_TEST=729c91276e20b8e270ea589ac437f24e6c7c66c969b4acfe99bd82faab391e68
42 changes: 42 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Enable or disable REST API functionality
# Values: "true" or "false"
ENABLE_REST=true

# Enable Rest API /docs swagger endpoint
ENABLE_REST_API_DOCS=true

# Port on which the REST API will run
REST_PORT=5099

# Cache control max age for REST API responses
REST_CACHE_CONTROL_MAX_AGE=3600

# Whether cache control should be public for REST API responses
# Values: "true" or "false"
REST_CACHE_CONTROL_PUBLIC=false

# Custom headers for REST API responses, in JSON format
REST_HEADERS=[{"name": "X-Powered-By", "value": "TracCore"}, {"name": "Access-Control-Allow-Origin", "value": "*"}]

# Enable or disable metrics exporter
# Values: "true" or "false"
ENABLE_METRICS=true

# Port on which the metrics exporter will run
METRICS_PORT=13337

# Enable or disable WebSocket functionality
# Values: "true" or "false"
ENABLE_WEBSOCKETS=false

# Port on which the WebSocket server will run
WEBSOCKET_PORT=5095

# CORS setting for WebSocket server
WEBSOCKET_CORS=*

# Default channel ID
CHANNEL=53d2e64fa7a09e9dc74fc52ee9e9feb9d59b3e2cff4a25dfb543ec3b0bf4b281

# Default test channel ID
CHANNEL_TEST=729c91276e20b8e270ea589ac437f24e6c7c66c969b4acfe99bd82faab391e68
14 changes: 14 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Node.js CI
on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- run: npm ci
- run: npm test
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"discord.enabled": true
}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:latest
# Set the working directory
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init
WORKDIR /home/node/app
# Before switching to user 'node', ensure the directory exists and has the correct permissions
RUN mkdir -p /home/node/app/node_modules && mkdir /home/node/app/tapstore && chown -R node:node /home/node/app
# Copying with chown in a single line before npm install to avoid permission issues.
COPY --chown=node:node . .
# Install dependencies
RUN npm install
# Expose ports
EXPOSE 5099
EXPOSE 13337
# RUN chmod -R 777 /home/node/
USER node
ENV NODE_ENV production

CMD [ "dumb-init", "npm", "start" ]
11 changes: 11 additions & 0 deletions bin/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { configure, processCLIArgs, run } from '@japa/runner'
import { expect } from '@japa/expect'
import { apiClient } from '@japa/api-client'

processCLIArgs(process.argv.splice(2))
configure({
files: ['tests/**/*.spec.js'],
plugins: [expect(), apiClient('http://localhost:5099')],
})

run()
82 changes: 82 additions & 0 deletions docker-compose-metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
version: '3.8'
networks:
monitoring:
driver: bridge

volumes:
prometheus_data: {}
grafana_storage: {}
tapstore: {}

services:
trac-core:
# image: tap-reader
build:
context: ./
dockerfile: Dockerfile
# expose:
# - 13337
# - 5099
ports:
- '13337:13337'
- '5099:5099'
networks:
- monitoring
# volumes:
# - 'tapstore:/home/node/app/tapstore'

grafana:
build:
context: ./grafana
dockerfile: Dockerfile
container_name: grafana
restart: unless-stopped
environment:
# - GF_SERVER_ROOT_URL=http://my.grafana.server/
- GF_INSTALL_PLUGINS=grafana-clock-panel
ports:
- '3000:3000'
volumes:
- 'grafana_storage:/var/lib/grafana'
networks:
- monitoring

node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
expose:
- 9100
ports:
- '9100:9100'
networks:
- monitoring

prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
ports:
- '9090:9090'
expose:
- 9090
networks:
- monitoring
23 changes: 23 additions & 0 deletions docker-compose-standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.8'
networks:
monitoring:
driver: bridge

volumes:
tapstore: {}

services:
tapreader:
build:
context: ./
dockerfile: Dockerfile
# expose:
# - 13337
# - 5099
ports:
- '13337:13337'
- '5099:5099'
# networks:
# - monitoring
volumes:
- './tapstore:/home/node/app/tapstore:rw'
12 changes: 12 additions & 0 deletions grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM grafana/grafana

# ENV GF_AUTH_DISABLE_LOGIN_FORM "true"
# ENV GF_AUTH_ANONYMOUS_ENABLED "true"
# ENV GF_AUTH_ANONYMOUS_ORG ROLE "Admin"

#Adding all the files to docker container.
ADD provisioning /etc/grafana/provisioning
ADD config.ini /etc/grafana/config.ini

# Adding all the dashboard files (JSON) to docker container
ADD dashboards /var/lib/grafana/dashboards
6 changes: 6 additions & 0 deletions grafana/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[paths]
provisioning = /etc/grafana/provisioning
[server]
enable_gzip = true
[users]
default_theme = dark
Loading
Loading