Skip to content
Open
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
46 changes: 0 additions & 46 deletions .eslintrc.js

This file was deleted.

45 changes: 5 additions & 40 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
node-version: 26
cache: npm
- run: npm ci
- run: npm run lint
Expand All @@ -27,36 +27,6 @@ jobs:
path: |
${{ github.workspace }}/dist
${{ github.workspace }}/node_modules
test-sqlite:
name: Run Tests with SQLite
runs-on: ubuntu-latest
needs: lint-build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- id: cache
uses: actions/cache/restore@v4
with:
key: dist-${{ github.sha }}
path: |
${{ github.workspace }}/dist
${{ github.workspace }}/node_modules
- if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
env:
youTubeKeys_visitorData: ${{ secrets.YOUTUBEKEYS_VISITORDATA }}
youTubeKeys_poToken: ${{ secrets.YOUTUBEKEYS_POTOKEN }}
- name: Run SQLite Tests
timeout-minutes: 5
run: npx nyc --silent npm test
- name: cache nyc output
uses: actions/cache/save@v4
with:
key: nyc-sqlite-${{ github.sha }}
path: ${{ github.workspace }}/.nyc_output
test-postgres:
name: Run Tests with PostgreSQL and Redis
runs-on: ubuntu-latest
Expand All @@ -72,7 +42,7 @@ jobs:
run: docker ps
- uses: actions/setup-node@v4
with:
node-version: 24
node-version: 26
cache: npm
- id: cache
uses: actions/cache/restore@v4
Expand All @@ -85,7 +55,7 @@ jobs:
run: npm ci
- name: Run Postgres Tests
env:
TEST_POSTGRES: true
TEST_REDIS: true
youTubeKeys_visitorData: ${{ secrets.YOUTUBEKEYS_VISITORDATA }}
youTubeKeys_poToken: ${{ secrets.YOUTUBEKEYS_POTOKEN }}
timeout-minutes: 5
Expand All @@ -96,26 +66,21 @@ jobs:
key: nyc-postgres-${{ github.sha }}
path: ${{ github.workspace }}/.nyc_output
codecov:
needs: [test-sqlite, test-postgres]
needs: [test-postgres]
name: Run Codecov
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
node-version: 26
cache: npm
- run: npm ci
- name: restore postgres nyc output
uses: actions/cache/restore@v4
with:
key: nyc-postgres-${{ github.sha }}
path: ${{ github.workspace }}/.nyc_output
- name: restore sqlite nyc output
uses: actions/cache/restore@v4
with:
key: nyc-sqlite-${{ github.sha }}
path: ${{ github.workspace }}/.nyc_output
- run: npx nyc report --reporter=lcov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM node:24-alpine AS builder
FROM node:26-alpine AS builder
RUN apk add --no-cache --virtual .build-deps python3 make g++
COPY package.json package-lock.json tsconfig.json entrypoint.sh ./
COPY src src
RUN npm ci && npm run tsc

FROM node:24-alpine AS app
FROM node:26-alpine AS app
WORKDIR /usr/src/app
RUN apk add --no-cache git postgresql-client
COPY --from=builder ./node_modules ./node_modules
Expand Down
6 changes: 3 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is the server backend for it

# Server

This uses a Postgres or Sqlite database to hold all the timing data.
This uses a Postgres database to hold all the timing data.

To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database. You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me.

Expand All @@ -24,9 +24,9 @@ Make sure to put the database files in the `./databases` folder if you want to u

Rename `config.json.example` to `config.json` and fill the parameters inside. Make sure to remove the comments as comments are not supported in JSON.

Ensure all the tests pass with `npm test`
Ensure all the tests pass with `npm test`. To run tests, make sure the `test-database` from `docker/docker-compose.yml`.

Run the server with `npm start`.
Run the server with `npm start`. To run the server, make sure all the containers in `docker/docker-compose.yml` are running.

# Developing

Expand Down
6 changes: 3 additions & 3 deletions databases/_sponsorTimes.db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS "casualVoteTitles" (
PRIMARY KEY("videoID", "service", "id")
);

CREATE EXTENSION IF NOT EXISTS pgcrypto; --!sqlite-ignore
CREATE EXTENSION IF NOT EXISTS pg_trgm; --!sqlite-ignore
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE EXTENSION IF NOT EXISTS pg_trgm;

COMMIT;
COMMIT;
2 changes: 2 additions & 0 deletions docker/database-test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
POSTGRES_USER=test_db_user
POSTGRES_PASSWORD=test_db_pass
19 changes: 15 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
database:
container_name: database
container_name: sb-database
image: postgres:14
env_file:
- database.env
Expand All @@ -11,7 +11,7 @@ services:
- 5432:5432
restart: always
redis:
container_name: redis
container_name: sb-redis
image: redis:7.0
command: /usr/local/etc/redis/redis.conf
volumes:
Expand All @@ -24,21 +24,32 @@ services:
restart: always
newleaf:
image: abeltramo/newleaf:latest
container_name: newleaf
container_name: sb-newleaf
restart: always
ports:
- 3241:3000
volumes:
- ./newleaf/configuration.py:/workdir/configuration.py
rsync:
image: mchangrh/rsync:latest
container_name: rsync
container_name: sb-rsync
restart: always
ports:
- 873:873
volumes:
- ./rsync/rsyncd.conf:/etc/rsyncd.conf
- ./database-export/:/mirror
test-database:
container_name: sb-test-database
image: postgres:14
env_file:
- database-test.env
volumes:
- database-test-data:/var/lib/postgresql/data
ports:
- 5499:5432
restart: always

volumes:
database-data:
database-test-data:
73 changes: 73 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { defineConfig } from"eslint/config";

import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import js from "@eslint/js";
import tseslint from "typescript-eslint";

export default defineConfig([
{
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
...globals.node,
},

parser: tsParser,
ecmaVersion: 12,
sourceType: "module",
parserOptions: {},
},

extends: [
js.configs.recommended,
tseslint.configs.recommended,
],

plugins: {
"@typescript-eslint": typescriptEslint,
},

rules: {
// TODO: Remove warn rules when not needed anymore
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",

"indent": ["warn", 4, {
"SwitchCase": 1,
}],

"no-multiple-empty-lines": ["error", {
max: 2,
maxEOF: 0,
}],

"no-self-assign": "off",
"no-trailing-spaces": "warn",
"object-curly-spacing": ["warn", "always"],
"prefer-template": "warn",

"quotes": ["warn", "double", {
"avoidEscape": true,
"allowTemplateLiterals": true,
}],

"require-await": "warn",
"semi": "warn",
"no-console": "warn",
},
}, {
files: ["**/*.ts"],

languageOptions: {
parserOptions: {
project: ["./tsconfig.eslint.json"],
},
},

rules: {
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-floating-promises": "error",
},
}]);
Loading
Loading