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

@plumier/generic-controller

Package Overview
Dependencies
Maintainers
1
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plumier/generic-controller - npm Package Compare versions

Comparing version 1.0.0-canary.kd3mpv1u.0 to 1.0.0-canary.kd3rqvd4.0

42

lib/facility.js

@@ -22,3 +22,3 @@ "use strict";

}
function copyDecorators(decorators) {
function copyDecorators(decorators, controller) {
const result = [];

@@ -33,5 +33,31 @@ for (const decorator of decorators) {

if (authDec.type === "plumier-meta:authorize") {
result.push(decorator);
// @authorize.role() should applied to all actions
if (authDec.access === "all") {
result.push(decorator);
continue;
}
const meta = tinspector_1.default(controller);
const findAction = (...methods) => {
const result = [];
for (const action of meta.methods) {
if (action.decorators.some((x) => x.name === "plumier-meta:route"
&& methods.some(m => m === x.method)))
result.push(action.name);
}
return result;
};
// add extra action filter for decorator @authorize.get() and @authorize.set()
// get will only applied to actions with GET method
// set will only applied to actions with mutation DELETE, PATCH, POST, PUT
if (authDec.access === "get") {
authDec.action = findAction("get");
result.push(decorator);
}
if (authDec.access === "set") {
authDec.action = findAction("delete", "patch", "post", "put");
result.push(decorator);
}
}
}
//reflect(ctl, { flushCache: true })
return result;

@@ -54,5 +80,4 @@ }

const meta = tinspector_1.default(entity);
decorateController(Controller, copyDecorators(meta.decorators));
Reflect.decorate([core_1.route.root(path)], Controller);
Reflect.decorate([core_1.api.tag(entity.name)], Controller);
decorateController(Controller, copyDecorators(meta.decorators, controller));
Reflect.decorate([core_1.route.root(path), core_1.api.tag(entity.name)], Controller);
return Controller;

@@ -75,9 +100,10 @@ }

const decorators = meta.properties.find(x => x.name === dec.propertyName).decorators;
decorateController(Controller, copyDecorators(decorators));
decorateController(Controller, copyDecorators(decorators, controller));
Reflect.decorate([
core_1.route.root(path),
core_1.api.tag(dec.parentType.name),
// re-assign oneToMany decorator which will be used on OneToManyController constructor
tinspector_1.decorateClass(dec)
tinspector_1.decorateClass(dec),
], Controller);
Reflect.decorate([core_1.api.tag(dec.parentType.name)], Controller);
Reflect.decorate([], Controller);
return Controller;

@@ -84,0 +110,0 @@ }

6

package.json
{
"name": "@plumier/generic-controller",
"version": "1.0.0-canary.kd3mpv1u.0+24bb431",
"version": "1.0.0-canary.kd3rqvd4.0+ae9b8e1",
"description": "Plumier generic controller implementation",

@@ -18,3 +18,3 @@ "main": "lib/index.js",

"dependencies": {
"@plumier/core": "1.0.0-canary.kd3mpv1u.0+24bb431",
"@plumier/core": "1.0.0-canary.kd3rqvd4.0+ae9b8e1",
"@types/pluralize": "^0.0.29",

@@ -33,3 +33,3 @@ "pluralize": "^8.0.0"

},
"gitHead": "24bb431acdcec517c3dafb55812e9b6014134ed8"
"gitHead": "ae9b8e103ae6be253ab3cebf401a0e34689da1c8"
}
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