fix(core): update
This commit is contained in:
commit
cf500f9197
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
112
.gitlab-ci.yml
Normal file
112
.gitlab-ci.yml
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
# gitzone ci_docker
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci-cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
- pages
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# release stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
release:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci docker login
|
||||||
|
- npmci docker build
|
||||||
|
- npmci docker test
|
||||||
|
- npmci docker push registry.gitlab.com
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@git.zone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@git.zone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# gitzone dockerfile_service
|
||||||
|
## STAGE 1 // BUILD
|
||||||
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as node1
|
||||||
|
COPY ./ /app
|
||||||
|
WORKDIR /app
|
||||||
|
ARG NPMCI_TOKEN_NPM2
|
||||||
|
ENV NPMCI_TOKEN_NPM2 $NPMCI_TOKEN_NPM2
|
||||||
|
RUN npmci npm prepare
|
||||||
|
RUN pnpm config set store-dir .pnpm-store
|
||||||
|
RUN rm -rf node_modules && pnpm install
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
|
# gitzone dockerfile_service
|
||||||
|
## STAGE 2 // install production
|
||||||
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as node2
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=node1 /app /app
|
||||||
|
RUN rm -rf .pnpm-store
|
||||||
|
ARG NPMCI_TOKEN_NPM2
|
||||||
|
ENV NPMCI_TOKEN_NPM2 $NPMCI_TOKEN_NPM2
|
||||||
|
RUN npmci npm prepare
|
||||||
|
RUN pnpm config set store-dir .pnpm-store
|
||||||
|
RUN rm -rf node_modules/ && pnpm install --prod
|
||||||
|
|
||||||
|
|
||||||
|
## STAGE 3 // rebuild dependencies for alpine
|
||||||
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpinenpmci as node3
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=node2 /app /app
|
||||||
|
ARG NPMCI_TOKEN_NPM2
|
||||||
|
ENV NPMCI_TOKEN_NPM2 $NPMCI_TOKEN_NPM2
|
||||||
|
RUN npmci npm prepare
|
||||||
|
RUN pnpm config set store-dir .pnpm-store
|
||||||
|
RUN pnpm rebuild -r
|
||||||
|
|
||||||
|
## STAGE 4 // the final production image with all dependencies in place
|
||||||
|
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine as node4
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=node3 /app /app
|
||||||
|
|
||||||
|
### Healthchecks
|
||||||
|
RUN pnpm install -g @servezone/healthy
|
||||||
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD [ "healthy" ]
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["npm", "start"]
|
4
cli.child.ts
Normal file
4
cli.child.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
import * as cliTool from './ts/index.js';
|
||||||
|
cliTool.runCli();
|
4
cli.js
Normal file
4
cli.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
const cliTool = await import('./dist_ts/index.js');
|
||||||
|
cliTool.runCli();
|
5
cli.ts.js
Normal file
5
cli.ts.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
|
||||||
|
import * as tsrun from '@git.zone/tsrun';
|
||||||
|
tsrun.runPath('./cli.child.js', import.meta.url);
|
28
npmextra.json
Normal file
28
npmextra.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"npmdocker": {
|
||||||
|
"baseImage": "hosttoday/ht-docker-node:npmci",
|
||||||
|
"command": "echo \"inside docker now\"",
|
||||||
|
"dockerSock": true
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "verdaccio.lossless.one",
|
||||||
|
"dockerRegistryRepoMap": {
|
||||||
|
"registry.gitlab.com": "losslessone/services/servezone/coretraffic"
|
||||||
|
},
|
||||||
|
"dockerBuildargEnvMap": {
|
||||||
|
"NPMCI_TOKEN_NPM2": "NPMCI_TOKEN_NPM2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "service",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "servezone/private",
|
||||||
|
"gitrepo": "coretraffic",
|
||||||
|
"shortDescription": "route traffic within your docker setup. TypeScript ready.",
|
||||||
|
"npmPackagename": "@servezone_private/coretraffic",
|
||||||
|
"license": "UNLICENSED"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
68
package.json
Normal file
68
package.json
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"name": "coretraffic",
|
||||||
|
"version": "1.0.183",
|
||||||
|
"description": "route traffic within your docker setup. TypeScript ready.",
|
||||||
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node --max_old_space_size=1000 cli.js",
|
||||||
|
"startTs": "node cli.ts.js",
|
||||||
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild --web --allowimplicitany)"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+ssh://git@gitlab.com/servezone/coretraffic.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"traffic"
|
||||||
|
],
|
||||||
|
"author": "Lossless GmbH",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://gitlab.com/servezone/coretraffic/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://gitlab.com/servezone/coretraffic#README",
|
||||||
|
"dependencies": {
|
||||||
|
"@api.global/typedrequest": "^3.0.23",
|
||||||
|
"@api.global/typedsocket": "^3.0.1",
|
||||||
|
"@losslessone_private/loint-cloudly": "^2.0.85",
|
||||||
|
"@losslessone_private/lole-log": "^2.0.16",
|
||||||
|
"@push.rocks/projectinfo": "^5.0.1",
|
||||||
|
"@push.rocks/qenv": "^6.0.5",
|
||||||
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
|
"@push.rocks/smartlog": "^3.0.3",
|
||||||
|
"@push.rocks/smartlog-destination-receiver": "^2.0.3",
|
||||||
|
"@push.rocks/smartpath": "^5.0.5",
|
||||||
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
|
"@push.rocks/smartproxy": "^3.0.58",
|
||||||
|
"@push.rocks/smartrequest": "^2.0.10",
|
||||||
|
"@push.rocks/smartshell": "^3.0.5",
|
||||||
|
"@push.rocks/smartstring": "^4.0.2",
|
||||||
|
"@push.rocks/taskbuffer": "^3.0.10"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@git.zone/tsbuild": "^2.1.65",
|
||||||
|
"@git.zone/tsrun": "^1.2.39",
|
||||||
|
"@git.zone/tstest": "^1.0.74",
|
||||||
|
"@push.rocks/tapbundle": "^5.0.4",
|
||||||
|
"@types/node": "^18.11.18"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
|
}
|
6409
pnpm-lock.yaml
generated
Normal file
6409
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
readme.md
Normal file
41
readme.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# @servezone/private/coretraffic
|
||||||
|
route traffic within your docker setup. TypeScript ready.
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@servezone_private/coretraffic)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/servezone/private/coretraffic)
|
||||||
|
* [github.com (source mirror)](https://github.com/servezone/private/coretraffic)
|
||||||
|
* [docs (typedoc)](https://servezone/private.gitlab.io/coretraffic/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [![pipeline status](https://gitlab.com/servezone/private/coretraffic/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/servezone/private/coretraffic/badges/master/coverage.svg)](https://lossless.cloud)
|
||||||
|
npm | [![npm downloads per month](https://badgen.net/npm/dy/@servezone_private/coretraffic)](https://lossless.cloud)
|
||||||
|
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/servezone/private/coretraffic)](https://lossless.cloud)
|
||||||
|
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||||
|
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@servezone_private/coretraffic)](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@servezone_private/coretraffic)](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@servezone_private/coretraffic)](https://lossless.cloud)
|
||||||
|
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
|
||||||
|
[![repo-footer](https://servezone.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> UNLICENSED licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
27
test/test.nonci.ts
Normal file
27
test/test.nonci.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
delete process.env.CLI_CALL;
|
||||||
|
import * as coretraffic from '../ts/index.js';
|
||||||
|
|
||||||
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
|
|
||||||
|
const testQenv = new Qenv('./', './.nogit');
|
||||||
|
let testCoreTraffic: coretraffic.CoreTraffic;
|
||||||
|
|
||||||
|
tap.test('should create an coretraffic instance', async (tools) => {
|
||||||
|
testCoreTraffic = new coretraffic.CoreTraffic();
|
||||||
|
expect(testCoreTraffic).toBeInstanceOf(coretraffic.CoreTraffic);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should start the instance', async (tools) => {
|
||||||
|
await testCoreTraffic.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should keep the instance alive', async (tools) => {
|
||||||
|
await tools.delayFor(10000);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should stop the instance', async (tools) => {
|
||||||
|
await testCoreTraffic.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: 'coretraffic',
|
||||||
|
version: '1.0.184',
|
||||||
|
description: 'route traffic within your docker setup. TypeScript ready.'
|
||||||
|
}
|
43
ts/coretraffic.classes.coreflowconnector.ts
Normal file
43
ts/coretraffic.classes.coreflowconnector.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import * as plugins from './coretraffic.plugins.js';
|
||||||
|
import { logger } from './coretraffic.logging.js';
|
||||||
|
import { CoreTraffic } from './coretraffic.classes.coretraffic.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coreflow Connector
|
||||||
|
*/
|
||||||
|
export class CoreflowConnector {
|
||||||
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||||
|
public coretrafficRef: CoreTraffic;
|
||||||
|
public typesocketClient: plugins.typedsocket.TypedSocket;
|
||||||
|
|
||||||
|
constructor(coretrafficRefArg: CoreTraffic) {
|
||||||
|
this.coretrafficRef = coretrafficRefArg;
|
||||||
|
this.coretrafficRef.typedrouter.addTypedRouter(this.typedrouter)
|
||||||
|
|
||||||
|
this.typedrouter.addTypedHandler<
|
||||||
|
plugins.lointCloudly.request.routing.IRequest_Coreflow_Coretraffic_RoutingUpdate
|
||||||
|
>(new plugins.typedrequest.TypedHandler('updateRouting', async (requestData) => {
|
||||||
|
console.log(requestData);
|
||||||
|
await this.coretrafficRef.taskmanager.setupRoutingTask.trigger(requestData.reverseConfigs);
|
||||||
|
return {
|
||||||
|
status: 'ok',
|
||||||
|
errorText: ''
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the corechatConnector
|
||||||
|
*/
|
||||||
|
public async start() {
|
||||||
|
this.typesocketClient = await plugins.typedsocket.TypedSocket.createClient(
|
||||||
|
this.typedrouter,
|
||||||
|
'http://coreflow:3000',
|
||||||
|
'coretraffic'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async stop() {
|
||||||
|
await this.typesocketClient.stop();
|
||||||
|
}
|
||||||
|
}
|
55
ts/coretraffic.classes.coretraffic.ts
Normal file
55
ts/coretraffic.classes.coretraffic.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import * as plugins from './coretraffic.plugins.js';
|
||||||
|
import * as paths from './coretraffic.paths.js'
|
||||||
|
import { logger } from './coretraffic.logging.js';
|
||||||
|
import { CoreflowConnector } from './coretraffic.classes.coreflowconnector.js';
|
||||||
|
import { CoretrafficTaskManager } from './coretraffic.classes.taskmanager.js';
|
||||||
|
|
||||||
|
export interface ICoretrafficConfig {
|
||||||
|
dockerDomainEnvName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CoreTraffic {
|
||||||
|
public projectinfo = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
|
||||||
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||||
|
public coreflowConnector: CoreflowConnector;
|
||||||
|
public taskmanager: CoretrafficTaskManager;
|
||||||
|
public networkProxy: plugins.smartproxy.NetworkProxy;
|
||||||
|
public sslRedirect: plugins.smartproxy.SslRedirect;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.coreflowConnector = new CoreflowConnector(this);
|
||||||
|
this.taskmanager = new CoretrafficTaskManager(this);
|
||||||
|
this.networkProxy = new plugins.smartproxy.NetworkProxy({
|
||||||
|
port: 8000
|
||||||
|
});
|
||||||
|
this.sslRedirect = new plugins.smartproxy.SslRedirect(7999);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts coretraffic
|
||||||
|
*/
|
||||||
|
public async start() {
|
||||||
|
await this.networkProxy.start();
|
||||||
|
await this.sslRedirect.start();
|
||||||
|
this.networkProxy.addDefaultHeaders({
|
||||||
|
servezone_coretraffic_version: this.projectinfo.version
|
||||||
|
})
|
||||||
|
|
||||||
|
await this.taskmanager.start();
|
||||||
|
await this.coreflowConnector.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stops coretraffic
|
||||||
|
*/
|
||||||
|
public async stop() {
|
||||||
|
await this.taskmanager.stop();
|
||||||
|
console.log('stopped taskmanager');
|
||||||
|
await this.coreflowConnector.stop();
|
||||||
|
console.log('stopped coreflowConnector');
|
||||||
|
await this.networkProxy.stop();
|
||||||
|
console.log('stopped smartproxy!');
|
||||||
|
await this.sslRedirect.stop();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
35
ts/coretraffic.classes.taskmanager.ts
Normal file
35
ts/coretraffic.classes.taskmanager.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import * as plugins from './coretraffic.plugins.js';
|
||||||
|
import { CoreTraffic } from './coretraffic.classes.coretraffic.js';
|
||||||
|
import { logger } from './coretraffic.logging.js';
|
||||||
|
|
||||||
|
export class CoretrafficTaskManager {
|
||||||
|
public coretrafficRef: CoreTraffic;
|
||||||
|
public taskmanager: plugins.taskbuffer.TaskManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a task to run setup routing, runs buffered
|
||||||
|
*/
|
||||||
|
public setupRoutingTask: plugins.taskbuffer.Task;
|
||||||
|
|
||||||
|
constructor(coretrafficRefArg: CoreTraffic) {
|
||||||
|
this.coretrafficRef = coretrafficRefArg;
|
||||||
|
this.taskmanager = new plugins.taskbuffer.TaskManager();
|
||||||
|
|
||||||
|
this.setupRoutingTask = new plugins.taskbuffer.Task({
|
||||||
|
buffered: true,
|
||||||
|
bufferMax: 2,
|
||||||
|
taskFunction: async (reverseConfigs: plugins.lointCloudly.traffic.IReverseProxyConfig[]) => {
|
||||||
|
console.log('this is what got to the task:');
|
||||||
|
console.log(reverseConfigs);
|
||||||
|
logger.log('info', `routing setup task triggered`);
|
||||||
|
logger.log('info', `Found ${reverseConfigs.length} host reverse configs!`);
|
||||||
|
logger.log('info', `trying to deploy host candidates now`);
|
||||||
|
await this.coretrafficRef.networkProxy.updateProxyConfigs(reverseConfigs);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async start() {}
|
||||||
|
|
||||||
|
public async stop() {}
|
||||||
|
}
|
14
ts/coretraffic.logging.ts
Normal file
14
ts/coretraffic.logging.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import * as plugins from './coretraffic.plugins.js';
|
||||||
|
import * as paths from './coretraffic.paths.js';
|
||||||
|
|
||||||
|
const projectInfoNpm = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
|
||||||
|
|
||||||
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
|
logContext: {
|
||||||
|
environment: 'production',
|
||||||
|
runtime: 'node',
|
||||||
|
zone: 'serve.zone',
|
||||||
|
containerName: 'coretraffic',
|
||||||
|
},
|
||||||
|
minimumLogLevel: 'info',
|
||||||
|
});
|
6
ts/coretraffic.paths.ts
Normal file
6
ts/coretraffic.paths.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from './coretraffic.plugins.js';
|
||||||
|
|
||||||
|
// Directories
|
||||||
|
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
|
export const appSslDir = '/app_certs';
|
||||||
|
export const nginxConfDir = '/etc/nginx/conf.d/';
|
44
ts/coretraffic.plugins.ts
Normal file
44
ts/coretraffic.plugins.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// NODE INTERNALS
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export { path };
|
||||||
|
|
||||||
|
// @serve.zone scope
|
||||||
|
import * as lointCloudly from '@losslessone_private/loint-cloudly';
|
||||||
|
|
||||||
|
export { lointCloudly };
|
||||||
|
|
||||||
|
// @api.global scope
|
||||||
|
import * as typedrequest from '@api.global/typedrequest';
|
||||||
|
import * as typedsocket from '@api.global/typedsocket';
|
||||||
|
|
||||||
|
export { typedrequest, typedsocket };
|
||||||
|
|
||||||
|
// @push.rocks scope
|
||||||
|
import * as qenv from '@push.rocks/qenv';
|
||||||
|
import * as projectinfo from '@push.rocks/projectinfo';
|
||||||
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
|
import * as smartlogDestinationReceiver from '@push.rocks/smartlog-destination-receiver';
|
||||||
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
|
import * as smartproxy from '@push.rocks/smartproxy';
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
import * as smartrequest from '@push.rocks/smartrequest';
|
||||||
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||||
|
|
||||||
|
export {
|
||||||
|
qenv,
|
||||||
|
projectinfo,
|
||||||
|
smartdelay,
|
||||||
|
smartlog,
|
||||||
|
smartlogDestinationReceiver,
|
||||||
|
smartpath,
|
||||||
|
smartproxy,
|
||||||
|
smartshell,
|
||||||
|
smartpromise,
|
||||||
|
smartrequest,
|
||||||
|
smartstring,
|
||||||
|
taskbuffer,
|
||||||
|
};
|
22
ts/index.ts
Normal file
22
ts/index.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
console.log('**** Starting coretraffic ****');
|
||||||
|
import * as plugins from './coretraffic.plugins.js';
|
||||||
|
import * as paths from './coretraffic.paths.js';
|
||||||
|
import { logger } from './coretraffic.logging.js';
|
||||||
|
|
||||||
|
import { CoreTraffic } from './coretraffic.classes.coretraffic.js';
|
||||||
|
export { CoreTraffic };
|
||||||
|
|
||||||
|
const projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
||||||
|
|
||||||
|
let coretrafficInstance: CoreTraffic;
|
||||||
|
|
||||||
|
export const runCli = async () => {
|
||||||
|
logger.log('info', `coretraffic@v${projectinfo.npm.version}`);
|
||||||
|
coretrafficInstance = new CoreTraffic();
|
||||||
|
await coretrafficInstance.start();
|
||||||
|
logger.log('info', 'coretraffic successfully started!');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const stop = async () => {
|
||||||
|
coretrafficInstance.stop();
|
||||||
|
};
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user