Compare commits

..

No commits in common. "master" and "v2.0.51" have entirely different histories.

28 changed files with 2001 additions and 5307 deletions

View File

@ -1,66 +0,0 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -1,124 +0,0 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

@ -15,6 +15,8 @@ node_modules/
# builds # builds
dist/ dist/
dist_*/ dist_web/
dist_serve/
dist_ts_web/
# custom # custom

11
.vscode/launch.json vendored
View File

@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored
View File

@ -1,26 +0,0 @@
{
"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"]
}
}
}
}
}
}
]
}

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# @pushrocks/smartnginx
control nginx from node, TypeScript ready
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartnginx)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartnginx)
* [github.com (source mirror)](https://github.com/pushrocks/smartnginx)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartnginx/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartnginx/badges/master/build.svg)](https://gitlab.com/pushrocks/smartnginx/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartnginx/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartnginx/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartnginx.svg)](https://www.npmjs.com/package/@pushrocks/smartnginx)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartnginx/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartnginx)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
We recommend the use of TypeScript! :)
```typescript
import * as smartnginx from 'smartnginx';
const smartnginxInstance = new smartnginx.SmartNginx();
myNginxHost = new smartnginx.NginxHost({
hostName: 'some.example.com',
type: 'reverseProxy',
destination: '192.192.192.192' // some destination IP
});
myNginxConfig.addZone(myNginxZone); // adds the zone to the config
myNginxConfig.deploy(); // deploys the referenced NginxConfig and gracefully reloads it
```
For further information read the linked docs at the top of this readme.
> MIT 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)

View File

@ -1,15 +1,15 @@
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQD5b6wtr4xHY5gxH0SR+V9XIQPH6DGe2PXlKWN02dgvg7Ej/4uA MIICXAIBAAKBgQCMGIi2uxtbfbDIiyL6SWwZb1RdSpjGFHwzlR+mipbwgW1JsYld
7MmOnem2SUpWE2GwuKCAUCeZkj+riEmky0EWFexaM3BmcvWLSHZ6MAYg5FxTsUG8 Fs463PvxsMFgyQ6Nzndj3IE1mpYQgWYSS69mV8B3XxusrxnOGeO00IdA+qPGakzq
IXxNYUdTPpUBxaCX/yp/dvpiDqSMH67y9LwI85oWHx/zk1jMixaZXvOCXwIDAQAB Sm+/2ualnz6nDeVWTvQuM15Ki6WQsbvmcIKngs+5tsmYfTiAnpFUv3t6zQIDAQAB
AoGBALFXn1/f9uluuu753yO12/4zf9+qi1T3xmQGuCqFE7o8dD422vVv5KHcTiUH AoGAdb6VAMdnKdEMyLAv+J3G7eWkyTfOCQTkklHuJQHr9D1DRiGhqoxlThG26p49
GK34G7Wsnph75JvAKjqHrGxZAk0NN59VK4Sl141S7qzXgjQf5Ks7r5y8v8AQgvEM GQRCaCq0K0kDi7LeFwc6a3wS8LjRZ9DI+mkyA0KRM0bXEkQnBM7ZGqc32476mMp+
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0pJ279EDgvsY+YjslMdUaJbZcF9rFgUE3t8vDDZH99kth8gqNddahcLqEV2 gYEARLQhxnvrKNGs758MzDTbf3lBuMd5jf42YFcUdEPI6jg9knKwqcgd5eNkZtNM
8hyx7qcnplpKNVx8DYvDWoTGRdXBhCP/TBBW3jdsqaBHJey+yfAISBk4pbOow260 DFPOFJf3HIJOLeOhXZ4bzQpcxVkkDAMUloKmQNypZlRWzkZt0jLgG0/ofKvvqX7c
tNQngsMDf+PZQMLm2bT1Pxk2KXd0rFMkVWprcRs2qx3Yz0Q= DpzwgTIoJwWlpbug788LEm3HcTVPu0LxQ1lOpgt0PWPnasc=
-----END CERTIFICATE----- -----END CERTIFICATE-----

View File

@ -15,8 +15,8 @@ server {
server { server {
listen *:443 ssl; listen *:443 ssl;
server_name test100.bleu.de; server_name test100.bleu.de;
ssl_certificate /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.public.pem; ssl_certificate /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test100.bleu.de.public.pem;
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test100.bleu.de.private.pem; ssl_certificate_key /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test100.bleu.de.private.pem;
location / { location / {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_buffering off; proxy_buffering off;

View File

@ -15,8 +15,8 @@ server {
server { server {
listen *:443 ssl; listen *:443 ssl;
server_name test102.bleu.de; server_name test102.bleu.de;
ssl_certificate /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.public.pem; ssl_certificate /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test102.bleu.de.public.pem;
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/test102.bleu.de.private.pem; ssl_certificate_key /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/test102.bleu.de.private.pem;
location / { location / {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_buffering off; proxy_buffering off;

View File

@ -68,12 +68,12 @@ http {
server { server {
listen *:443 ssl default_server; listen *:443 ssl default_server;
server_name selfsigned.git.zone; server_name selfsigned.git.zone;
ssl_certificate /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.public.pem; ssl_certificate /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/default.public.pem;
ssl_certificate_key /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/default.private.pem; ssl_certificate_key /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/default.private.pem;
rewrite ^ https://git.zone redirect; rewrite ^ https://git.zone redirect;
} }
include /mnt/HC_Volume_11396573/lossless/push.rocks/smartnginx/nginxconfig/hosts/*.conf; include /Users/philkunz/gitlab/pushrocks_meta/smartnginx/nginxconfig/hosts/*.conf;
include /etc/nginx/sites-enabled/*; include /etc/nginx/sites-enabled/*;
} }
daemon off; daemon off;

View File

@ -4,26 +4,13 @@
}, },
"npmdocker": {}, "npmdocker": {},
"gitzone": { "gitzone": {
"projectType": "npm",
"module": { "module": {
"githost": "code.foss.global", "githost": "gitlab.com",
"gitscope": "push.rocks", "gitscope": "pushrocks",
"gitrepo": "smartnginx", "gitrepo": "smartnginx",
"description": "A TypeScript library for controlling Nginx from Node.js, with support for generating and managing Nginx configurations dynamically.", "shortDescription": "control nginx from node, TypeScript ready",
"npmPackagename": "@push.rocks/smartnginx", "npmPackagename": "@pushrocks/smartnginx",
"license": "MIT", "license": "MIT"
"keywords": [
"nginx",
"node.js",
"TypeScript",
"configuration management",
"web server",
"reverse proxy",
"SSL certificates"
]
} }
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis 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. \n\n**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.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
} }
} }

1819
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,66 +1,56 @@
{ {
"name": "@push.rocks/smartnginx", "name": "@pushrocks/smartnginx",
"version": "2.0.52", "version": "2.0.51",
"private": false, "private": false,
"description": "A TypeScript library for controlling Nginx from Node.js, with support for generating and managing Nginx configurations dynamically.", "description": "control nginx from node, TypeScript ready",
"main": "dist_ts/index.js", "main": "dist/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "tstest test/", "test": "tstest test/",
"cleanTest": "(rm -r nginxconfig) && npm run test", "cleanTest": "(rm -r nginxconfig) && npm run test",
"build": "(tsbuild --allowimplicitany)" "build": "(tsbuild)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://code.foss.global/push.rocks/smartnginx.git" "url": "git+ssh://git@gitlab.com/pushrocks/smartnginx.git"
}, },
"keywords": [ "keywords": [
"nginx", "nginx"
"node.js",
"TypeScript",
"configuration management",
"web server",
"reverse proxy",
"SSL certificates"
], ],
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartnginx/issues" "url": "https://gitlab.com/pushrocks/smartnginx/issues"
}, },
"homepage": "https://code.foss.global/push.rocks/smartnginx", "homepage": "https://gitlab.com/pushrocks/smartnginx#README",
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.0.2", "@pushrocks/lik": "^3.0.10",
"@push.rocks/smartfile": "^10.0.26", "@pushrocks/smartfile": "^7.0.4",
"@push.rocks/smartlog": "^3.0.2", "@pushrocks/smartlog": "^2.0.19",
"@push.rocks/smartpath": "^5.0.11", "@pushrocks/smartpromise": "^3.0.2",
"@push.rocks/smartpromise": "^4.0.2", "@pushrocks/smartshell": "^2.0.23",
"@push.rocks/smartshell": "^3.0.3", "@pushrocks/smartstring": "^3.0.10",
"@push.rocks/smartstring": "^4.0.7", "@pushrocks/smartunique": "^3.0.1",
"@push.rocks/smartunique": "^3.0.3", "selfsigned": "^1.10.4"
"selfsigned": "^2.1.1"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.66", "@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.2.44", "@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.77", "@gitzone/tstest": "^1.0.24",
"@push.rocks/qenv": "^5.0.2", "@pushrocks/qenv": "^4.0.2",
"@push.rocks/tapbundle": "^5.0.8" "@pushrocks/tapbundle": "^3.0.11",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/*",
"ts_web/**/*", "ts_web/*",
"dist/**/*", "dist/*",
"dist_*/**/*", "dist_web/*",
"dist_ts/**/*", "dist_ts_web/*",
"dist_ts_web/**/*", "assets/*",
"assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
] ]
} }

4819
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

View File

@ -1,93 +0,0 @@
# @push.rocks/smartnginx
control nginx from node, TypeScript ready
## Install
To install `@push.rocks/smartnginx`, you can use npm (Node Package Manager). Open your terminal and run:
```bash
npm install @push.rocks/smartnginx --save
```
This will download and install `@push.rocks/smartnginx` and its dependencies into your project's `node_modules` folder and save it as a dependency in your project's `package.json` file.
## Usage
`@push.rocks/smartnginx` is a powerful library for interacting with Nginx programmatically using Node.js and TypeScript. It simplifies tasks such as configuring hosts, deploying configurations, and managing SSL certificates. Below is a comprehensive guide to using the library effectively in your TypeScript projects.
### Getting Started
First, ensure you have imported the library into your TypeScript file. Use ESM syntax as shown:
```typescript
import { SmartNginx, NginxHost } from '@push.rocks/smartnginx';
```
### Initialize SmartNginx
Before you interact with Nginx, you need to create an instance of `SmartNginx`. This object acts as the main interface to your Nginx server. You can specify a default proxy URL that requests will be redirected to if no matching host is found.
```typescript
const smartNginx = new SmartNginx({
defaultProxyUrl: 'https://your-default-url.com'
});
```
### Add Host Candidates
To serve content or applications via Nginx, you will define hosts. Each host corresponds to a domain or subdomain and can be configured with specific rules. Here's how to add host candidates:
```typescript
const myHost = smartNginx.addHostCandidate({
hostName: 'example.com',
destination: 'localhost',
destinationPort: 8080,
privateKey: '<Your SSL Private Key>',
publicKey: '<Your SSL Public Key>'
});
```
Replace `'example.com'`, `'localhost'`, `8080`, `'<Your SSL Private Key>'`, and `'<Your SSL Public Key>'` with your actual host name, destination IP or hostname, port number, and SSL keys respectively.
### Deploying Configuration
After adding all your host candidates, you will need to apply these configurations for Nginx to recognize and use them. Deploy the configuration as follows:
```typescript
await smartNginx.deploy();
```
This method checks for any changes in your host configurations compared to what's currently deployed and updates the Nginx configuration accordingly.
### Managing SSL Certificates
When setting up SSL for your hosts, you will provide the paths to the private key and public certificate. It's essential to ensure these files are securely stored and accessible by the library during deployment.
### Handling Multiple Hosts
You can add multiple host candidates using `addHostCandidate` method for different domains or subdomains, each with unique configurations. Here's an example of adding another host:
```typescript
const anotherHost = smartNginx.addHostCandidate({
hostName: 'sub.example.com',
destination: 'localhost',
destinationPort: 9090,
privateKey: '<Another SSL Private Key>',
publicKey: '<Another SSL Public Key>'
});
```
### Reloading Configurations
If at any time you make changes to your host configurations and need to apply these changes, simply call the `deploy` method again. `@push.rocks/smartnginx` efficiently detects changes and reloads Nginx with the new configurations.
### Stopping SmartNginx
To stop the Nginx process managed by `@push.rocks/smartnginx`, use:
```typescript
await smartNginx.stop();
```
Bear in mind that this might affect your web services if they rely on the Nginx instance you are stopping.
### Conclusion
`@push.rocks/smartnginx` abstracts away much of the complexity involved in managing Nginx configurations, offering a TypeScript-ready solution for Node.js projects. With simple method calls, you can automate and manage your Nginx server programmatically, making it an excellent tool for developers seeking to integrate Nginx management into their applications or deployment workflows.
## 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.
**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.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -1,10 +1,10 @@
import { tap, expect } from '@push.rocks/tapbundle'; import { tap, expect } from '@pushrocks/tapbundle';
import path = require('path'); import path = require('path');
import { Qenv } from '@push.rocks/qenv'; import { Qenv } from '@pushrocks/qenv';
const testQenv = new Qenv('./', './.nogit/'); const testQenv = new Qenv('./', './.nogit/');
import * as smartnginx from '../ts/index.js'; import * as smartnginx from '../ts/index';
let testSmartNginx: smartnginx.SmartNginx; let testSmartNginx: smartnginx.SmartNginx;
let testNginxZone01: smartnginx.NginxHost; let testNginxZone01: smartnginx.NginxHost;
@ -12,7 +12,7 @@ let testNginxZone02: smartnginx.NginxHost;
tap.test('should create a valid instance of SmartNginx', async () => { tap.test('should create a valid instance of SmartNginx', async () => {
testSmartNginx = new smartnginx.SmartNginx({ defaultProxyUrl: 'https://git.zone' }); testSmartNginx = new smartnginx.SmartNginx({ defaultProxyUrl: 'https://git.zone' });
expect(testSmartNginx).toBeInstanceOf(smartnginx.SmartNginx); expect(testSmartNginx).to.be.instanceof(smartnginx.SmartNginx);
}); });
tap.test(`should produce an instance of NginxConfig`, async () => { tap.test(`should produce an instance of NginxConfig`, async () => {
@ -21,16 +21,16 @@ tap.test(`should produce an instance of NginxConfig`, async () => {
destination: '192.192.192.191', destination: '192.192.192.191',
destinationPort: 3000, destinationPort: 3000,
privateKey: 'some private', privateKey: 'some private',
publicKey: 'some public', publicKey: 'some public'
}); });
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, { testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test102.bleu.de', hostName: 'test102.bleu.de',
destination: '192.192.192.192', destination: '192.192.192.192',
destinationPort: 3050, destinationPort: 3050,
privateKey: 'some private', privateKey: 'some private',
publicKey: 'some public', publicKey: 'some public'
}); });
expect(testNginxZone01).toBeInstanceOf(smartnginx.NginxHost); expect(testNginxZone01).to.be.instanceof(smartnginx.NginxHost);
}); });
tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => { tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => {

View File

@ -1,8 +0,0 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartnginx',
version: '2.0.52',
description: 'control nginx from node, TypeScript ready'
}

View File

@ -1,4 +1,6 @@
import * as plugins from './smartnginx.plugins';
// classes // classes
export * from './smartnginx.classes.smartnginx.js'; export * from './smartnginx.classes.smartnginx';
export * from './smartnginx.classes.nginxprocess.js'; export * from './smartnginx.classes.nginxprocess';
export * from './smartnginx.classes.nginxhost.js'; export * from './smartnginx.classes.nginxhost';

View File

@ -1,13 +1,13 @@
import * as plugins from './smartnginx.plugins.js'; import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths.js'; import * as paths from './smartnginx.paths';
import * as snippets from './smartnginx.snippets.js'; import * as snippets from './smartnginx.snippets';
import { SmartNginx } from './smartnginx.classes.smartnginx.js'; import { SmartNginx } from './smartnginx.classes.smartnginx';
import { type IHostConfig } from './interfaces/hostconfig.js'; import { IHostConfig } from './interfaces/hostconfig';
export enum hostTypes { export enum hostTypes {
reverseProxy, reverseProxy
} }
/** /**

View File

@ -1,7 +1,9 @@
import * as plugins from './smartnginx.plugins.js'; import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths.js'; import * as paths from './smartnginx.paths';
import { SmartNginx } from './smartnginx.classes.smartnginx.js'; import { SmartNginx } from './smartnginx.classes.smartnginx';
import { NginxHost } from './smartnginx.classes.nginxhost.js'; import { NginxHost } from './smartnginx.classes.nginxhost';
import { Smartshell } from '@pushrocks/smartshell';
import { ChildProcess } from 'child_process'; import { ChildProcess } from 'child_process';
@ -12,8 +14,8 @@ export class NginxProcess {
public started: boolean = false; public started: boolean = false;
public smartNginxRef: SmartNginx; public smartNginxRef: SmartNginx;
private nginxChildProcess: ChildProcess; private nginxChildProcess: ChildProcess;
private smartshellInstance = new plugins.smartshell.Smartshell({ private smartshellInstance = new Smartshell({
executor: 'bash', executor: 'bash'
}); });
constructor(nginxRefArg: SmartNginx) { constructor(nginxRefArg: SmartNginx) {
@ -25,12 +27,12 @@ export class NginxProcess {
*/ */
public async start() { public async start() {
if (!this.nginxChildProcess) { if (!this.nginxChildProcess) {
this.nginxChildProcess = ( this.nginxChildProcess = (await this.smartshellInstance.execStreaming(
await this.smartshellInstance.execStreaming(`nginx -c ${paths.nginxConfFile}`) `nginx -c ${paths.nginxConfFile}`
).childProcess; )).childProcess;
} }
this.started = true; this.started = true;
console.log('info', 'started Nginx!'); plugins.smartlog.defaultLogger.log('info', 'started Nginx!');
} }
/** /**

View File

@ -1,9 +1,9 @@
import * as plugins from './smartnginx.plugins.js'; import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths.js'; import * as paths from './smartnginx.paths';
import * as snippets from './smartnginx.snippets.js'; import * as snippets from './smartnginx.snippets';
import { NginxHost } from './smartnginx.classes.nginxhost.js'; import { NginxHost } from './smartnginx.classes.nginxhost';
import { NginxProcess } from './smartnginx.classes.nginxprocess.js'; import { NginxProcess } from './smartnginx.classes.nginxprocess';
import { type IHostConfig } from './interfaces/hostconfig.js'; import { IHostConfig } from './interfaces/hostconfig';
export interface ISmartNginxContructorOptions { export interface ISmartNginxContructorOptions {
logger?: plugins.smartlog.Smartlog; logger?: plugins.smartlog.Smartlog;
@ -18,17 +18,15 @@ export class SmartNginx {
public logger: plugins.smartlog.Smartlog; public logger: plugins.smartlog.Smartlog;
// the objectmaps // the objectmaps
private deployedHosts = new plugins.lik.ObjectMap<NginxHost>(); private deployedHosts = new plugins.lik.Objectmap<NginxHost>();
private hostCandidates = new plugins.lik.ObjectMap<NginxHost>(); private hostCandidates = new plugins.lik.Objectmap<NginxHost>();
public nginxProcess: NginxProcess = new NginxProcess(this); public nginxProcess: NginxProcess = new NginxProcess(this);
constructor(optionsArg: ISmartNginxContructorOptions) { constructor(optionsArg: ISmartNginxContructorOptions) {
this.options = optionsArg; this.options = optionsArg;
this.options.logger this.options.logger
? (this.logger = this.options.logger) ? (this.logger = this.options.logger)
: (this.logger = new plugins.smartlog.Smartlog({ : (this.logger = plugins.smartlog.defaultLogger);
logContext: null
}));
} }
// =================== // ===================
@ -50,7 +48,7 @@ export class SmartNginx {
* @param hostNameArg * @param hostNameArg
*/ */
public getDeployedNginxHostByHostName(hostNameArg: string): NginxHost { public getDeployedNginxHostByHostName(hostNameArg: string): NginxHost {
return this.deployedHosts.findSync((nginxHost) => { return this.deployedHosts.find(nginxHost => {
return nginxHost.hostName === hostNameArg; return nginxHost.hostName === hostNameArg;
}); });
} }
@ -67,7 +65,7 @@ export class SmartNginx {
*/ */
public async removeDeployedHost(nginxHostArg: NginxHost) { public async removeDeployedHost(nginxHostArg: NginxHost) {
if (this.hostCandidates.isEmpty()) { if (this.hostCandidates.isEmpty()) {
this.deployedHosts.forEach((hostArg) => { this.deployedHosts.forEach(hostArg => {
this.hostCandidates.add(hostArg); this.hostCandidates.add(hostArg);
}); });
} }
@ -82,9 +80,9 @@ export class SmartNginx {
private async areHostsDiverged(): Promise<boolean> { private async areHostsDiverged(): Promise<boolean> {
let hostCounter = 0; let hostCounter = 0;
let unfoundHosts = 0; let unfoundHosts = 0;
await this.hostCandidates.forEach(async (hostCandidateArg) => { await this.hostCandidates.forEach(async hostCandidateArg => {
let foundHost = false; let foundHost = false;
await this.deployedHosts.forEach(async (deployedHostArg) => { await this.deployedHosts.forEach(async deployedHostArg => {
if ( if (
hostCandidateArg.hostName === deployedHostArg.hostName && hostCandidateArg.hostName === deployedHostArg.hostName &&
hostCandidateArg.destination === deployedHostArg.destination && hostCandidateArg.destination === deployedHostArg.destination &&

View File

@ -1,7 +1,7 @@
import * as plugins from './smartnginx.plugins.js'; import * as plugins from './smartnginx.plugins';
// directories // directories
export const packageBase = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../'); export const packageBase = plugins.path.join(__dirname, '../');
export const nginxConfigDirPath = plugins.path.join(packageBase, 'nginxconfig'); export const nginxConfigDirPath = plugins.path.join(packageBase, 'nginxconfig');
export const nginxHostDirPath = plugins.path.join(nginxConfigDirPath, 'hosts'); export const nginxHostDirPath = plugins.path.join(nginxConfigDirPath, 'hosts');

View File

@ -4,18 +4,17 @@ import * as path from 'path';
export { path }; export { path };
// @pushrocks scope // @pushrocks scope
import * as lik from '@push.rocks/lik'; import * as lik from '@pushrocks/lik';
import * as smartfile from '@push.rocks/smartfile'; import * as smartlog from '@pushrocks/smartlog';
import * as smartlog from '@push.rocks/smartlog'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartpath from '@push.rocks/smartpath'; import * as smartshell from '@pushrocks/smartshell';
import * as smartpromise from '@push.rocks/smartpromise'; import * as smartfile from '@pushrocks/smartfile';
import * as smartshell from '@push.rocks/smartshell'; import * as smartstring from '@pushrocks/smartstring';
import * as smartstring from '@push.rocks/smartstring'; import * as smartunique from '@pushrocks/smartunique';
import * as smartunique from '@push.rocks/smartunique';
export { lik, smartfile, smartlog, smartpath, smartpromise, smartshell, smartstring, smartunique }; export { lik, smartlog, smartpromise, smartshell, smartfile, smartstring, smartunique };
// thirdparty scope // thirdparty scope
import * as selfsigned from 'selfsigned'; import * as selfsigned from 'selfsigned';
export { selfsigned }; export { selfsigned };

View File

@ -1,5 +1,5 @@
import * as plugins from './smartnginx.plugins.js'; import * as plugins from './smartnginx.plugins';
import * as paths from './smartnginx.paths.js'; import * as paths from './smartnginx.paths';
export let getBaseConfigString = (defaultProxy: string) => { export let getBaseConfigString = (defaultProxy: string) => {
const baseConfig = plugins.smartstring.indent.normalize(` const baseConfig = plugins.smartstring.indent.normalize(`
user www-data; user www-data;

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

17
tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}