Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moleculer-web

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moleculer-web - npm Package Versions

1
7

0.6.2

Diff

Changelog

Source

0.6.2 (2018-01-15)

Changes

  • turnable pre-validation with preValidate setting. Default to true in order to backward compatibility.
    broker.createService({
        mixins: [ApiService],
        settings: {
            // Disable pre-validation at action calls
            preValidate: false
        }
    })
    

<a name="0.6.1"></a>

icebob
published 0.6.1 •

Changelog

Source

0.6.1 (2018-01-07)

Changes

  • fix CORS OPTIONS handling. #30

<a name="0.6.0"></a>

icebob
published 0.6.0 •

Changelog

Source

0.6.0 (2018-01-04)

Breaking changes

Alias custom function arguments is changed

The route first argument is removed. The new signature of function is function(req, res) {}. To access to route use the req.$route property. However you can use an array of Function for aliases. With it you can call middlewares. In this case the third argument is next. I.e.: function(req, res, next) {}.

Other changes

  • better error handling. Always returns with JSON error response.
  • The charset is UTF-8 for application/json responses.
  • logRequestParams setting to log the request parameters. Use log level value i.e. "debug", "info" or null to disable.
  • logResponseData setting to log the response data. Use log level value i.e. "debug", "info" or null to disable.
  • req.$service & res.$service is pointed to the service instance.
  • req.$route & res.$route is pointed to the route definition.
  • req.$params is pointed to the resolved parameters (from query string & post body)
  • req.$alias is pointed to the alias definition.
  • req.$endpoint is pointed to the resolved action endpoint. It contains action and nodeID.

Middlewares

Support middlewares in global, routes & aliases.

broker.createService({
    mixins: [ApiService],
    settings: {
        // Global middlewares. Applied to all routes.
        use: [
            cookieParser(),
            helmet()
        ],

        routes: [
            {
                path: "/",

                // Route-level middlewares.
                use: [
                    compression(),
                    
                    passport.initialize(),
                    passport.session(),

                    serveStatic(path.join(__dirname, "public"))
                ],
                
                aliases: {
                    "GET /secret": [
                        // Alias-level middlewares.
                        auth.isAuthenticated(),
                        auth.hasRole("admin"),
                        "top.secret" // Call the `top.secret` action
                    ]
                }
            }
        ]
    }
});

Custom response headers

It supports custom response headers to define in action definition.

module.exports = {
    name: "export",
    actions: {
        downloadCSV: 
            responseHeaders: {
                "Content-Disposition": "attachment; filename=\"data.csv\"",
                "Content-Type": "text/csv"
            },
            handler() {
                return "...";
            }
        }
    }
}

Error handlers

You can add route & global custom error handlers.

broker.createService({
    mixins: [ApiService],
    settings: {

        routes: [{
            path: "/api",

            // Route error handler
            onError(req, res, err) {
                res.setHeader("Content-Type", "application/json; charset=utf-8");
                res.writeHead(500);
                res.end(JSON.stringify(err));
            }
        }],

        // Global error handler
        onError(req, res, err) {
            res.setHeader("Content-Type", "text/plain");
            res.writeHead(501);
            res.end("Global error: " + err.message);
        }		
    }
}

New examples to serve client-side developing with Webpack


<a name="0.5.2"></a>

icebob
published 0.6.0-beta7 •

icebob
published 0.6.0-beta6 •

icebob
published 0.6.0-beta5 •

icebob
published 0.6.0-beta4 •

icebob
published 0.6.0-beta3 •

icebob
published 0.6.0-beta1 •

icebob
published 0.5.2 •

Changelog

Source

0.5.2 (2017-10-24)

New

  • add mappingPolicy route option

<a name="0.5.1"></a>

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