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

@eclipse-emfcloud/modelserver-node

Package Overview
Dependencies
Maintainers
8
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-emfcloud/modelserver-node

Business Logic layer façade for the Model Server.

  • 0.2.0-next.4b57c0e.50
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
8
Weekly downloads
 
Created
Source

Model Server Server Framework

This package provides the Model Server server framework.

Setup

See the parent readme for details of how to set up and build the project.

Routing Mechanism

Route providers create interceptors for endpoints (GET/POST/PUT..) via the routerFactory:

const router = routerFactory('/api/v2');
router.get('/my-endpoint', myInterceptingHandler());
// OR
routerFactory('/api/v2(my-endpoint').get('/', myInterceptingHandler());

This intercepting handler can:

  • handle the request by executing custom behaviour and not forwarding
  • handle the request by executing custom behaviour and forwarding to the next upstream
    • executing custom behaviour and then forward to the next upstream via return next(); (see also example below)
  • simply forward to the next upstream without any custom behaviour
    • forward directly to the next upstream via return next();. Please keep in mind that forwarding uses the requests'url to forward to the next upstream.
  • pass and stop execution
    • if no custom behaviour is executed and no forward to upstream is triggered, the chain ends here

Important: If the chain is stopped by your route provider, please always ensure that the execution is also formally ended and a response is sent:

res.end();

Model Uri Validation

The route-utils provides a utility wrapper hook that validates the model uri beforehand and passes it on to the intercepting handler via:

export function myInterceptingHandler(): ModelRequestHandler {
    return async (req: ModelRequest, res: Response, next: NextFunction) => {
        withValidatedModelUri(req, res, async validatedModelUri => {
            // execute some custom behaviour with the validated model uri
            ...
            // AND/OR forward request to upstream with validated model uri
            return next();
        });
    };
}

This example uses the validated model uri in some custom behaviour, and eventually forwards the request to the next upstream (via return next()).

Binding of Route Providers

The default route providers are currently all bound in one container module This is not optimal and unconvenient, for more details please see Issue #64 which aims to improve the module handling.

FAQs

Package last updated on 15 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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