refactor: expose upcoming-events public api and guard its boundary (WealthLedger/backend#163) #164
+23
-15
@@ -15,6 +15,18 @@ import globals from 'globals';
|
|||||||
import tseslint from 'typescript-eslint';
|
import tseslint from 'typescript-eslint';
|
||||||
|
|
||||||
const tests = ['**/*.spec.ts', 'test/**/*.ts'];
|
const tests = ['**/*.spec.ts', 'test/**/*.ts'];
|
||||||
|
const guardedModules = [
|
||||||
|
{
|
||||||
|
name: 'tbank-sync',
|
||||||
|
except: [
|
||||||
|
'./tbank-sync.api.ts',
|
||||||
|
'./tbank-sync.dto.ts',
|
||||||
|
'./tbank-sync.module.ts',
|
||||||
|
'./tbank-sync-repository.module.ts',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ name: 'upcoming-events', except: ['./upcoming-events.api.ts', './upcoming-events.module.ts'] },
|
||||||
|
];
|
||||||
const prismaImports = [
|
const prismaImports = [
|
||||||
'@prisma/*', '**/generated/prisma/**', '**/prisma.service',
|
'@prisma/*', '**/generated/prisma/**', '**/prisma.service',
|
||||||
];
|
];
|
||||||
@@ -212,24 +224,20 @@ export default defineConfig(
|
|||||||
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
// Separate rule so it does not replace layer-specific no-restricted-imports configs.
|
||||||
files: ['src/**/*.ts'],
|
// A module may import its own internals, so each guarded module gets a block without its zone.
|
||||||
ignores: [...tests, 'src/modules/investments/tbank-sync/**'],
|
...[undefined, ...guardedModules].map((own) => ({
|
||||||
|
files: own ? [`src/modules/investments/${own.name}/**/*.ts`] : ['src/**/*.ts'],
|
||||||
|
ignores: own ? tests : [...tests, ...guardedModules.map(({ name }) => `src/modules/investments/${name}/**`)],
|
||||||
rules: {
|
rules: {
|
||||||
// Separate rule so it does not replace layer-specific no-restricted-imports configs.
|
|
||||||
'import-x/no-restricted-paths': ['error', {
|
'import-x/no-restricted-paths': ['error', {
|
||||||
zones: [{
|
zones: guardedModules.filter((module) => module !== own).map(({ except, name }) => ({
|
||||||
target: './src',
|
target: './src',
|
||||||
from: './src/modules/investments/tbank-sync',
|
from: `./src/modules/investments/${name}`,
|
||||||
except: [
|
except,
|
||||||
'./tbank-sync.api.ts',
|
message: `Use ${name}.api for cross-module access.`,
|
||||||
'./tbank-sync.dto.ts',
|
})),
|
||||||
'./tbank-sync.module.ts',
|
|
||||||
'./tbank-sync-repository.module.ts',
|
|
||||||
],
|
|
||||||
message: 'Use tbank-sync.api for cross-module access.',
|
|
||||||
}],
|
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
},
|
})),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
import { PrismaService } from '../../../prisma/prisma.service';
|
import { PrismaService } from '../../../prisma/prisma.service';
|
||||||
import { BrokerageOperationsSyncService } from '../operations/operations.api';
|
import { BrokerageOperationsSyncService } from '../operations/operations.api';
|
||||||
import { PortfolioService } from '../portfolio/portfolio.api';
|
import { PortfolioService } from '../portfolio/portfolio.api';
|
||||||
import { UpcomingEventsService } from '../upcoming-events/upcoming-events.service';
|
import { UpcomingEventsService } from '../upcoming-events/upcoming-events.api';
|
||||||
import {
|
import {
|
||||||
HOURLY_CAUSE_INTERRUPTED,
|
HOURLY_CAUSE_INTERRUPTED,
|
||||||
type HourlyCause,
|
type HourlyCause,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export { EventsErrorCode, UpcomingEventsService } from './upcoming-events.service';
|
||||||
+1
-1
@@ -10,7 +10,7 @@ import { BankErrorCode } from './modules/banking/bank-cards/application/bank-car
|
|||||||
import { IncomeErrorCode } from './modules/investments/income/income-period';
|
import { IncomeErrorCode } from './modules/investments/income/income-period';
|
||||||
import { InstrumentErrorCode } from './modules/investments/instruments/domain/instrument-error-code';
|
import { InstrumentErrorCode } from './modules/investments/instruments/domain/instrument-error-code';
|
||||||
import { OperationErrorCode } from './modules/investments/operations/domain/operation-error-code';
|
import { OperationErrorCode } from './modules/investments/operations/domain/operation-error-code';
|
||||||
import { EventsErrorCode } from './modules/investments/upcoming-events/upcoming-events.service';
|
import { EventsErrorCode } from './modules/investments/upcoming-events/upcoming-events.api';
|
||||||
|
|
||||||
export const API_PREFIX = 'api/v1';
|
export const API_PREFIX = 'api/v1';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user