diff --git a/.editorconfig b/.editorconfig index 81f76721..a376964a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ charset = utf-8 end_of_line = lf indent_style = tab indent_size = 8 -print_width = 111 +print_width = 120 trim_trailing_whitespace = true insert_final_newline = true diff --git a/.github/workflows/ingest-pull.yml b/.github/workflows/ingest-pull.yml index 7930f39d..57d4148c 100644 --- a/.github/workflows/ingest-pull.yml +++ b/.github/workflows/ingest-pull.yml @@ -32,7 +32,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} - name: ๐Ÿ›  Setup Bun - uses: oven-sh/setup-bun@v1 + uses: oven-sh/setup-bun@v2 with: bun-version: latest @@ -46,7 +46,7 @@ jobs: create_credentials_file: true - name: ๐Ÿ“š Lint Code - run: bun ingest:lint + run: bun lint - name: ๐Ÿงช Run Ingest Tests env: @@ -74,7 +74,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} - name: ๐Ÿ›  Setup Bun - uses: oven-sh/setup-bun@v1 + uses: oven-sh/setup-bun@v2 with: bun-version: latest diff --git a/.github/workflows/ingest-push.yml b/.github/workflows/ingest-push.yml index d8c185b2..6bfcd64e 100644 --- a/.github/workflows/ingest-push.yml +++ b/.github/workflows/ingest-push.yml @@ -9,7 +9,7 @@ on: types: [closed] env: - NODE_VERSION: 22 + NODE_VERSION: 22.8 IMAGE_NAME: ard-eventhub-europe-west3/ingest REGISTRY_DOMAIN: europe-west3-docker.pkg.dev @@ -35,7 +35,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} - name: ๐Ÿ›  Setup Bun - uses: oven-sh/setup-bun@v1 + uses: oven-sh/setup-bun@v2 with: bun-version: latest @@ -49,7 +49,7 @@ jobs: create_credentials_file: true - name: ๐Ÿ“š Lint Code - run: bun ingest:lint + run: bun lint - name: ๐Ÿงช Run Ingest Tests env: @@ -62,7 +62,7 @@ jobs: STAGE: dev TEST_USER: ${{ secrets.TEST_USER }} TEST_USER_PW: ${{ secrets.TEST_USER_PW }} - run: bun ingest:test + run: npm run ingest:test docker: runs-on: ubuntu-latest diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 93a7ce9c..00000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Linter - -on: - workflow_dispatch: - pull_request: - branches-ignore: - - dependabot/** - -permissions: - contents: read - statuses: write - -jobs: - lint: - uses: swrlab/node-utils/.github/workflows/linter.yml@main - with: - install-all: false - log-level: 'NOTICE' - validate-all-codebase: false - javascript-es-config-file: /.eslintrc.json diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0b1bd5..8f193262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.9.1] - 2024-09-04 + +- chore: apply linter suggestions +- feat: add more event duplication IDs + ## [1.9.0] - 2024-08-19 - feat: enable event duplication for service migrations diff --git a/Dockerfile b/Dockerfile index b23a9940..15a36ee9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,10 @@ WORKDIR /web/app COPY . . # Install dependencies -RUN bun install +RUN bun install --frozen-lockfile --production # Load desired node image -FROM node:22-alpine +FROM node:22.8-alpine # Create app directory WORKDIR /web/app diff --git a/biome.json b/biome.json index ec22e05c..614f25ed 100644 --- a/biome.json +++ b/biome.json @@ -5,7 +5,8 @@ }, "formatter": { "indentStyle": "tab", - "formatWithErrors": true + "formatWithErrors": true, + "lineWidth": 120 }, "javascript": { "formatter": { diff --git a/bun.lockb b/bun.lockb index 2ca61188..81213447 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/config/coreIdPrefixes.json b/config/core-id-prefixes.json similarity index 100% rename from config/coreIdPrefixes.json rename to config/core-id-prefixes.json diff --git a/config/dtsKeys.js b/config/dts-keys.js similarity index 100% rename from config/dtsKeys.js rename to config/dts-keys.js diff --git a/config/event-duplication.json b/config/event-duplication.json index f73eeebf..04951677 100644 --- a/config/event-duplication.json +++ b/config/event-duplication.json @@ -7,5 +7,27 @@ "crid://wdr.de/Sendung-3c5b688d-5f31-4bb1-91f0-41d72a2e7cd3": "crid://wdr.de/Beitrag-7a56249f-4f7e-4ff4-aaf0-27d7cf50ba13", "crid://wdr.de/Sendung-165961": "crid://wdr.de/Beitrag-99ed97df-550b-48a4-a544-dcaf03e59c44", "crid://wdr.de/Sendung-165960": "crid://wdr.de/Beitrag-5552666a-b5e0-48b2-a500-47a58ad2d457", - "crid://wdr.de/Sendung-165959": "crid://wdr.de/Beitrag-78a782d9-d557-4c01-a2f9-99866279190e" + "crid://wdr.de/Sendung-165959": "crid://wdr.de/Beitrag-78a782d9-d557-4c01-a2f9-99866279190e", + + "crid://mdr.de/stream/28428-0": "crid://mdr.de/livestream/cms/5ad33a1f-f08e-4c6f-98cf-186df47a12cf/Beitrag", + "crid://mdr.de/stream/28429-0": "crid://mdr.de/livestream/cms/a8e7fd2a-b198-422f-9629-336cf27f13fa/Beitrag", + "crid://mdr.de/stream/28430-0": "crid://mdr.de/livestream/cms/112f1e08-13ce-4e85-8b60-a17929402ae9/Beitrag", + "crid://mdr.de/stream/28434-0": "crid://mdr.de/livestream/cms/MDR Aktuell Radio/Beitrag", + "crid://mdr.de/stream/28431-0": "crid://mdr.de/livestream/cms/MDR Kultur Radio/Beitrag", + "crid://mdr.de/stream/28431-1-0": "crid://mdr.de/livestream/cms/84876c76-d6f4-4b25-bdec-d22e98fb94c4/Beitrag", + "crid://mdr.de/stream/28435-0": "crid://mdr.de/livestream/cms/MDR Klassik/Beitrag", + "crid://mdr.de/stream/28432-0": "crid://mdr.de/livestream/cms/Jump/Beitrag", + "crid://mdr.de/stream/28432-1-0": "crid://mdr.de/livestream/cms/b643d081-4f41-4f90-ada3-7864bcacaf24/Beitrag", + "crid://mdr.de/stream/28432-3-0": "crid://mdr.de/livestream/cms/d760608f-9eb4-4cf3-a405-e8cccb355776/Beitrag", + "crid://mdr.de/stream/28432-2-0": "crid://mdr.de/livestream/cms/5dd1d0cd-2ac6-46f8-b90d-3f5a8f2ca5e5/Beitrag", + "crid://mdr.de/stream/28433-0": "crid://mdr.de/livestream/cms/Sputnik/Beitrag", + "crid://mdr.de/stream/28433-2-0": "crid://mdr.de/livestream/cms/b8121905-6f73-4b83-a06a-b0e5fda562ad/Beitrag", + "crid://mdr.de/stream/28433-7-0": "crid://mdr.de/livestream/cms/f04c8fa2-3e15-4760-988b-5381ceb5f2ab/Beitrag", + "crid://mdr.de/stream/28433-1-0": "crid://mdr.de/livestream/cms/1cd38023-bc46-488c-b6e1-3a947796617b/Beitrag", + "crid://mdr.de/stream/28433-4-0": "crid://mdr.de/livestream/cms/964d26d4-c392-4295-94a8-acec49c0a4d7/Beitrag", + "crid://mdr.de/stream/28433-5-0": "crid://mdr.de/livestream/cms/a2c4d57d-2f48-42f0-ad2e-8a309283e3d9/Beitrag", + "crid://mdr.de/stream/28433-3-0": "crid://mdr.de/livestream/cms/0217ea7c-b6c6-402e-bbe2-cc83358c0c21/Beitrag", + "crid://mdr.de/stream/28433-6-0": "crid://mdr.de/livestream/cms/87710c90-ac51-4231-93c6-7206c9c5c50b/Beitrag", + "crid://mdr.de/stream/10402-0": "crid://mdr.de/livestream/cms/MDR Tweens/Beitrag", + "crid://mdr.de/stream/10401-0": "crid://mdr.de/livestream/cms/9507b3b3-5b04-4540-97c9-758c40ed98c0/Beitrag" } diff --git a/config/index.js b/config/index.js index 35a7229a..d642f4bc 100644 --- a/config/index.js +++ b/config/index.js @@ -7,7 +7,7 @@ // import version from package.json const { version } = require('../package.json') -const coreIdPrefixes = require('./coreIdPrefixes.json') +const coreIdPrefixes = require('./core-id-prefixes.json') // load winston logger const logger = require('../src/utils/logger') @@ -32,7 +32,7 @@ if (!process.env.SERVICE_NAME) exitWithError('SERVICE_NAME not found') // set static envs const stage = process.env.STAGE.toLowerCase() const protocol = stage === 'dev' ? 'http' : 'https' -const hostname = stage === 'dev' ? 'localhost' : `eventhub-ingest.ard.de` +const hostname = stage === 'dev' ? 'localhost' : 'eventhub-ingest.ard.de' const port = process.env.PORT || 8080 const serviceName = process.env.SERVICE_NAME diff --git a/config/swaggerUI.js b/config/swagger-ui.js similarity index 100% rename from config/swaggerUI.js rename to config/swagger-ui.js diff --git a/package.json b/package.json index 28afe494..03e50874 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ard-eventhub", - "version": "1.9.0", + "version": "1.9.1", "description": "ARD system to distribute real-time (live) metadata for primarily radio broadcasts.", "main": "./src/ingest/index.js", "engines": { @@ -14,7 +14,7 @@ "ingest:cloud": "node ./src/ingest/index.js", "ingest:test:local": "node --env-file .env ./node_modules/mocha/bin/mocha --recursive './src/**/*.test.js' --timeout 15000 --exit", "ingest:test": "mocha --recursive './src/**/*.test.js' --timeout 15000 --exit", - "ingest:lint": "biome lint src", + "lint": "biome lint", "docker:build": "docker build . -t swr/ard-eventhub", "docker:run": "docker run --env-file .env -p 8080:8080 --name ard-eventhub swr/ard-eventhub", "docker:scan": "bun docker:build && docker scout quickview", @@ -28,15 +28,15 @@ "license": "EUPL-1.2", "dependencies": { "@google-cloud/datastore": "^9.1.0", - "@google-cloud/pubsub": "^4.5.0", + "@google-cloud/pubsub": "^4.7.0", "@google-cloud/secret-manager": "^5.6.0", "@swrlab/utils": "^2.0.1-beta", "compression": "^1.7.4", - "dd-trace": "^5.21.0", + "dd-trace": "^5.22.0", "express": "^4.19.2", - "express-openapi-validator": "^5.3.1", - "firebase-admin": "^12.3.1", - "google-auth-library": "^9.13.0", + "express-openapi-validator": "^5.3.4", + "firebase-admin": "^12.4.0", + "google-auth-library": "^9.14.1", "jsonwebtoken": "^9.0.2", "luxon": "^3.5.0", "slug": "^9.1.0", @@ -46,7 +46,7 @@ }, "devDependencies": { "@biomejs/biome": "^1.8.3", - "@swrlab/style-guide": "swrlab/style-guide", + "@swrlab/style-guide": "^1.0.1", "chai": "^4.5.0", "chai-http": "^4.4.0", "docsify-cli": "^4.4.4", diff --git a/src/ingest/auth/login/post.js b/src/ingest/auth/login/post.js index 537c6ebb..d826494c 100644 --- a/src/ingest/auth/login/post.js +++ b/src/ingest/auth/login/post.js @@ -22,7 +22,7 @@ module.exports = async (req, res) => { // send email + password for verification, receive login and user object try { login = await firebase.signInWithEmailAndPassword(req.body.email, req.body.password) - } catch (error) { + } catch (_error) { return response.badRequest(req, res, { status: 500 }) } diff --git a/src/ingest/auth/middleware/verify.js b/src/ingest/auth/middleware/verify.js index 28b05ffd..6b6d20f4 100644 --- a/src/ingest/auth/middleware/verify.js +++ b/src/ingest/auth/middleware/verify.js @@ -29,7 +29,6 @@ module.exports = async (req, res, next) => { }) return res.sendStatus(401) } - // extract token ;[authorization] = authorization.match(regexp) @@ -43,6 +42,7 @@ module.exports = async (req, res, next) => { level: 'notice', message: 'user token invalid', source, + error, data: { ...req.headers, authorization: 'hidden' }, }) return res.status(403).json(ERROR_JSON) diff --git a/src/ingest/auth/refresh/post.js b/src/ingest/auth/refresh/post.js index eade97dc..4a1b7a52 100644 --- a/src/ingest/auth/refresh/post.js +++ b/src/ingest/auth/refresh/post.js @@ -22,7 +22,7 @@ module.exports = async (req, res) => { // swap previously received refresh token for new id token try { login = await firebase.refreshToken(req.body.refreshToken) - } catch (error) { + } catch (_error) { return response.badRequest(req, res, { status: 500 }) } diff --git a/src/ingest/ingest.test.js b/src/ingest/ingest.test.js index 2c4c23c5..5af3be7d 100644 --- a/src/ingest/ingest.test.js +++ b/src/ingest/ingest.test.js @@ -8,6 +8,7 @@ */ // Require dependencies +const { describe, it, before } = require('mocha') const chai = require('chai') const chaiHttp = require('chai-http') const { DateTime } = require('luxon') @@ -17,7 +18,7 @@ const logger = require('../utils/logger') // Init chai functions const { expect } = chai -const should = chai.should() +chai.should() // Use chaiHttp chai.use(chaiHttp) @@ -81,10 +82,11 @@ describe(`POST ${loginPath}`, () => { password: testUserPass, } - chai.request(server) + chai + .request(server) .post(loginPath) .send(loginRequest) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) testAuthKeys(res.body) done() @@ -103,10 +105,11 @@ describe(`POST ${refreshPath}`, () => { refreshToken: refreshToken, } - chai.request(server) + chai + .request(server) .post(refreshPath) .send(refreshRequest) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) testAuthKeys(res.body) done() @@ -127,10 +130,11 @@ if (testUserReset === true) { email: testUser, } - chai.request(server) + chai + .request(server) .post(resetPath) .send(resetRequest) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) done() }) @@ -185,32 +189,35 @@ const event = { describe(`POST ${eventPath}`, () => { it('test invalid auth for POST /event', (done) => { - chai.request(server) + chai + .request(server) .post(eventPath) .send(event) - .end((err, res) => { + .end((_err, res) => { testMissingAuth(res) done() }) }) it('test invalid auth for POST /event', (done) => { - chai.request(server) + chai + .request(server) .post(eventPath) .set('Authorization', `Bearer invalid${accessToken}`) .send(event) - .end((err, res) => { + .end((_err, res) => { testFailedAuth(res) done() }) }) it('publish a new event', (done) => { - chai.request(server) + chai + .request(server) .post(eventPath) .set('Authorization', `Bearer ${accessToken}`) .send(event) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 201) testEventKeys(res.body) done() @@ -219,11 +226,12 @@ describe(`POST ${eventPath}`, () => { it('publish a new event with expired time', (done) => { event.start = DateTime.now().minus({ minutes: 3 }).toISO() - chai.request(server) + chai + .request(server) .post(eventPath) .set('Authorization', `Bearer ${accessToken}`) .send(event) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 400) done() }) @@ -231,11 +239,12 @@ describe(`POST ${eventPath}`, () => { it('publish a new event with invalid time', (done) => { event.start = `${DateTime.now().toISO()}00` - chai.request(server) + chai + .request(server) .post(eventPath) .set('Authorization', `Bearer ${accessToken}`) .send(event) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 400) done() }) @@ -243,11 +252,12 @@ describe(`POST ${eventPath}`, () => { it('publish a new event with invalid externalId in references', (done) => { event.references[1].externalId = null - chai.request(server) + chai + .request(server) .post(eventPath) .set('Authorization', `Bearer ${accessToken}`) .send(event) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 400) done() }) @@ -271,20 +281,22 @@ function testTopicKeys(body) { describe(`GET ${topicPath}`, () => { it(`test auth for GET ${topicPath}`, (done) => { - chai.request(server) + chai + .request(server) .get(topicPath) .set('Authorization', `Bearer invalid${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testFailedAuth(res) done() }) }) it('list all available topics', (done) => { - chai.request(server) + chai + .request(server) .get(topicPath) .set('Authorization', `Bearer ${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) res.body.should.be.a('array') res.body.every((i) => testTopicKeys(i)) @@ -333,22 +345,24 @@ describe(`POST ${subscriptPath}`, () => { }) it(`test auth for POST ${subscriptPath}`, (done) => { - chai.request(server) + chai + .request(server) .post(subscriptPath) .set('Authorization', `Bearer invalid${accessToken}`) .send(subscription) - .end((err, res) => { + .end((_err, res) => { testFailedAuth(res) done() }) }) it('add a new subscription to this user', (done) => { - chai.request(server) + chai + .request(server) .post(subscriptPath) .set('Authorization', `Bearer ${accessToken}`) .send(subscription) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 201) testSubscriptionKeys(res.body) // Store subscription name for further tests @@ -360,20 +374,22 @@ describe(`POST ${subscriptPath}`, () => { describe(`GET ${subscriptPath}`, () => { it(`test auth for GET ${subscriptPath}`, (done) => { - chai.request(server) + chai + .request(server) .get(subscriptPath) .set('Authorization', `Bearer invalid${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testFailedAuth(res) done() }) }) it('list all subscriptions for this user', (done) => { - chai.request(server) + chai + .request(server) .get(subscriptPath) .set('Authorization', `Bearer ${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) res.body.should.be.a('array') res.body.every((i) => testSubscriptionKeys(i)) @@ -384,20 +400,22 @@ describe(`GET ${subscriptPath}`, () => { describe(`GET ${subscriptPath}/{name}`, () => { it(`test auth for GET ${subscriptPath}/{name}`, (done) => { - chai.request(server) + chai + .request(server) .get(`${subscriptPath}/${subscriptionName}`) .set('Authorization', `Bearer invalid${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testFailedAuth(res) done() }) }) it('get details about single subscription from this user', (done) => { - chai.request(server) + chai + .request(server) .get(`${subscriptPath}/${subscriptionName}`) .set('Authorization', `Bearer ${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) testSubscriptionKeys(res.body) done() @@ -407,20 +425,22 @@ describe(`GET ${subscriptPath}/{name}`, () => { describe(`DELETE ${subscriptPath}/{name}`, () => { it(`test auth for DELETE ${subscriptPath}/{name}`, (done) => { - chai.request(server) + chai + .request(server) .delete(`${subscriptPath}/${subscriptionName}`) .set('Authorization', `Bearer invalid${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testFailedAuth(res) done() }) }) it('remove a single subscription by this user', (done) => { - chai.request(server) + chai + .request(server) .delete(`${subscriptPath}/${subscriptionName}`) .set('Authorization', `Bearer ${accessToken}`) - .end((err, res) => { + .end((_err, res) => { testResponse(res, 200) res.body.should.be.a('object') res.body.should.have.property('valid').eql(true) diff --git a/src/ingest/router.js b/src/ingest/router.js index ff606314..90439496 100644 --- a/src/ingest/router.js +++ b/src/ingest/router.js @@ -1,10 +1,3 @@ -/* - - ard-eventhub - by SWR Audio Lab - -*/ - // import express.router const { isIncluded } = require('@swrlab/utils/packages/strings') const express = require('express') @@ -14,7 +7,7 @@ const OpenApiValidator = require('express-openapi-validator') // load swagger UI const swaggerUi = require('swagger-ui-express') const swaggerDocument = require('../../openapi.json') -const swaggerConfig = require('../../config/swaggerUI') +const swaggerConfig = require('../../config/swagger-ui') // set up router const router = express.Router() @@ -29,16 +22,11 @@ router.use( apiSpec: './openapi.yaml', validateRequests: true, validateResponses: false, - ignorePaths: (path) => - path.startsWith('/openapi') || - path === '/' || - path === '/health' || - path === '/pubsub', + ignorePaths: (path) => path.startsWith('/openapi') || path === '/' || path === '/health' || path === '/pubsub', formats: { 'iso8601-timestamp': { type: 'string', - validate: (value) => - isIncluded(value, 'T') && DateTime.fromISO(value).isValid, + validate: (value) => isIncluded(value, 'T') && DateTime.fromISO(value).isValid, }, }, }) @@ -49,9 +37,7 @@ const response = require('../utils/response') // register swagger endpoints router.get('/openapi/openapi.json', (_req, res) => res.json(swaggerDocument)) -router.get('/openapi/openapi.yaml', (_req, res) => - res.sendFile('openapi.yaml', { root: '.' }) -) +router.get('/openapi/openapi.yaml', (_req, res) => res.sendFile('openapi.yaml', { root: '.' })) router.use('/openapi', swaggerUi.serve, swaggerUi.setup({}, swaggerConfig)) // load auth middleware @@ -69,16 +55,8 @@ router.post('/pubsub/', require('./pubsub/verify'), require('./pubsub')) router.get('/subscriptions/', authVerify, require('./subscriptions/list')) router.post('/subscriptions/', authVerify, require('./subscriptions/post')) -router.get( - '/subscriptions/:subscriptionName', - authVerify, - require('./subscriptions/get') -) -router.delete( - '/subscriptions/:subscriptionName', - authVerify, - require('./subscriptions/delete') -) +router.get('/subscriptions/:subscriptionName', authVerify, require('./subscriptions/get')) +router.delete('/subscriptions/:subscriptionName', authVerify, require('./subscriptions/delete')) router.get('/topics/', authVerify, require('./topics/list')) router.get('/topics/:topicName', authVerify, require('./topics/list')) @@ -89,18 +67,14 @@ router.get(['/', '/health'], (_req, res) => { }) // set which error message to return (other may contain private information) -const allowedErrors = [ - 'Authorization header required', - 'GET method not allowed', -] +const allowedErrors = ['Authorization header required', 'GET method not allowed'] // set openapi error handler router.use((err, req, res, _next) => { // set error message let useOriginalError = false if (allowedErrors.includes(err.message)) useOriginalError = true - if (err.message.includes('must have required property') !== -1) - useOriginalError = true + if (err.message.includes('must have required property') !== -1) useOriginalError = true return response.badRequest(req, res, { message: useOriginalError ? err.message : 'Bad request', diff --git a/src/ingest/subscriptions/get.js b/src/ingest/subscriptions/get.js index b818ac8e..fb3d7f0f 100644 --- a/src/ingest/subscriptions/get.js +++ b/src/ingest/subscriptions/get.js @@ -22,7 +22,7 @@ module.exports = async (req, res) => { try { subscription = await pubsub.getSubscription(subscriptionName) subscription = subscription.limited - } catch (error) { + } catch (_error) { return response.notFound(req, res, { status: 404, message: `Subscription '${subscriptionName}' not found`, diff --git a/src/ingest/subscriptions/list.js b/src/ingest/subscriptions/list.js index 0dbd56de..b4af5279 100644 --- a/src/ingest/subscriptions/list.js +++ b/src/ingest/subscriptions/list.js @@ -18,9 +18,7 @@ module.exports = async (req, res) => { let subscriptions = await pubsub.getSubscriptions() // verify if user is allowed to list subscriptions (same institution) - subscriptions = subscriptions.filter( - (subscription) => subscription?.institutionId === req.user.institutionId - ) + subscriptions = subscriptions.filter((subscription) => subscription?.institutionId === req.user.institutionId) // return data return res.status(200).json(subscriptions) diff --git a/src/utils/plugins/dts/event.js b/src/utils/plugins/dts/event.js index 0a3825e5..3f7890c3 100644 --- a/src/utils/plugins/dts/event.js +++ b/src/utils/plugins/dts/event.js @@ -13,7 +13,7 @@ const logger = require('../../logger') const undici = require('../../undici') // load keys -const { credentials, endpoints, permittedExcludedFields } = require('../../../../config/dtsKeys') +const { credentials, endpoints, permittedExcludedFields } = require('../../../../config/dts-keys') // load config const config = require('../../../../config') @@ -88,8 +88,7 @@ module.exports = async (job) => { webURL: plugin?.webUrl || null, enableShare: !!plugin?.webUrl, - enableThumbs: - plugin?.enableThumbs === true || plugin?.enableThumbs === false ? plugin.enableThumbs : true, + enableThumbs: plugin?.enableThumbs === true || plugin?.enableThumbs === false ? plugin.enableThumbs : true, year: null, fccId: null, imageURL: null, @@ -99,8 +98,7 @@ module.exports = async (job) => { const mediaType = plugin?.preferArtistMedia ? 'artist' : 'cover' const media = event.media?.find((thisMedia) => thisMedia.type === mediaType) if (media) { - liveRadioEvent.imageURL = - media.url || media.templateUrl.replace('{width}', 512).replace('{height}', 512) + liveRadioEvent.imageURL = media.url || media.templateUrl.replace('{width}', 512).replace('{height}', 512) } // handle exclusions diff --git a/src/utils/response/badRequest.js b/src/utils/response/badRequest.js index fe98a38c..49afeb91 100644 --- a/src/utils/response/badRequest.js +++ b/src/utils/response/badRequest.js @@ -13,7 +13,7 @@ module.exports = (req, res, err) => { errors: err.errors, trace: req.headers['x-cloud-trace-context'] || null, }) - } catch (error) { + } catch (_error) { return res.sendStatus(500) } } diff --git a/src/utils/response/internalServerError.js b/src/utils/response/internalServerError.js index 26b48801..b99adcf2 100644 --- a/src/utils/response/internalServerError.js +++ b/src/utils/response/internalServerError.js @@ -11,7 +11,7 @@ module.exports = (req, res) => { message: 'Internal Server Error', trace: req.headers['x-cloud-trace-context'] || null, }) - } catch (error) { + } catch (_error) { return res.sendStatus(500) } } diff --git a/src/utils/response/notFound.js b/src/utils/response/notFound.js index 2cd42091..729739b8 100644 --- a/src/utils/response/notFound.js +++ b/src/utils/response/notFound.js @@ -13,7 +13,7 @@ module.exports = (req, res, err) => { errors: err.errors, trace: req.headers['x-cloud-trace-context'] || null, }) - } catch (error) { + } catch (_error) { return res.sendStatus(500) } } diff --git a/src/utils/response/ok.js b/src/utils/response/ok.js index 144beccb..9e7a476c 100644 --- a/src/utils/response/ok.js +++ b/src/utils/response/ok.js @@ -11,7 +11,7 @@ module.exports = (req, res, data, status) => { ...data, trace: req.headers['x-cloud-trace-context'] || null, }) - } catch (error) { + } catch (_error) { return res.sendStatus(500) } } diff --git a/src/utils/secrets/get.js b/src/utils/secrets/get.js index dccfa690..2cf91d7b 100644 --- a/src/utils/secrets/get.js +++ b/src/utils/secrets/get.js @@ -20,7 +20,7 @@ module.exports = async (name) => { let json = null try { json = JSON.parse(payload) - } catch (error) { + } catch (_error) { // do nothing }