fix(workflow): Update Gitea workflow paths and dependencies

This commit is contained in:
Philipp Kunz 2025-02-03 23:41:13 +01:00
parent 8e4d3b7565
commit 9150e8c5fc
12 changed files with 8494 additions and 3548 deletions

View File

@ -6,8 +6,8 @@ on:
- '**' - '**'
env: env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}} NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}} NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}} NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
@ -26,7 +26,7 @@ jobs:
- name: Install pnpm and npmci - name: Install pnpm and npmci
run: | run: |
pnpm install -g pnpm pnpm install -g pnpm
pnpm install -g @shipzone/npmci pnpm install -g @ship.zone/npmci
- name: Run npm prepare - name: Run npm prepare
run: npmci npm prepare run: npmci npm prepare

View File

@ -6,8 +6,8 @@ on:
- '*' - '*'
env: env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}} NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}} NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}} NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
@ -26,7 +26,7 @@ jobs:
- name: Prepare - name: Prepare
run: | run: |
pnpm install -g pnpm pnpm install -g pnpm
pnpm install -g @shipzone/npmci pnpm install -g @ship.zone/npmci
npmci npm prepare npmci npm prepare
- name: Audit production dependencies - name: Audit production dependencies
@ -54,7 +54,7 @@ jobs:
- name: Prepare - name: Prepare
run: | run: |
pnpm install -g pnpm pnpm install -g pnpm
pnpm install -g @shipzone/npmci pnpm install -g @ship.zone/npmci
npmci npm prepare npmci npm prepare
- name: Test stable - name: Test stable
@ -82,7 +82,7 @@ jobs:
- name: Prepare - name: Prepare
run: | run: |
pnpm install -g pnpm pnpm install -g pnpm
pnpm install -g @shipzone/npmci pnpm install -g @ship.zone/npmci
npmci npm prepare npmci npm prepare
- name: Release - name: Release
@ -104,7 +104,7 @@ jobs:
- name: Prepare - name: Prepare
run: | run: |
pnpm install -g pnpm pnpm install -g pnpm
pnpm install -g @shipzone/npmci pnpm install -g @ship.zone/npmci
npmci npm prepare npmci npm prepare
- name: Code quality - name: Code quality
@ -119,6 +119,6 @@ jobs:
run: | run: |
npmci node install stable npmci node install stable
npmci npm install npmci npm install
pnpm install -g @gitzone/tsdoc pnpm install -g @git.zone/tsdoc
npmci command tsdoc npmci command tsdoc
continue-on-error: true continue-on-error: true

3
.gitignore vendored
View File

@ -3,7 +3,6 @@
# artifacts # artifacts
coverage/ coverage/
public/ public/
pages/
# installs # installs
node_modules/ node_modules/
@ -17,4 +16,4 @@ node_modules/
dist/ dist/
dist_*/ dist_*/
# custom #------# custom

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 2025-02-03 - 3.1.1 - fix(workflow)
Update Gitea workflow paths and dependencies
- Updated registry paths for npmci image and repositories in Gitea workflow files.
- Fixed dependency paths in package.json.
- Completed adding typescript to the list of devDependencies.
## 2024-10-07 - 3.1.0 - feat(NetworkProxy) ## 2024-10-07 - 3.1.0 - feat(NetworkProxy)
Introduce WebSocket heartbeat to maintain active connections in NetworkProxy Introduce WebSocket heartbeat to maintain active connections in NetworkProxy

View File

@ -15,21 +15,22 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.66", "@git.zone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44", "@git.zone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77", "@git.zone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.12", "@push.rocks/tapbundle": "^5.5.6",
"@types/node": "^20.4.5" "@types/node": "^22.13.0",
"typescript": "^5.7.3"
}, },
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.0.3", "@push.rocks/lik": "^6.1.0",
"@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartpromise": "^4.0.3", "@push.rocks/smartpromise": "^4.2.2",
"@push.rocks/smartrequest": "^2.0.18", "@push.rocks/smartrequest": "^2.0.23",
"@push.rocks/smartstring": "^4.0.7", "@push.rocks/smartstring": "^4.0.15",
"@tsclass/tsclass": "^4.0.42", "@tsclass/tsclass": "^4.4.0",
"@types/ws": "^8.5.5", "@types/ws": "^8.5.14",
"ws": "^8.13.0" "ws": "^8.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -59,9 +60,15 @@
"reverse proxy", "reverse proxy",
"authentication" "authentication"
], ],
"homepage": "https://code.foss.global/push.rocks/smartproxy", "homepage": "https://code.foss.global/push.rocks/smartproxy#readme",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://code.foss.global/push.rocks/smartproxy.git" "url": "https://code.foss.global/push.rocks/smartproxy.git"
},
"bugs": {
"url": "https://code.foss.global/push.rocks/smartproxy/issues"
},
"pnpm": {
"overrides": {}
} }
} }

11631
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,9 @@
# @push.rocks/smartproxy # @push.rocks/smartproxy
A proxy for handling high workloads of proxying. A proxy for handling high workloads of proxying.
## Install ## Install
To install `@push.rocks/smartproxy`, run the following command in your project's root directory: To install `@push.rocks/smartproxy`, run the following command in your project's root directory:
```bash ```bash
@ -100,7 +102,7 @@ For more information on how to use the features, refer to the in-depth documenta
## License and Legal Information ## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

View File

@ -0,0 +1,83 @@
export const testCertificates = {
privateKey: `-----BEGIN PRIVATE KEY-----
MIIJRQIBADANBgkqhkiG9w0BAQEFAASCCS8wggkrAgEAAoICAQDi2F/0kQr96mhe
3yEWvy2mRHOZoSSBtIqg6Bre4ZcMu901/cHNIjFnynNGFl9Se61yZbW2F3PfCt7+
kQlHug1Cx+LFssvz+hLlB5cqJQZfRKx92DhbROygtxG9r7UBmx/fwx+JQ+HOHX9R
b+szLBZqxrNDBFl2SRdviconYgVnHbaqcAPj/lK6D6x94qgUEX+vMjbIruuiCe3u
RbYse/quzAednVnY/+BuGVn8SEb2EVVFnBEsOxxYpy5ZzGR48O3YnWkM2oPpJhrp
mMYLcARMnDmIQDVstD1i+MM2lVhx/pm9xKKUgWNJC7lyz2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UJTrcfZ0gGhGkF4nYLmX5OI+TPqrDJf0fZ+mzAEHzDDVXcBYpYRDr
r8d9QwrK+WaqVi2ofbMfMByVF72jgeJNa4nxwT9bVbu/Q1T2Lt+YPb4pQ7yCoUgS
JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
-----END CERTIFICATE-----
`,
};

View File

@ -1,115 +1,168 @@
import { expect, tap } from '@push.rocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as smartproxy from '../ts/index.js'; import * as smartproxy from '../ts/index.js';
import { testCertificates } from './helpers/certificates.js';
import * as https from 'https';
import * as http from 'http';
import { WebSocket, WebSocketServer } from 'ws';
let testProxy: smartproxy.NetworkProxy; let testProxy: smartproxy.NetworkProxy;
let testServer: http.Server;
let wsServer: WebSocketServer;
tap.test('first test', async () => { // Helper function to make HTTPS requests
async function makeHttpsRequest(
options: https.RequestOptions,
): Promise<{ statusCode: number; headers: http.IncomingHttpHeaders; body: string }> {
return new Promise((resolve, reject) => {
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => (data += chunk));
res.on('end', () =>
resolve({
statusCode: res.statusCode!,
headers: res.headers,
body: data,
}),
);
});
req.on('error', reject);
req.end();
});
}
// Setup test environment
tap.test('setup test environment', async () => {
// Create a test HTTP server
testServer = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello from test server!');
});
// Create a WebSocket server
wsServer = new WebSocketServer({ noServer: true });
wsServer.on('connection', (ws) => {
ws.on('message', (message) => {
ws.send('Echo: ' + message);
});
});
// Handle upgrade requests
testServer.on('upgrade', (request, socket, head) => {
wsServer.handleUpgrade(request, socket, head, (ws) => {
wsServer.emit('connection', ws, request);
});
});
await new Promise<void>((resolve) => testServer.listen(3000, resolve));
});
tap.test('should create proxy instance', async () => {
testProxy = new smartproxy.NetworkProxy({ testProxy = new smartproxy.NetworkProxy({
port: 3001, port: 3001,
}); });
expect(testProxy).toBeInstanceOf(smartproxy.NetworkProxy); expect(testProxy).toEqual(testProxy); // Instance equality check
}); });
tap.test('should start the testproxy', async () => { tap.test('should start the proxy server', async () => {
await testProxy.start(); await testProxy.start();
});
tap.test('should supply reverse proxy config', async () => { // Configure proxy with test certificates
testProxy.updateProxyConfigs([ testProxy.updateProxyConfigs([
{ {
destinationIp: '127.0.0.1', destinationIp: '127.0.0.1',
destinationPort: '3000', destinationPort: '3000',
hostName: 'push.rocks', hostName: 'push.rocks',
privateKey: `-----BEGIN PRIVATE KEY----- publicKey: testCertificates.publicKey,
MIIJRQIBADANBgkqhkiG9w0BAQEFAASCCS8wggkrAgEAAoICAQDi2F/0kQr96mhe privateKey: testCertificates.privateKey,
3yEWvy2mRHOZoSSBtIqg6Bre4ZcMu901/cHNIjFnynNGFl9Se61yZbW2F3PfCt7+
kQlHug1Cx+LFssvz+hLlB5cqJQZfRKx92DhbROygtxG9r7UBmx/fwx+JQ+HOHX9R
b+szLBZqxrNDBFl2SRdviconYgVnHbaqcAPj/lK6D6x94qgUEX+vMjbIruuiCe3u
RbYse/quzAednVnY/+BuGVn8SEb2EVVFnBEsOxxYpy5ZzGR48O3YnWkM2oPpJhrp
mMYLcARMnDmIQDVstD1i+MM2lVhx/pm9xKKUgWNJC7lyz2xRscZ4pOtLkfN94leH
U98nIvxfQe7tQFKN9K52yjdtoT0UaIEUFbZyddkoNka1Xx6r+rE96046BLT2lVs0
/rnTxZUFH6vP3z9UNktmpxtnZSk67Pj6QAqZtgT0amXEpBlk7vBYSjHsyJ3+5R1y
oSjhAqeejq6M67NDOflrag5LSTkeTe4dqk0laVb1gjcse18AOlgf7pw5H79zclYH
NAnoAPua683MD2ZZd4eovEww/imSZvui3NlisSSh1SomABDFxiEaHpewI98n8P1E
3vfg4lyCV5VcUjwrPjnkfEJbX1c1/PXqTtPqSqFn/pI4FuTES6qDugS2EA/XT1ln
ODHigOiFCzDbhOMuQjhI8hzuevrRRQIDAQABAoICAQC7nU+HW6qmpQebZ5nbUVT1
Deo6Js+lwudg+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fJ/D9RN734OJc
gleVXFI8Kz455HxCW19XNfz16k7T6kqhZ/6SOBbkxEuqg7oEthAP109ZZzgx4oDo
hQsw24TjLkI4SPIc7nr60UUCAwEAATANBgkqhkiG9w0BAQsFAAOCAgEAu0+zrg0C
mlSv4Yi24OwB7TBvx+WHesl1IilCUdTiiUMo3NumvsU9Dr3Jkd0jGqYI0eyH4gIt
KrhAveXfEw7tAOEHiYicmAdIFtyzh++ZWb8mgbBeqij1MP/76Jv+cc0lUqpfRo/A
qytAsPAILuyL1o1jh28JHcq+v+WYn/FEhjUlH6emhGKGlsAjhUPjzK8MEshNolhj
t2UXw9WB5B2xWvrqlNMy0F3NAZBkZ/+k21HZo6FmVi+q6OEGcOo7wJt6wrH/lko9
LxX96GC1JoN1Pfr2FoTKy1WHzrSfyGmDIUCrbaYQ58UuMOR+5eIPPdkf/030u5eX
xXhF2fBujD57E2zQGh/l2MrOjamcSo0+wYhOqlX3WNdaKNAzPqloBnF6w7eqLYde
h9He39ySmxjENwv3miOjEP1sBeMBSRfL/ckEonfK5uJgYA5nVMQ3ojUeDMZzLfFE
Ue2WHt+uPyYk7mMZfOrK2uHzI2/Coqj7lbfRodFwj+fCArYBck2NZannDPKA6X8V
TzJTbTCteOUUJTrcfZ0gGhGkF4nYLmX5OI+TPqrDJf0fZ+mzAEHzDDVXcBYpYRDr
r8d9QwrK+WaqVi2ofbMfMByVF72jgeJNa4nxwT9bVbu/Q1T2Lt+YPb4pQ7yCoUgS
JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
-----END CERTIFICATE-----
`,
}, },
]); ]);
}); });
tap.test('should wait for 60 seconds', async (tools) => { tap.test('should route HTTPS requests based on host header', async () => {
await tools.delayFor(10000); const response = await makeHttpsRequest({
hostname: 'push.rocks',
port: 3001,
path: '/',
method: 'GET',
rejectUnauthorized: false,
});
expect(response.statusCode).toEqual(200);
expect(response.body).toEqual('Hello from test server!');
}); });
tap.test('should close the testproxy', async () => { tap.test('should handle unknown host headers', async () => {
const response = await makeHttpsRequest({
hostname: 'unknown.host',
port: 3001,
path: '/',
method: 'GET',
rejectUnauthorized: false,
}).catch((e) => e);
expect(response instanceof Error).toEqual(true);
});
tap.test('should support WebSocket connections', async () => {
return new Promise<void>((resolve, reject) => {
console.log('Starting WebSocket test...');
const ws = new WebSocket('wss://localhost:3001', {
rejectUnauthorized: false,
headers: {
'Host': 'push.rocks'
}
});
const timeout = setTimeout(() => {
ws.close();
reject(new Error('WebSocket test timed out after 5 seconds'));
}, 5000);
ws.on('open', () => {
console.log('WebSocket connection opened');
ws.send('Hello WebSocket');
});
ws.on('message', (data) => {
console.log('Received message:', data.toString());
expect(data.toString()).toEqual('Echo: Hello WebSocket');
clearTimeout(timeout);
ws.close();
resolve();
});
ws.on('error', (err) => {
console.error('WebSocket error:', err);
clearTimeout(timeout);
reject(err);
});
ws.on('close', () => {
console.log('WebSocket connection closed');
});
});
});
tap.test('should handle custom headers', async () => {
testProxy.addDefaultHeaders({
'X-Proxy-Header': 'test-value',
});
const response = await makeHttpsRequest({
hostname: 'push.rocks',
port: 3001,
path: '/',
method: 'GET',
rejectUnauthorized: false,
});
expect(response.headers['x-proxy-header']).toEqual('test-value');
});
tap.test('cleanup', async () => {
// Clean up all servers
await new Promise<void>((resolve) => wsServer.close(() => resolve()));
await new Promise<void>((resolve) => testServer.close(() => resolve()));
await testProxy.stop(); await testProxy.stop();
}); });

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartproxy', name: '@push.rocks/smartproxy',
version: '3.1.0', version: '3.1.1',
description: 'a proxy for handling high workloads of proxying' description: 'a proxy for handling high workloads of proxying'
} }

View File

@ -129,7 +129,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
const endOriginReqRes = ( const endOriginReqRes = (
statusArg: number = 404, statusArg: number = 404,
messageArg: string = 'This route is not available on this server.', messageArg: string = 'This route is not available on this server.',
headers: plugins.http.OutgoingHttpHeaders = {} headers: plugins.http.OutgoingHttpHeaders = {},
) => { ) => {
originResponse.writeHead(statusArg, messageArg); originResponse.writeHead(statusArg, messageArg);
originResponse.end(messageArg); originResponse.end(messageArg);
@ -140,13 +140,13 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
}; };
console.log( console.log(
`got request: ${originRequest.headers.host}${plugins.url.parse(originRequest.url).path}` `got request: ${originRequest.headers.host}${plugins.url.parse(originRequest.url).path}`,
); );
const destinationConfig = this.router.routeReq(originRequest); const destinationConfig = this.router.routeReq(originRequest);
if (!destinationConfig) { if (!destinationConfig) {
console.log( console.log(
`${originRequest.headers.host} can't be routed properly. Terminating request.` `${originRequest.headers.host} can't be routed properly. Terminating request.`,
); );
endOriginReqRes(); endOriginReqRes();
return; return;
@ -179,7 +179,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
default: default:
return endOriginReqRes( return endOriginReqRes(
403, 403,
'Forbidden: unsupported authentication method configured. Please report to the admin.' 'Forbidden: unsupported authentication method configured. Please report to the admin.',
); );
} }
} }
@ -224,7 +224,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
proxyRequest.on('error', () => { proxyRequest.on('error', () => {
endOriginReqRes(); endOriginReqRes();
}); });
} },
); );
originResponse.statusCode = proxyResponse.statusCode; originResponse.statusCode = proxyResponse.statusCode;
console.log(proxyResponse.statusCode); console.log(proxyResponse.statusCode);
@ -254,7 +254,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
console.error('Error while processing request:', error); console.error('Error while processing request:', error);
endOriginReqRes(502, 'Bad Gateway: Error processing the request'); endOriginReqRes(502, 'Bad Gateway: Error processing the request');
} }
} },
); );
// Enable websockets // Enable websockets
@ -280,7 +280,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
'connection', 'connection',
async (wsIncoming: WebSocketWithHeartbeat, reqArg: plugins.http.IncomingMessage) => { async (wsIncoming: WebSocketWithHeartbeat, reqArg: plugins.http.IncomingMessage) => {
console.log( console.log(
`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}` `wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`,
); );
wsIncoming.lastPong = Date.now(); wsIncoming.lastPong = Date.now();
@ -296,7 +296,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
wsOutgoing = new plugins.wsDefault( wsOutgoing = new plugins.wsDefault(
`ws://${this.router.routeReq(reqArg).destinationIp}:${ `ws://${this.router.routeReq(reqArg).destinationIp}:${
this.router.routeReq(reqArg).destinationPort this.router.routeReq(reqArg).destinationPort
}${reqArg.url}` }${reqArg.url}`,
); );
console.log('wss proxy: initiated outgoing proxy'); console.log('wss proxy: initiated outgoing proxy');
wsOutgoing.on('open', async () => { wsOutgoing.on('open', async () => {
@ -342,7 +342,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
}; };
wsOutgoing.on('error', () => terminateWsIncoming()); wsOutgoing.on('error', () => terminateWsIncoming());
wsOutgoing.on('close', () => terminateWsIncoming()); wsOutgoing.on('close', () => terminateWsIncoming());
} },
); );
this.httpsServer.keepAliveTimeout = 600 * 1000; this.httpsServer.keepAliveTimeout = 600 * 1000;
@ -374,7 +374,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
this.httpsServer.listen(this.options.port); this.httpsServer.listen(this.options.port);
console.log( console.log(
`NetworkProxy -> OK: now listening for new connections on port ${this.options.port}` `NetworkProxy -> OK: now listening for new connections on port ${this.options.port}`,
); );
} }

View File

@ -6,9 +6,11 @@
"module": "NodeNext", "module": "NodeNext",
"moduleResolution": "NodeNext", "moduleResolution": "NodeNext",
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
}, },
"exclude": [ "exclude": [
"dist_*/**/*.d.ts" "dist_*/**/*.d.ts"
] ]
} }