Comparing version 2.2.9 to 2.3.0
@@ -5,6 +5,8 @@ <img src="./netget.png" alt="SVG Image" width="244" height="203"> | ||
**NetGet** is a modular gateway framework designed for Node.js applications. It provides a flexible routing mechanism to create and manage digital domains in a networked environment. | ||
# Unleash the Cyberspace Within | ||
It acts as a dynamic **gateway** to direct internet traffic to various local services based on domain names. It is particularly useful in environments where multiple services or applications must be accessible through a single entry point, commonly known as a **reverse proxy setup.** | ||
**NetGet** streamlines the orchestration of digital domains with the simplicity of a pedal's press, enabling seamless symphonies across networked realms. This **modular gateway framework,** designed for Node.js applications, acts as a dynamic conduit, **directing internet traffic to local services** with unparalleled ease. Inspired by the vast digital landscapes of cyberpunk lore, NetGet empowers developers to manage and expand their digital footprints without the complexities traditionally associated with network configurations. | ||
Visit [netget.me](https://netget.me) | ||
## Installation | ||
@@ -18,14 +20,2 @@ | ||
### Scalable Web Services | ||
In a microservices architecture, **NetGet can route requests to different services** within your infrastructure, making it an ideal solution for developers looking to scale their applications horizontally. Each service can have its own domain, and **NetGet** will ensure that requests are forwarded to the correct service. | ||
### Development and Testing | ||
During the development phase, NetGet can be employed to simulate a production environment where multiple domains point to different local services. This allows developers to test domain-based routing without the need to deploy to a live server. | ||
### Personal Hosting Solutions | ||
For personal web hosting, **NetGet** provides an **easy-to-set-up gateway** for routing traffic to various self-hosted applications. Users with several web applications running on a home server can use NetGet to manage access to these applications through different domains. | ||
## Usage | ||
@@ -37,8 +27,4 @@ | ||
import { Gateway } from 'netget'; | ||
// Configure your gateway instance | ||
const gateway = new Gateway({ | ||
port: 3000, | ||
domainsConfigPath: './config/domains.json' | ||
}); | ||
// Start the gateway | ||
// Initialize and configure your Gateway | ||
const gateway = new Gateway(); | ||
gateway.listen(); | ||
@@ -63,2 +49,16 @@ ``` | ||
By default, NetGet searches for a `domains.json` configuration in the `./config` directory, streamlining the setup process. | ||
**NetGet** is particularly useful in environments where multiple services or applications must be accessible through a single entry point, commonly known as a **reverse proxy setup.** | ||
### Scalable Web Services | ||
In a microservices architecture, **NetGet can route requests to different services** within your infrastructure, making it an ideal solution for developers looking to scale their applications horizontally. Each service can have its own domain, and **NetGet** will ensure that requests are forwarded to the correct service. | ||
### Personal Hosting Solutions | ||
For personal web hosting, **NetGet** provides an **easy-to-set-up gateway** for routing traffic to various self-hosted applications. Users with several web applications running on a home server can use **NetGet** to manage access to these applications through different domains. | ||
### Secure Access Control | ||
@@ -76,3 +76,3 @@ | ||
By using NetGet, developers and system administrators can create a more organized and efficient network topology, where the flow of requests is handled systematically, aligning with the concept of futuristic control and management of digital spaces as depicted in cyberpunk narratives. | ||
By using **NetGet,** developers and system administrators can create a more organized and efficient network topology, where the flow of requests is handled systematically, aligning with the concept of futuristic control and management of digital spaces. | ||
@@ -79,0 +79,0 @@ ------ |
{ | ||
"name": "netget", | ||
"version": "2.2.9", | ||
"version": "2.3.0", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -5,6 +5,8 @@ <img src="./netget.png" alt="SVG Image" width="244" height="203"> | ||
**NetGet** is a modular gateway framework designed for Node.js applications. It provides a flexible routing mechanism to create and manage digital domains in a networked environment. | ||
# Unleash the Cyberspace Within | ||
It acts as a dynamic **gateway** to direct internet traffic to various local services based on domain names. It is particularly useful in environments where multiple services or applications must be accessible through a single entry point, commonly known as a **reverse proxy setup.** | ||
**NetGet** streamlines the orchestration of digital domains with the simplicity of a pedal's press, enabling seamless symphonies across networked realms. This **modular gateway framework,** designed for Node.js applications, acts as a dynamic conduit, **directing internet traffic to local services** with unparalleled ease. Inspired by the vast digital landscapes of cyberpunk lore, NetGet empowers developers to manage and expand their digital footprints without the complexities traditionally associated with network configurations. | ||
Visit [netget.me](https://netget.me) | ||
## Installation | ||
@@ -18,14 +20,2 @@ | ||
### Scalable Web Services | ||
In a microservices architecture, **NetGet can route requests to different services** within your infrastructure, making it an ideal solution for developers looking to scale their applications horizontally. Each service can have its own domain, and **NetGet** will ensure that requests are forwarded to the correct service. | ||
### Development and Testing | ||
During the development phase, NetGet can be employed to simulate a production environment where multiple domains point to different local services. This allows developers to test domain-based routing without the need to deploy to a live server. | ||
### Personal Hosting Solutions | ||
For personal web hosting, **NetGet** provides an **easy-to-set-up gateway** for routing traffic to various self-hosted applications. Users with several web applications running on a home server can use NetGet to manage access to these applications through different domains. | ||
## Usage | ||
@@ -37,8 +27,4 @@ | ||
import { Gateway } from 'netget'; | ||
// Configure your gateway instance | ||
const gateway = new Gateway({ | ||
port: 3000, | ||
domainsConfigPath: './config/domains.json' | ||
}); | ||
// Start the gateway | ||
// Initialize and configure your Gateway | ||
const gateway = new Gateway(); | ||
gateway.listen(); | ||
@@ -63,2 +49,16 @@ ``` | ||
By default, NetGet searches for a `domains.json` configuration in the `./config` directory, streamlining the setup process. | ||
**NetGet** is particularly useful in environments where multiple services or applications must be accessible through a single entry point, commonly known as a **reverse proxy setup.** | ||
### Scalable Web Services | ||
In a microservices architecture, **NetGet can route requests to different services** within your infrastructure, making it an ideal solution for developers looking to scale their applications horizontally. Each service can have its own domain, and **NetGet** will ensure that requests are forwarded to the correct service. | ||
### Personal Hosting Solutions | ||
For personal web hosting, **NetGet** provides an **easy-to-set-up gateway** for routing traffic to various self-hosted applications. Users with several web applications running on a home server can use **NetGet** to manage access to these applications through different domains. | ||
### Secure Access Control | ||
@@ -76,3 +76,3 @@ | ||
By using NetGet, developers and system administrators can create a more organized and efficient network topology, where the flow of requests is handled systematically, aligning with the concept of futuristic control and management of digital spaces as depicted in cyberpunk narratives. | ||
By using **NetGet,** developers and system administrators can create a more organized and efficient network topology, where the flow of requests is handled systematically, aligning with the concept of futuristic control and management of digital spaces. | ||
@@ -79,0 +79,0 @@ ------ |
@@ -13,17 +13,22 @@ /* | ||
import morgan from 'morgan'; | ||
import initializeRoutes from './routes/routes.js'; | ||
import { loadDomainConfig } from './config/domainConfigUtils.js'; | ||
// Calculate the equivalent of __dirname in ES Module scope | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
/** | ||
* Represents a gateway server with customizable settings. | ||
* Class representing a customizable gateway server using Express.js. | ||
*/ | ||
class Gateway { | ||
/** | ||
* Initializes a new instance of the Gateway class. | ||
* @param {Object} config - Configuration options for the server. | ||
* @param {number} [config.port=3000] - The port number on which the server will listen. | ||
* @param {string} [config.domainsConfigPath='./config/domains.json'] - Path to the domains configuration file. | ||
* Creates a Gateway instance with provided configuration. | ||
* @param {Object} config Configuration for the Gateway. | ||
* @param {number} [config.port=3000] Port on which the server will listen. | ||
* @param {string} [config.domainsConfigPath='./config/domains.json'] Path to the domain configuration file. | ||
*/ | ||
constructor({ port = 3000, domainsConfigPath = './config/domains.json' } = {}) { | ||
this.port = port; | ||
// Resolve the absolute path to the configuration file | ||
this.domainsConfigPath = path.join(path.dirname(fileURLToPath(import.meta.url)), domainsConfigPath); | ||
// Adjust the path to the domains configuration file | ||
this.domainsConfigPath = path.resolve(__dirname, domainsConfigPath); | ||
this.app = express(); | ||
@@ -34,24 +39,29 @@ this.initialize().catch(err => console.error('Initialization error:', err)); | ||
/** | ||
* Asynchronously initializes the server, setting up static file serving, view engine, and domain routing. | ||
* Initializes the server setup including static file serving, view engine setup, and domain routing. | ||
*/ | ||
async initialize() { | ||
// Calculate the base directory for the gateway, assuming the gateway class is in 'src' | ||
const baseDir = path.dirname(fileURLToPath(import.meta.url)); | ||
this.app.use(express.static(path.join(baseDir, 'ejsApp', 'public'))); | ||
this.app.set('view engine', 'ejs'); | ||
this.app.set('views', path.join(baseDir, 'ejsApp', 'views')); | ||
this.app.use(morgan('dev')); // 'dev' is a predefined format string in Morgan | ||
// Define a route handler for the root path to render the index.ejs view | ||
this.app.get('/', (req, res) => { | ||
res.render('index', { title: 'Gateway Initiated.' }); | ||
}); | ||
// Calculate the base directory for the gateway, assuming the gateway class is in 'src' | ||
const baseDir = path.dirname(fileURLToPath(import.meta.url)); | ||
this.app.use(express.static(path.join(baseDir, 'ejsApp', 'public'))); | ||
this.app.set('view engine', 'ejs'); | ||
this.app.set('views', path.join(baseDir, 'ejsApp', 'views')); | ||
// Use morgan for logging | ||
this.app.use(morgan('dev')); | ||
// Load the domain configuration | ||
await this.loadDomainConfig(); | ||
// Initialize and use the routes with the provided domainsConfigPath | ||
// This should come after loading your domain configuration and before starting the server | ||
const router = initializeRoutes(this.domainsConfigPath); | ||
this.app.use(router); | ||
} | ||
/** | ||
* Asynchronously loads the domain configuration from the specified JSON file. | ||
* Loads the domain configuration from a specified JSON file. | ||
*/ | ||
async loadDomainConfig() { | ||
try { | ||
const config = JSON.parse(await fs.readFile(this.domainsConfigPath, 'utf-8')); | ||
// Pass the resolved path to the utility function | ||
const config = await loadDomainConfig(this.domainsConfigPath); | ||
console.log('Loaded Domain Configuration:', config); | ||
@@ -65,3 +75,3 @@ } catch (err) { | ||
/** | ||
* Starts the server, making it listen on the configured port. | ||
* Starts listening on the configured port. | ||
*/ | ||
@@ -71,3 +81,2 @@ listen() { | ||
console.log(`Gateway listening at http://localhost:${this.port}`); | ||
// Potentially log more about the loaded configuration | ||
}); | ||
@@ -79,4 +88,1 @@ } | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1633073
39
517
2