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

@azure-iot/hal

Package Overview
Dependencies
Maintainers
28
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure-iot/hal - npm Package Compare versions

Comparing version 1.0.0-rc.10 to 1.0.0-rc.11

2

package.json
{
"name": "@azure-iot/hal",
"description": "Decorator library for HAL-based routes",
"version": "1.0.0-rc.10",
"version": "1.0.0-rc.11",
"scripts": {

@@ -6,0 +6,0 @@ "prebuild": "npm run lint",

@@ -21,3 +21,3 @@ # @azure-iot/hal

* `options` [provides.Options.Namespace] *(optional)*:
* `href` [string]: The documentation link representing this namespace; this contains the placeholder 'rel' for the rels provided by the routes of this server, as per the HAL spec. It can accept either URI-template or Express syntax, though the latter is required for automated documentation. Default is '/docs/<namespace>/:rel'.
* `href` [string]: The documentation link representing this namespace; this contains the placeholder 'rel' for the rels provided by the routes of this server, as per the HAL spec. It can accept either URI-template or Express syntax, as per the `@route` decorator. Default is '/docs/<namespace>/:rel'.
* `auto` [boolean]: Indicates whether to automatically generate documentation from the `description` attributes, described below; default is false if `href` is specified, true otherwise.

@@ -24,0 +24,0 @@

@@ -13,3 +13,3 @@ import * as express from 'express';

provides(namespace?: string, options?: provides.Options.Namespace): this;
middleware(handler: express.RequestHandler | express.ErrorRequestHandler, options?: middleware.Options): this;
middleware(handler: express.RequestHandler | express.ErrorHandler, options?: middleware.Options): this;
}

@@ -16,0 +16,0 @@ class Method extends Api {

@@ -15,3 +15,3 @@ import * as express from 'express';

interface Middleware {
handler: express.RequestHandler | express.ErrorRequestHandler;
handler: express.RequestHandler | express.ErrorHandler;
options: middleware.Options;

@@ -18,0 +18,0 @@ }

@@ -89,2 +89,5 @@ export declare enum Method {

export declare type Rel = string | LinkRelation;
export declare namespace Rel {
const Param: string;
}
export declare namespace Hal {

@@ -91,0 +94,0 @@ interface Link {

@@ -91,2 +91,6 @@ "use strict";

var LinkRelation = exports.LinkRelation;
var Rel;
(function (Rel) {
Rel.Param = 'rel';
})(Rel = exports.Rel || (exports.Rel = {}));
//# sourceMappingURL=constants.js.map

@@ -44,3 +44,3 @@ import * as express from 'express';

export declare function route(verb: Verb, path: string): MethodDecorator;
export declare function middleware(handler: express.RequestHandler | express.ErrorRequestHandler, options?: middleware.Options): ClassDecorator & MethodDecorator;
export declare function middleware(handler: express.RequestHandler | express.ErrorHandler, options?: middleware.Options): ClassDecorator & MethodDecorator;
export declare namespace middleware {

@@ -47,0 +47,0 @@ interface Options {

@@ -9,3 +9,3 @@ import * as express from 'express';

private _initialize(resolved);
json(original: express.Send, data: any): express.Response;
json(original: (obj: any) => express.Response, data: any): express.Response;
private _resolve(rel, overrides);

@@ -12,0 +12,0 @@ private _docs(resolved);

@@ -108,6 +108,8 @@ "use strict";

if (!_private(_private(this).root).hal.getLink(CURIES, (link) => link.name === name)) {
let params = Object.assign({}, _private(this).params);
delete params[constants_1.Rel.Param];
_private(_private(this).root).hal.addLink(CURIES, template_1.Template.link({
href: href,
id: name,
params: {}
params: params
}));

@@ -114,0 +116,0 @@ }

@@ -40,7 +40,7 @@ "use strict";

return (req, res, next) => {
if (!req.params.rel) {
if (!req.params[constants_1.Rel.Param]) {
res.sendStatus(404);
}
let doc = '';
linker_1.Linker.handle(null, ns + ':' + req.params.rel, (server, route, links) => {
linker_1.Linker.handle(null, ns + ':' + req.params[constants_1.Rel.Param], (server, route, links) => {
doc += `<h1>${route}</h1>`;

@@ -88,4 +88,3 @@ links.forEach(link => {

const handlers = method.hal.length === 0 ? middleware : middleware.concat((req, res, next) => response_1.Response.create(server, path(req), links, req, res) && next());
const uri = template_1.Template.is(route.path) ? template_1.Template.express(route.path) : route.path;
app[route.verb.toLowerCase()].call(app, uri, handlers, handler);
app[route.verb.toLowerCase()].call(app, template_1.Template.express(route.path), handlers, handler);
}

@@ -120,6 +119,6 @@ else {

for (let provides of proto.provides) {
const href = provides.options.href || `/docs/${provides.namespace}/:rel`;
const href = provides.options.href || `/docs/${provides.namespace}/:${constants_1.Rel.Param}`;
linker_1.Linker.registerDocs(server, provides.namespace, href);
if ((typeof provides.options.auto === 'undefined' && typeof provides.options.href === 'undefined') || provides.options.auto) {
app.get(href, Server.autodoc(provides.namespace));
app.get(template_1.Template.express(href), Server.autodoc(provides.namespace));
}

@@ -126,0 +125,0 @@ }

import { Hal } from './constants';
import { hal } from './decorators';
export declare class Template {
private static parse;
private static l1;
private static l4;
private static params(href);
private static decode(href);
static apply(href: string, params: any): string;
static is(href: string): boolean;
static link(resolved: hal.Overrides): Hal.Link;
static express(href: string): string;
}

@@ -20,7 +20,7 @@ "use strict";

static decode(href) {
return href.replace(/%7B(.+)%7D/, param => decodeURIComponent(param));
return href.replace(/%7B.+?%7D/g, param => decodeURIComponent(param));
}
static apply(href, params) {
if (Template.is(href)) {
return href.replace(Template.parse, (match, variable) => typeof params[variable] !== 'undefined' ? params[variable] : match);
if (Template.l1.test(href)) {
return href.replace(Template.l1, (match, variable) => typeof params[variable] !== 'undefined' ? params[variable] : match);
}

@@ -31,5 +31,2 @@ else {

}
static is(href) {
return Template.parse.test(href);
}
static link(resolved) {

@@ -40,3 +37,3 @@ let link = { href: resolved.href };

}
if (Template.is(link.href)) {
if (Template.l4.test(link.href)) {
link.templated = true;

@@ -53,8 +50,12 @@ }

static express(href) {
let route = href.replace(Template.parse, (match, variable) => `:${variable}`);
if (!Template.l1.test(href)) {
return href;
}
let route = href.replace(Template.l1, (match, variable) => `:${variable}`);
return url.parse(route).pathname;
}
}
Template.parse = /\{\W?(\w+)*?\}/g;
Template.l1 = /\{(\w+)\}/g;
Template.l4 = /\{\W?([\w\:\*\,]+)\}/g;
exports.Template = Template;
//# sourceMappingURL=template.js.map
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