BREAKING CHANGE(project-structure): Refactor project structure by updating import paths, removing legacy files, and adjusting test configurations

This commit is contained in:
2025-05-09 21:52:46 +00:00
parent b214e58a26
commit 88c75d9cc2
20 changed files with 568 additions and 226 deletions

View File

@ -1,12 +1,12 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as plugins from '../ts/plugins.js';
import type { IForwardConfig, ForwardingType } from '../ts/smartproxy/types/forwarding.types.js';
import type { ForwardConfig, ForwardingType } from '../ts/forwarding/config/forwarding-types.js';
// First, import the components directly to avoid issues with compiled modules
import { ForwardingHandlerFactory } from '../ts/smartproxy/forwarding/forwarding.factory.js';
import { createDomainConfig } from '../ts/smartproxy/forwarding/domain-config.js';
import { DomainManager } from '../ts/smartproxy/forwarding/domain-manager.js';
import { httpOnly, tlsTerminateToHttp, tlsTerminateToHttps, httpsPassthrough } from '../ts/smartproxy/types/forwarding.types.js';
import { ForwardingHandlerFactory } from '../ts/forwarding/factory/forwarding-factory.js';
import { createDomainConfig } from '../ts/forwarding/config/domain-config.js';
import { DomainManager } from '../ts/forwarding/config/domain-manager.js';
import { httpOnly, tlsTerminateToHttp, tlsTerminateToHttps, httpsPassthrough } from '../ts/forwarding/config/forwarding-types.js';
const helpers = {
httpOnly,
@ -17,7 +17,7 @@ const helpers = {
tap.test('ForwardingHandlerFactory - apply defaults based on type', async () => {
// HTTP-only defaults
const httpConfig: IForwardConfig = {
const httpConfig: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 3000 }
};
@ -26,7 +26,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
expect(expandedHttpConfig.http?.enabled).toEqual(true);
// HTTPS-passthrough defaults
const passthroughConfig: IForwardConfig = {
const passthroughConfig: ForwardConfig = {
type: 'https-passthrough',
target: { host: 'localhost', port: 443 }
};
@ -36,7 +36,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
expect(expandedPassthroughConfig.http?.enabled).toEqual(false);
// HTTPS-terminate-to-http defaults
const terminateToHttpConfig: IForwardConfig = {
const terminateToHttpConfig: ForwardConfig = {
type: 'https-terminate-to-http',
target: { host: 'localhost', port: 3000 }
};
@ -48,7 +48,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
expect(expandedTerminateToHttpConfig.acme?.maintenance).toEqual(true);
// HTTPS-terminate-to-https defaults
const terminateToHttpsConfig: IForwardConfig = {
const terminateToHttpsConfig: ForwardConfig = {
type: 'https-terminate-to-https',
target: { host: 'localhost', port: 8443 }
};
@ -62,7 +62,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
tap.test('ForwardingHandlerFactory - validate configuration', async () => {
// Valid configuration
const validConfig: IForwardConfig = {
const validConfig: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 3000 }
};
@ -77,7 +77,7 @@ tap.test('ForwardingHandlerFactory - validate configuration', async () => {
expect(() => ForwardingHandlerFactory.validateConfig(invalidConfig1)).toThrow();
// Invalid configuration - invalid port
const invalidConfig2: IForwardConfig = {
const invalidConfig2: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 0 }
};
@ -85,7 +85,7 @@ tap.test('ForwardingHandlerFactory - validate configuration', async () => {
expect(() => ForwardingHandlerFactory.validateConfig(invalidConfig2)).toThrow();
// Invalid configuration - HTTP disabled for HTTP-only
const invalidConfig3: IForwardConfig = {
const invalidConfig3: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 3000 },
http: { enabled: false }
@ -94,7 +94,7 @@ tap.test('ForwardingHandlerFactory - validate configuration', async () => {
expect(() => ForwardingHandlerFactory.validateConfig(invalidConfig3)).toThrow();
// Invalid configuration - HTTP enabled for HTTPS passthrough
const invalidConfig4: IForwardConfig = {
const invalidConfig4: ForwardConfig = {
type: 'https-passthrough',
target: { host: 'localhost', port: 443 },
http: { enabled: true }