From de062f5acd2ee6cbeacdf0a130f3caea3e837bdc Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 18:33:33 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 19 ++++++- package.json | 16 +++++- readme.hints.md | 1 + readme.md | 142 +++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 154 insertions(+), 24 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index a58d9f1..b489a0f 100644 --- a/npmextra.json +++ b/npmextra.json @@ -8,14 +8,29 @@ "shortDescription": "a module creating a vhost layer in order to maintain several smartexpress instances", "npmPackagename": "@push.rocks/smartvhost", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "description": "A module for creating a virtual host (vhost) layer to manage multiple SmartExpress instances.", + "keywords": [ + "virtual host", + "SmartExpress", + "networking", + "proxy", + "vhost configuration", + "node.js", + "express", + "web server", + "reverse proxy", + "typescript", + "SSL", + "module" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "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" } } \ No newline at end of file diff --git a/package.json b/package.json index a593efd..34eac1c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartvhost", "version": "1.0.3", "private": false, - "description": "a module creating a vhost layer in order to maintain several smartexpress instances", + "description": "A module for creating a virtual host (vhost) layer to manage multiple SmartExpress instances.", "main": "dist/index.js", "typings": "dist/index.d.ts", "author": "Lossless GmbH", @@ -36,5 +36,19 @@ "cli.js", "npmextra.json", "readme.md" + ], + "keywords": [ + "virtual host", + "SmartExpress", + "networking", + "proxy", + "vhost configuration", + "node.js", + "express", + "web server", + "reverse proxy", + "typescript", + "SSL", + "module" ] } \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 68c224e..8c2384a 100644 --- a/readme.md +++ b/readme.md @@ -1,32 +1,132 @@ -# @pushrocks/smartvhost +# @push.rocks/smartvhost a module creating a vhost layer in order to maintain several smartexpress instances -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartvhost) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartvhost) -* [github.com (source mirror)](https://github.com/pushrocks/smartvhost) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartvhost/) +## Install +To install `@push.rocks/smartvhost`, use the following npm command: -## Status for master -[![pipeline status](https://gitlab.com/pushrocks/smartvhost/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartvhost/commits/master) -[![coverage report](https://gitlab.com/pushrocks/smartvhost/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartvhost/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartvhost.svg)](https://www.npmjs.com/package/@pushrocks/smartvhost) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartvhost/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartvhost) -[![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/) +```bash +npm install @push.rocks/smartvhost --save +``` + +This will add smartvhost as a dependency to your project and you are ready to use it to manage multiple virtual hosts within your applications. ## Usage -Use TypeScript for best in class intellisense +`@push.rocks/smartvhost` simplifies the handling of multiple `smartexpress` instances or other target types by providing a virtual host (vhost) layer. This allows for differentiated handling of requests based on the hostname, among other criteria. Utilizing this module enables efficient scalability and organization of your web server components in a Node.js environment. -## Contribution +Below, you'll find comprehensive examples and explanations to help you get started and leverage the full spectrum of functionalities offered by smartvhost. -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +### Importing and Initial Setup -For further information read the linked docs at the top of this readme. +Firstly, let's look into importing and setting up smartvhost in your project using modern ESM syntax and TypeScript. -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +```typescript +import { SmartVHost } from '@push.rocks/smartvhost'; -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +const mySmartVHost = new SmartVHost(); +``` + +Upon instantiation, `SmartVHost` begins without any configured virtual hosts. To make it functional, you'll need to define and set configurations according to your needs. + +### Configuring Virtual Hosts + +Virtual host configurations are crucial for directing traffic appropriately. smartvhost supports several types of configurations, which include directing traffic to local folders, specific IP and port combinations, local ports, or even other domains. Below is how to define and apply these configurations: + +```typescript +import { IVHostConfig } from '@push.rocks/smartvhost'; + +// Define an array of virtual host configurations +const vHostConfigs: IVHostConfig[] = [ + { + hostName: 'example.com', + type: 'folder', + target: '/path/to/your/site', + privateKey: '', // needed for HTTPS + publicKey: '', // needed for HTTPS + }, + { + hostName: 'api.example.com', + type: 'localPort', + target: '3002', + privateKey: '', + publicKey: '', + }, + { + hostName: 'another-domain.com', + type: 'ipAndPort', + target: '192.168.1.100:80', + privateKey: '', + publicKey: '', + } +]; + +// Apply the configurations to the smartvhost instance +mySmartVHost.setVHostConfigs(vHostConfigs); +``` + +### Starting and Stopping smartvhost + +To activate the virtual host layer, simply start your smartvhost instance. Similarly, you can stop it when necessary: + +```typescript +// To start +await mySmartVHost.start(); + +// When needed, stop +await mySmartVHost.stop(); +``` + +### Complete Example + +Combining all the steps above, here's a complete example showcasing how to utilize `@push.rocks/smartvhost` in managing different vhosts for your application: + +```typescript +import { SmartVHost, IVHostConfig } from '@push.rocks/smartvhost'; + +async function setupSmartVHost() { + const mySmartVHost = new SmartVHost(); + const vHostConfigs: IVHostConfig[] = [ + { + hostName: 'example.com', + type: 'folder', + target: '/path/to/site', + privateKey: '', + publicKey: '', + }, + // Include other configurations as needed + ]; + + mySmartVHost.setVHostConfigs(vHostConfigs); + + await mySmartVHost.start(); + console.log('SmartVHost started and serving configurations.'); + + // When you're done, don't forget to stop it + // await mySmartVHost.stop(); +} + +setupSmartVHost().catch(console.error); +``` + +This guide and examples should serve as a foundation to integrate and fully utilize smartvhost in your Node.js projects, thereby enhancing your web server's flexibility and efficiency in handling multiple domains or applications. + +For advanced use cases, refer to the module's typedoc documentation and explore the extensive API options provided for fine-tuned control over your virtual host configurations and behaviors. + +## 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.