Skip to content

Commit

Permalink
Merge pull request #1107 from myrotvorets/renovate/linters
Browse files Browse the repository at this point in the history
chore(deps): update dependency @myrotvorets/eslint-config-myrotvorets-ts to ^2.22.4
  • Loading branch information
myrotvorets-team authored Oct 13, 2023
2 parents 43a92f3 + dc9a1d3 commit 5359596
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 156 deletions.
116 changes: 4 additions & 112 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"@myrotvorets/oav-installer": "^4.1.0",
"@myrotvorets/opentelemetry-configurator": "^6.4.1",
"@myrotvorets/opentelemetry-plugin-knex": "^0.30.0",
"@opentelemetry/instrumentation-express": "^0.33.1",
"@opentelemetry/instrumentation-http": "^0.44.0",
"@opentelemetry/instrumentation-mysql2": "^0.34.1",
"envalid": "^8.0.0",
"express": "^4.18.2",
"express-openapi-validator": "^5.0.6",
Expand All @@ -40,7 +37,7 @@
"objection": "^3.1.2"
},
"devDependencies": {
"@myrotvorets/eslint-config-myrotvorets-ts": "^2.21.0",
"@myrotvorets/eslint-config-myrotvorets-ts": "^2.22.4",
"@myrotvorets/fake-knex-client": "^1.1.0",
"@types/chai": "^4.3.8",
"@types/chai-as-promised": "^7.1.6",
Expand Down
16 changes: 2 additions & 14 deletions src/lib/tracing.mts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
/* c8 ignore start */
import { OpenTelemetryConfigurator } from '@myrotvorets/opentelemetry-configurator';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2';
import { OpenTelemetryConfigurator, getExpressInstrumentations } from '@myrotvorets/opentelemetry-configurator';
import { KnexInstrumentation } from '@myrotvorets/opentelemetry-plugin-knex';

if (!+(process.env.ENABLE_TRACING || 0)) {
process.env.OTEL_SDK_DISABLED = 'true';
}

const configurator = new OpenTelemetryConfigurator({
serviceName: 'psb-api-identigraf-decoder',
instrumentations: [
new ExpressInstrumentation(),
new HttpInstrumentation(),
new KnexInstrumentation(),
new MySQL2Instrumentation(),
],
instrumentations: [...getExpressInstrumentations(), new KnexInstrumentation()],
});

configurator.start();
Expand Down
2 changes: 1 addition & 1 deletion src/models/criminal.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Criminal extends Model {
public address!: string;
public description!: string;

public static tableName = 'criminals';
public static override tableName = 'criminals';

public get link(): string {
return `https://myrotvorets.center/criminal/${this.slug}/`;
Expand Down
4 changes: 2 additions & 2 deletions src/models/criminalattachment.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export class CriminalAttachment extends Model {
public path!: string;
public mime_type!: string;

public static tableName = 'criminal_attachments';
public static override tableName = 'criminal_attachments';

public get link(): string {
return `https://cdn.myrotvorets.center/m/${this.path}`;
}

public static modifiers: Modifiers<QueryBuilder<Model>> = {
public static override modifiers: Modifiers<QueryBuilder<CriminalAttachment>> = {
findImages(builder): QueryBuilder<Model> {
return builder.where('mime_type', 'LIKE', 'image/%');
},
Expand Down
7 changes: 4 additions & 3 deletions src/services/decoder.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface DecodedItem {
export type QueueItem = [criminalID: number, attachmentID: number, item: string];
export type Queue = Record<number, QueueItem[]>;

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class DecoderService {
public static decode(items: Readonly<string[]>): Promise<Record<string, DecodedItem>> {
const v1OIDs = items.filter((item) => item.startsWith('!1-'));
Expand All @@ -31,11 +32,11 @@ export class DecoderService {

if (parts.length === 4) {
const [, typeID, criminalID, attachmentID] = parts;
if (accumulator[typeID] === undefined) {
accumulator[typeID] = [];
if (accumulator[typeID!] === undefined) {
accumulator[typeID!] = [];
}

accumulator[typeID].push([criminalID, attachmentID, item]);
accumulator[typeID!]!.push([criminalID!, attachmentID!, item]);
}

return accumulator;
Expand Down
5 changes: 2 additions & 3 deletions test/functional/controllers/monitoring.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import request from 'supertest';
import * as knexpkg from 'knex';
import mockKnex from 'mock-knex';
import { FakeClient } from '@myrotvorets/fake-knex-client';
import type { HealthChecker } from '@cloudnative/health-connect';
import { healthChecker, monitoringController } from '../../../src/controllers/monitoring.mjs';

describe('MonitoringController', function () {
Expand All @@ -24,7 +23,7 @@ describe('MonitoringController', function () {

beforeEach(function () {
expect(healthChecker).not.to.be.undefined;
(healthChecker as HealthChecker).shutdownRequested = false;
healthChecker!.shutdownRequested = false;
});

after(function () {
Expand All @@ -41,7 +40,7 @@ describe('MonitoringController', function () {
request(app).get(`/monitoring/${endpoint}`).expect('Content-Type', /json/u).expect(200);

const checker503 = (endpoint: string): Promise<unknown> => {
(healthChecker as HealthChecker).shutdownRequested = true;
healthChecker!.shutdownRequested = true;
return request(app).get(`/monitoring/${endpoint}`).expect('Content-Type', /json/u).expect(503);
};

Expand Down
11 changes: 7 additions & 4 deletions test/helpers.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ export function decodeMyrotvoretsQueryHandler(query: QueryDetails, step: number)
expect(query.transacting).to.be.true;

if (query.sql.includes('from `criminals`')) {
return query.response(criminalsResponse);
query.response(criminalsResponse);
return;
}

if (query.sql.includes('FIRST_VALUE(att_id)')) {
return query.response(primaryPhotosResponse);
query.response(primaryPhotosResponse);
return;
}

return query.response(photosResponse);
query.response(photosResponse);
return;
}

return query.response([]);
query.response([]);
}
2 changes: 1 addition & 1 deletion test/integration/controller/decode.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('DecodeController (integration)', function () {
let db: Knex | undefined = undefined;

before(async function () {
if (!process.env.RUN_INTEGRATION_TESTS) {
if (!process.env['RUN_INTEGRATION_TESTS']) {
this.skip();
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/controller/monitoring.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('MonitoringController (integration)', function () {
let db: Knex | undefined = undefined;

before(function () {
if (!process.env.RUN_INTEGRATION_TESTS) {
if (!process.env['RUN_INTEGRATION_TESTS']) {
this.skip();
}

Expand Down
2 changes: 1 addition & 1 deletion test/migrate.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ try {
process.stdout.write('Creating tables\n');
await db.migrate.latest();

if (process.env.SEED_TABLES === 'yes') {
if (process.env['SEED_TABLES'] === 'yes') {
process.stdout.write('Populating tables\n');
await db.seed.run();
}
Expand Down
4 changes: 2 additions & 2 deletions test/migrations/2020071914070000_criminals.mts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export async function up(knex: Knex): Promise<void> {
}

export async function down(knex: Knex): Promise<void> {
if (process.env.NODE_ENV !== 'test') {
throw new Error(`Refusing to run this in the ${process.env.NODE_ENV} environment`);
if (process.env['NODE_ENV'] !== 'test') {
throw new Error(`Refusing to run this in the ${process.env['NODE_ENV']} environment`);
}

await knex.schema.dropTableIfExists('criminals');
Expand Down
4 changes: 2 additions & 2 deletions test/migrations/2020071914090000_criminal_attachments.mts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export async function up(knex: Knex): Promise<void> {
}

export async function down(knex: Knex): Promise<void> {
if (process.env.NODE_ENV !== 'test') {
throw new Error(`Refusing to run this in the ${process.env.NODE_ENV} environment`);
if (process.env['NODE_ENV'] !== 'test') {
throw new Error(`Refusing to run this in the ${process.env['NODE_ENV']} environment`);
}

await knex.schema.dropTableIfExists('criminal_attachments');
Expand Down
4 changes: 2 additions & 2 deletions test/seeds/0000_criminals.mts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const seedData = [
];

export async function seed(knex: Knex): Promise<void> {
if (!['test', 'development'].includes(process.env.NODE_ENV || '')) {
throw new Error(`Refusing to run this in ${process.env.NODE_ENV} environment`);
if (!['test', 'development'].includes(process.env['NODE_ENV'] ?? '')) {
throw new Error(`Refusing to run this in ${process.env['NODE_ENV']} environment`);
}

await knex('criminals').del();
Expand Down
4 changes: 2 additions & 2 deletions test/seeds/0001_criminal_attachments.mts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ const seedData = [
];

export async function seed(knex: Knex): Promise<void> {
if (!['test', 'development'].includes(process.env.NODE_ENV || '')) {
throw new Error(`Refusing to run this in ${process.env.NODE_ENV} environment`);
if (!['test', 'development'].includes(process.env['NODE_ENV'] ?? '')) {
throw new Error(`Refusing to run this in ${process.env['NODE_ENV']} environment`);
}

await knex('criminal_attachments').del();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/services/decoder.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { decodeMyrotvoretsResult } from '../../fixtures/results.mjs';
import { decodeMyrotvoretsQueryHandler } from '../../helpers.mjs';

class MyDecoderService extends DecoderService {
public static prepareV1Items(items: Readonly<string[]>, queue: Readonly<Queue>): Queue {
public static override prepareV1Items(items: Readonly<string[]>, queue: Readonly<Queue>): Queue {
return DecoderService.prepareV1Items(items, queue);
}

public static decodeMyrotvorets(items?: QueueItem[]): Promise<Record<string, DecodedItem>> {
public static override decodeMyrotvorets(items?: QueueItem[]): Promise<Record<string, DecodedItem>> {
return DecoderService.decodeMyrotvorets(items);
}
}
Expand Down

0 comments on commit 5359596

Please sign in to comment.