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

@ekino/rendr-core

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ekino/rendr-core - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

5

dist/_bundles/rendr-core.d.ts

@@ -66,3 +66,4 @@ /// <reference types="node" />

req: IncomingMessage;
res: ServerResponse;
res?: ServerResponse;
settings: Settings;
}

@@ -90,4 +91,4 @@ export interface Normalizer {

url: string;
}, res: ServerResponse): RequestCtx;
}, res?: ServerResponse): RequestCtx;
export function mergePages(pages: Page[]): Page;
}

27

dist/_bundles/rendr-core.js

@@ -25,2 +25,9 @@ var __extends = (this && this.__extends) || (function () {

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -77,3 +84,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Not Found Exception", args), { stack: new Error().stack, name: "NotFoundError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Not Found Exception", args)), { stack: new Error().stack, name: "NotFoundError" }));
return _this;

@@ -92,3 +99,3 @@ }

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Internal Server Error", args), { stack: new Error().stack, name: "InternalServerError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Internal Server Error", args)), { stack: new Error().stack, name: "InternalServerError" }));
return _this;

@@ -107,3 +114,3 @@ }

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Normalization Error", args), { stack: new Error().stack, name: "NormalizationError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Normalization Error", args)), { stack: new Error().stack, name: "NormalizationError" }));
return _this;

@@ -251,6 +258,7 @@ }

function createContext(req, res) {
var isServerSide = res ? true : false;
var isServerSide = false;
var fullUrl = req.url;
var asPath = req.url;
var fullUrl = req.url;
if (req instanceof http_1.IncomingMessage) {
isServerSide = true;
fullUrl = "https://" + req.headers["host"] + req.url;

@@ -268,3 +276,4 @@ }

req: isServerSide ? req : null,
res: isServerSide ? res : null
res: isServerSide ? res : null,
settings: {}
};

@@ -290,3 +299,3 @@ return ctx;

: page.head.htmlAttributes,
meta: page.head.meta.concat(p.head.meta)
meta: __spreadArrays(page.head.meta, p.head.meta)
};

@@ -298,4 +307,4 @@ page.path = p.path;

page.statusCode = p.statusCode;
page.settings = __assign({}, page.settings, p.settings);
page.blocks = page.blocks.concat(p.blocks);
page.settings = __assign(__assign({}, page.settings), p.settings);
page.blocks = __spreadArrays(page.blocks, p.blocks);
});

@@ -302,0 +311,0 @@ return page;

@@ -70,3 +70,3 @@ var __extends = (this && this.__extends) || (function () {

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Not Found Exception", args), { stack: new Error().stack, name: "NotFoundError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Not Found Exception", args)), { stack: new Error().stack, name: "NotFoundError" }));
return _this;

@@ -85,3 +85,3 @@ }

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Internal Server Error", args), { stack: new Error().stack, name: "InternalServerError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Internal Server Error", args)), { stack: new Error().stack, name: "InternalServerError" }));
return _this;

@@ -100,3 +100,3 @@ }

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Normalization Error", args), { stack: new Error().stack, name: "NormalizationError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Normalization Error", args)), { stack: new Error().stack, name: "NormalizationError" }));
return _this;

@@ -103,0 +103,0 @@ }

@@ -15,3 +15,3 @@ /// <reference types="node" />

url: string;
}, res: ServerResponse): RequestCtx;
}, res?: ServerResponse): RequestCtx;
export declare function mergePages(pages: Page[]): Page;

@@ -12,2 +12,9 @@ var __assign = (this && this.__assign) || function () {

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
import { Page } from "./types";

@@ -110,6 +117,7 @@ import { IncomingMessage } from "http";

export function createContext(req, res) {
var isServerSide = res ? true : false;
var isServerSide = false;
var fullUrl = req.url;
var asPath = req.url;
var fullUrl = req.url;
if (req instanceof IncomingMessage) {
isServerSide = true;
fullUrl = "https://" + req.headers["host"] + req.url;

@@ -127,3 +135,4 @@ }

req: isServerSide ? req : null,
res: isServerSide ? res : null
res: isServerSide ? res : null,
settings: {}
};

@@ -148,3 +157,3 @@ return ctx;

: page.head.htmlAttributes,
meta: page.head.meta.concat(p.head.meta)
meta: __spreadArrays(page.head.meta, p.head.meta)
};

@@ -156,4 +165,4 @@ page.path = p.path;

page.statusCode = p.statusCode;
page.settings = __assign({}, page.settings, p.settings);
page.blocks = page.blocks.concat(p.blocks);
page.settings = __assign(__assign({}, page.settings), p.settings);
page.blocks = __spreadArrays(page.blocks, p.blocks);
});

@@ -160,0 +169,0 @@ return page;

@@ -46,3 +46,4 @@ /// <reference types="node" />

req: IncomingMessage;
res: ServerResponse;
res?: ServerResponse;
settings: Settings;
}

@@ -49,0 +50,0 @@ export interface Normalizer {

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

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Not Found Exception", args), { stack: new Error().stack, name: "NotFoundError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Not Found Exception", args)), { stack: new Error().stack, name: "NotFoundError" }));
return _this;

@@ -87,3 +87,3 @@ }

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Internal Server Error", args), { stack: new Error().stack, name: "InternalServerError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Internal Server Error", args)), { stack: new Error().stack, name: "InternalServerError" }));
return _this;

@@ -102,3 +102,3 @@ }

var _this = _super.call(this) || this;
Object.assign(_this, __assign({}, getErrorParameters("Normalization Error", args), { stack: new Error().stack, name: "NormalizationError" }));
Object.assign(_this, __assign(__assign({}, getErrorParameters("Normalization Error", args)), { stack: new Error().stack, name: "NormalizationError" }));
return _this;

@@ -105,0 +105,0 @@ }

@@ -15,3 +15,3 @@ /// <reference types="node" />

url: string;
}, res: ServerResponse): RequestCtx;
}, res?: ServerResponse): RequestCtx;
export declare function mergePages(pages: Page[]): Page;

@@ -13,2 +13,9 @@ "use strict";

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __export(m) {

@@ -125,6 +132,7 @@ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];

function createContext(req, res) {
var isServerSide = res ? true : false;
var isServerSide = false;
var fullUrl = req.url;
var asPath = req.url;
var fullUrl = req.url;
if (req instanceof http_1.IncomingMessage) {
isServerSide = true;
fullUrl = "https://" + req.headers["host"] + req.url;

@@ -142,3 +150,4 @@ }

req: isServerSide ? req : null,
res: isServerSide ? res : null
res: isServerSide ? res : null,
settings: {}
};

@@ -164,3 +173,3 @@ return ctx;

: page.head.htmlAttributes,
meta: page.head.meta.concat(p.head.meta)
meta: __spreadArrays(page.head.meta, p.head.meta)
};

@@ -172,4 +181,4 @@ page.path = p.path;

page.statusCode = p.statusCode;
page.settings = __assign({}, page.settings, p.settings);
page.blocks = page.blocks.concat(p.blocks);
page.settings = __assign(__assign({}, page.settings), p.settings);
page.blocks = __spreadArrays(page.blocks, p.blocks);
});

@@ -176,0 +185,0 @@ return page;

@@ -46,3 +46,4 @@ /// <reference types="node" />

req: IncomingMessage;
res: ServerResponse;
res?: ServerResponse;
settings: Settings;
}

@@ -49,0 +50,0 @@ export interface Normalizer {

{
"name": "@ekino/rendr-core",
"license": "MIT",
"version": "0.0.8",
"version": "0.0.9",
"main": "dist/lib/index.js",

@@ -13,3 +13,3 @@ "typing": "dist/lib/index.d.ts",

"devDependencies": {
"@types/node": "^12.7.2"
"@types/node": "^12.7.4"
},

@@ -23,3 +23,3 @@ "scripts": {

},
"gitHead": "404863fc0ca84698556c72b465261ed1431402af"
"gitHead": "bfb72cae87ba375224002b81bf3e468c6ba60b88"
}

@@ -1,2 +0,3 @@

import { createPage, mergePages, Page } from "./index";
import { createPage, mergePages, Page, createContext } from "./index";
import { IncomingMessage } from "http";

@@ -110,1 +111,21 @@ describe("test create page", () => {

});
describe("test createContext", () => {
it("test clientSide context", () => {
const ctx = createContext({ url: "https://ekino.com/foobar?foo=bar" });
expect(ctx.isClientSide).toBeTruthy();
expect(ctx.isServerSide).toBeFalsy();
expect(ctx).toMatchSnapshot();
// try to set a setting
ctx.settings["foo"] = "bar";
expect(ctx).toMatchSnapshot();
});
it("test server side context", () => {
// need to think about a clean way of mocking the IncomingMessage... without
// no much of boilerplate.
});
});

@@ -133,10 +133,12 @@ import { Page, Cache, Head, BlockDefinition, RequestCtx } from "./types";

req: IncomingMessage | { url: string },
res: ServerResponse
res?: ServerResponse
): RequestCtx {
const isServerSide = res ? true : false;
// default to client, why not!
let isServerSide = false;
let fullUrl = req.url;
const asPath = req.url;
let fullUrl = req.url;
if (req instanceof IncomingMessage) {
isServerSide = true;
fullUrl = `https://${req.headers["host"]}${req.url}`;

@@ -161,3 +163,4 @@ }

// @ts-ignore
res: isServerSide ? res : null
res: isServerSide ? res : null,
settings: {}
};

@@ -164,0 +167,0 @@

@@ -62,3 +62,6 @@ import { IncomingMessage, ServerResponse } from "http";

req: IncomingMessage;
res: ServerResponse;
res?: ServerResponse;
// anything that need to be set during the life time of the request,
// this data will no be exposed on the end user.
settings: Settings;
}

@@ -65,0 +68,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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