From 85c63f7828b791b63f429fe98b32a592fdd024b8 Mon Sep 17 00:00:00 2001 From: Ben Kiarie Date: Mon, 17 Feb 2025 10:58:10 +0300 Subject: [PATCH] chore: refactor file structure --- src/lib/{authentication/errors => }/authentication-error.ts | 0 src/lib/{authentication => }/authentication.ts | 2 +- src/lib/cht-session.ts | 2 +- src/lib/manage-hierarchy.ts | 2 +- src/routes/app.ts | 2 +- src/routes/authentication.ts | 4 ++-- src/server.ts | 2 +- src/worker/cht-conf-worker.ts | 2 +- test/integration/manage-hierarchy.spec.ts | 2 +- test/lib/authentication.spec.ts | 4 ++-- test/lib/cht-session.spec.ts | 2 +- test/lib/manage-hierarchy.spec.ts | 2 +- test/worker/cht-conf-worker.spec.ts | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) rename src/lib/{authentication/errors => }/authentication-error.ts (100%) rename src/lib/{authentication => }/authentication.ts (97%) diff --git a/src/lib/authentication/errors/authentication-error.ts b/src/lib/authentication-error.ts similarity index 100% rename from src/lib/authentication/errors/authentication-error.ts rename to src/lib/authentication-error.ts diff --git a/src/lib/authentication/authentication.ts b/src/lib/authentication.ts similarity index 97% rename from src/lib/authentication/authentication.ts rename to src/lib/authentication.ts index dbda6e17..c32c770a 100644 --- a/src/lib/authentication/authentication.ts +++ b/src/lib/authentication.ts @@ -1,6 +1,6 @@ import process from 'process'; import jwt from 'jsonwebtoken'; -import ChtSession from '../cht-session'; +import ChtSession from './cht-session'; const LOGIN_EXPIRES_AFTER_MS = 4 * 24 * 60 * 60 * 1000; const QUEUE_SESSION_EXPIRATION = '96h'; diff --git a/src/lib/cht-session.ts b/src/lib/cht-session.ts index 9d170d8b..e39ccd7e 100644 --- a/src/lib/cht-session.ts +++ b/src/lib/cht-session.ts @@ -4,7 +4,7 @@ import { AxiosHeaders, AxiosInstance } from 'axios'; import axiosRetry from 'axios-retry'; import * as semver from 'semver'; -import { AuthErrors } from './authentication/errors/authentication-error'; +import { AuthErrors } from './authentication-error'; import { AuthenticationInfo } from '../config'; import { axiosRetryConfig } from './retry-logic'; import { RemotePlace } from './remote-place-cache'; diff --git a/src/lib/manage-hierarchy.ts b/src/lib/manage-hierarchy.ts index 085b88aa..7dd0c148 100644 --- a/src/lib/manage-hierarchy.ts +++ b/src/lib/manage-hierarchy.ts @@ -1,7 +1,7 @@ import _ from 'lodash'; import { DateTime } from 'luxon'; -import Auth from './authentication/authentication'; +import Auth from './authentication'; import { ChtApi } from './cht-api'; import { ChtConfJobData } from '../worker/cht-conf-worker'; import { ContactType } from '../config'; diff --git a/src/routes/app.ts b/src/routes/app.ts index 4fffbc25..96411dd2 100644 --- a/src/routes/app.ts +++ b/src/routes/app.ts @@ -1,6 +1,6 @@ import { FastifyInstance } from 'fastify'; -import Auth from '../lib/authentication/authentication'; +import Auth from '../lib/authentication'; import { ChtApi } from '../lib/cht-api'; import { Config } from '../config'; import DirectiveModel from '../services/directive-model'; diff --git a/src/routes/authentication.ts b/src/routes/authentication.ts index dd8d5eab..6874c12a 100644 --- a/src/routes/authentication.ts +++ b/src/routes/authentication.ts @@ -1,7 +1,7 @@ import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; -import Auth from '../lib/authentication/authentication'; -import { AuthError, AuthErrors } from '../lib/authentication/errors/authentication-error'; +import Auth from '../lib/authentication'; +import { AuthError, AuthErrors } from '../lib/authentication-error'; import { Config } from '../config'; import { version as appVersion } from '../package.json'; import ChtSession from '../lib/cht-session'; diff --git a/src/server.ts b/src/server.ts index 36fb437e..75790858 100644 --- a/src/server.ts +++ b/src/server.ts @@ -11,7 +11,7 @@ import { FastifySSEPlugin } from 'fastify-sse-v2'; import path from 'path'; const metricsPlugin = require('fastify-metrics'); -import Auth from './lib/authentication/authentication'; +import Auth from './lib/authentication'; import SessionCache from './services/session-cache'; import { checkRedisConnection } from './config/config-worker'; diff --git a/src/worker/cht-conf-worker.ts b/src/worker/cht-conf-worker.ts index be2b1446..23f2b9e5 100644 --- a/src/worker/cht-conf-worker.ts +++ b/src/worker/cht-conf-worker.ts @@ -3,7 +3,7 @@ import { spawn } from 'child_process'; import { Worker, Job, DelayedError, ConnectionOptions, MinimalJob } from 'bullmq'; import { DateTime } from 'luxon'; -import Auth from '../lib/authentication/authentication'; +import Auth from '../lib/authentication'; import { HierarchyAction } from '../lib/manage-hierarchy'; export interface ChtConfJobData { diff --git a/test/integration/manage-hierarchy.spec.ts b/test/integration/manage-hierarchy.spec.ts index 1b86741d..f7ac0332 100644 --- a/test/integration/manage-hierarchy.spec.ts +++ b/test/integration/manage-hierarchy.spec.ts @@ -6,7 +6,7 @@ import sinon from 'sinon'; import MoveLib from '../../src/lib/manage-hierarchy'; -import Auth from '../../src/lib/authentication/authentication'; +import Auth from '../../src/lib/authentication'; import { Config } from '../../src/config'; import { BullQueue } from '../../src/lib/queues'; import { mockChtApi, mockChtSession } from '../mocks'; diff --git a/test/lib/authentication.spec.ts b/test/lib/authentication.spec.ts index 62b00284..47f60247 100644 --- a/test/lib/authentication.spec.ts +++ b/test/lib/authentication.spec.ts @@ -1,8 +1,8 @@ import chai from 'chai'; import chaiExclude from 'chai-exclude'; import { mockChtSession } from '../mocks'; -import Auth from '../../src/lib/authentication/authentication'; -import { AuthError, AuthErrors } from '../../src/lib/authentication/errors/authentication-error'; +import Auth from '../../src/lib/authentication'; +import { AuthError, AuthErrors } from '../../src/lib/authentication-error'; chai.use(chaiExclude); const { expect } = chai; diff --git a/test/lib/cht-session.spec.ts b/test/lib/cht-session.spec.ts index 9c3841b8..ad81af6c 100644 --- a/test/lib/cht-session.spec.ts +++ b/test/lib/cht-session.spec.ts @@ -4,7 +4,7 @@ import sinon from 'sinon'; import { AuthenticationInfo } from '../../src/config'; import { RemotePlace } from '../../src/lib/remote-place-cache'; -import { AuthError } from '../../src/lib/authentication/errors/authentication-error'; +import { AuthError } from '../../src/lib/authentication-error'; const ChtSession = rewire('../../src/lib/cht-session'); import chaiAsPromised from 'chai-as-promised'; diff --git a/test/lib/manage-hierarchy.spec.ts b/test/lib/manage-hierarchy.spec.ts index a71c65cb..bb668d49 100644 --- a/test/lib/manage-hierarchy.spec.ts +++ b/test/lib/manage-hierarchy.spec.ts @@ -3,7 +3,7 @@ import chaiAsPromised from 'chai-as-promised'; import { DateTime } from 'luxon'; import sinon from 'sinon'; -import Auth from '../../src/lib/authentication/authentication'; +import Auth from '../../src/lib/authentication'; import { Config } from '../../src/config'; import { JobParams } from '../../src/lib/queues'; import ManageHierarchyLib from '../../src/lib/manage-hierarchy'; diff --git a/test/worker/cht-conf-worker.spec.ts b/test/worker/cht-conf-worker.spec.ts index 0a211f67..6f76f64c 100644 --- a/test/worker/cht-conf-worker.spec.ts +++ b/test/worker/cht-conf-worker.spec.ts @@ -3,7 +3,7 @@ import Sinon from 'sinon'; import chaiAsPromised from 'chai-as-promised'; Chai.use(chaiAsPromised); -import Auth from '../../src/lib/authentication/authentication'; +import Auth from '../../src/lib/authentication'; import { ChtConfWorker } from '../../src/worker/cht-conf-worker'; import { HierarchyAction } from '../../src/lib/manage-hierarchy'; import { mockChtSession } from '../mocks';