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

moleculer-web

Package Overview
Dependencies
Maintainers
1
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
57

0.5.1

Diff

Changelog

Source

0.5.1 (2017-10-07)

New

  • add CORS headers
  • add Rate limiter

<a name="0.5.0"></a>

icebob
published 0.5.0 •

Changelog

Source

0.5.0 (2017-09-12)

Breaking changes

  • compatibility with Moleculer >= v0.11.x

<a name="0.4.4"></a>

icebob
published 0.4.4 •

Changelog

Source

0.4.4 (2017-08-20)

Changes

  • update Moleculer to v0.10

<a name="0.4.1"></a>

icebob
published 0.4.3 •

icebob
published 0.4.2 •

icebob
published 0.4.1 •

Changelog

Source

0.4.1 (2017-07-24)

New

Prohibited action with publish: false action properties

module.exports = {
    name: "test",
    actions: {
        dangerZone: {
            publish: false,
            handler(ctx) {
                return "You cannot call this action via API Gateway!";
            }
        }
    }
};

Calling options in routes

The route has a callOptions property which is passed to broker.call. So you can set timeout, retryCount or fallbackResponse options for routes.

broker.createService(ApiGatewayService, {
    settings: {
        routes: [{
            
            callOptions: {
                timeout: 1000, // 1 sec
                retryCount: 0,
                //fallbackResponse: { ... },
                // or 
                //fallbackResponse(ctx, err) { ... }
            }

        }]
    }
});

<a name="0.4.0"></a>

icebob
published 0.4.0 •

Changelog

Source

0.4.0 (2017-07-07)

Breaking changes

  • in the REST shorthand, the GET / calls the list action instead of find. The reason is list action in moleculer-db is support pagination

Changes

  • changed order of param handling ctx.params = Object.assign({}, body, query, params).
  • moved onBeforeCall before authorize in request flow. So you can also reach unauthorized requests in onBeforeCall handler.
  • the sendResponse method has new arguments: sendResponse(ctx, route, req, res, data, responseType)

<a name="0.3.3"></a>

icebob
published 0.3.3 •

Changelog

Source

0.3.3 (2017-06-07)

New

Functions in aliases

There is available to use custom function in aliases. In this case you got req & res and you should return with the response. Use it for example file uploads. You can find example in the full example.

Usage

    ...
        aliases: {
            "add/:a/:b": "math.add",
            "GET sub": "math.sub",
            "POST upload"(route, req, res) {
                //Do something and call res.end()
            }
        }
    ...

New camelCaseNames route setting

There is a new camelCaseNames option in route setting. If it is true, the service will convert the received action name to camelCase name.

Usage

broker.createService(ApiGatewayService, {
    settings: {
        routes: [{
            camelCaseNames: true
        }]
    }
});

broker.createService({
    name: "test",
    actions: {
        sayHi(ctx) {
            return "Hi!"
        }
    }
});

// Start server
broker.start();

In the above example the sayHi action can be called with http://localhost:3000/test/say-hi as well.


<a name="0.3.2"></a>

icebob
published 0.3.2 •

Changelog

Source

0.3.2 (2017-06-02)

New

Exposed error classes

Available errors:

| Class | Params | Description | | ----- | ------ | ----------- | |UnAuthorizedError|type, data| Unauthorized HTTP error (401) | |ForbiddenError|type, data| Forbidden HTTP error (403) | |BadRequestError|type, data| Bad Request HTTP error (400) |

Type contants:

  • ERR_NO_TOKEN
  • ERR_INVALID_TOKEN
  • ERR_UNABLE_DECODE_PARAM

Usage

const { UnAuthorizedError, ERR_NO_TOKEN } = require("moleculer-web").Errors;
    ...
    actions: {
        update(ctx) {
            if(!ctx.meta.user)
                return Promise.reject(new UnAuthorizedError(ERR_NO_TOKEN));
        }
    }
    ...

<a name="0.3.1"></a>

icebob
published 0.3.1 •

Changelog

Source

0.3.1 (2017-06-02)

New

RESTful routes

It is possible to use RESTful aliases which routed to CRUD service actions.

Usage

broker.createService(ApiGatewayService, {
    settings: {
        routes: [{
            // RESTful aliases
            aliases: {
                "REST posts": "posts"
            }
        }]
    }
});

// Start server
broker.start();

The "REST posts": "posts" will be extracted to these aliases:

"GET posts":        "posts.find",
"GET posts/:id":    "posts.get",
"POST posts":       "posts.create",
"PUT posts/:id":    "posts.update",
"DELETE posts/:id": "posts.remove"				

Example: examples/rest


<a name="0.3.0"></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