New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

netget

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netget - npm Package Compare versions

Comparing version 2.3.34 to 2.3.35

docs/src_handlers_defaultHandler.js.html

3

index.js
/**
* Entry point of the application.
* It exports all NetGet tools.
* default exports NetGet
*
* @module index

@@ -5,0 +6,0 @@ */

{
"source": {
"include": ["./src/","./src/Gateway.js", "./index.js", "./tests/"]
"include": ["./src/","./src/gateway.js", "./src/netget.js", "./src/routes/defaultRoutes.js", "./src/routes/routes.js", "./index.js", "./tests/"]
},

@@ -5,0 +5,0 @@ "opts": {

{
"name": "netget",
"version": "2.3.34",
"version": "2.3.35",
"description": "Rette Adepto/ Recibido Directamente.",

@@ -5,0 +5,0 @@ "type": "module",

import express from 'express';
import path from 'path';
import morgan from 'morgan';
import defaultHandler from './handlers/defaultHandler.js';
import defaultRoutes from './handlers/defaultRoutes.js';
import { fileURLToPath } from 'url';

@@ -22,3 +22,3 @@

this.port = port;
this.handlers = handlers;
this.routes = routes;
this.app = express();

@@ -37,7 +37,13 @@ this.initialize().catch(err => console.error('Initialization error:', err));

this.app.set('views', path.join(baseDir, 'ejsApp', 'views'));
morgan.token('host', (req) => req.hostname || req.headers['host'] || '-');
this.app.use(morgan(':method :url :status :res[content-length] - :response-time ms - Host: :host'));
// This middleware checks the request's hostname and uses the corresponding handler or the default one
/* This middleware checks the request's ::::::::hostname::::::and uses the corresponding handler or the default one.
Hard-coded and Dynamic Domain Handling in the Gateway ,
Define two methods.
1. Static object this.handlers for domains with predefined handlers.
2. Fetch Handler configurations dynamically from a PostgreSQL database v.path.mlisa.me,
for domains that require dynamic content serving, such as browser.pixelgrid.me/html.js.
this.app.use((req, res) => {

@@ -50,3 +56,10 @@ // Check if handlers object is empty (no handlers defined at all)

}
*/
this.app.use((req, res) => {
// Check if handlers object is empty (no handlers defined at all)
const noRoutesDefined = Object.keys(this.handlers).length === 0;
const routes = this.routes[req.hostname] || ((req, res) => defaultRoutes(req, res, noHRoutesDefined));
handler(req, res);
});
}
/**

@@ -53,0 +66,0 @@ * Starts the gateway, making it listen on the configured port.

@@ -24,5 +24,12 @@ import Gateway from '../src/gateway.js';

port: 3000,
domainsConfigPath: './config/domains.json'
routes: {
'example.com': (req, res) => {
res.send('Hello from example.com!');
},
'another.com': (req, res) => {
res.send('Hello from another.com!');
}
}
});
testGateway.listen();

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc