Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 10.0.0 #199

Merged
merged 3 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,432 changes: 690 additions & 742 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nzz/q-server",
"version": "9.0.1",
"version": "10.0.0",
"description": "",
"main": "index.js",
"scripts": {
Expand All @@ -25,31 +25,31 @@
},
"homepage": "https://github.com/nzzdev/Q-server#readme",
"dependencies": {
"@hapi/boom": "^7.4.3",
"@hapi/bounce": "^1.3.1",
"@hapi/hoek": "^8.2.5",
"@hapi/inert": "^5.2.2",
"@hapi/joi": "^15.1.1",
"@hapi/mimos": "^4.1.1",
"@hapi/vision": "^5.5.4",
"@hapi/wreck": "^15.1.0",
"ajv": "^6.10.2",
"aws-sdk": "^2.541.0",
"@hapi/boom": "^9.0.0",
"@hapi/bounce": "^2.0.0",
"@hapi/hoek": "^9.0.3",
"@hapi/inert": "^6.0.1",
"@hapi/joi": "^17.1.0",
"@hapi/mimos": "^5.0.0",
"@hapi/vision": "^6.0.0",
"@hapi/wreck": "^17.0.0",
"ajv": "^6.11.0",
"aws-sdk": "^2.618.0",
"clone": "^2.1.2",
"deepmerge": "^4.0.0",
"deepmerge": "^4.2.2",
"hasha": "^5.1.0",
"json-schema-ref-parser": "^7.1.1",
"json-schema-ref-parser": "^7.1.3",
"keycdn": "^0.2.2",
"nano": "^8.1.0",
"node-fetch": "^2.6.0",
"puppeteer": "^1.20.0",
"slugify": "^1.3.5",
"uuid": "^3.3.3"
"puppeteer": "^2.1.1",
"slugify": "^1.3.6",
"uuid": "^3.4.0"
},
"devDependencies": {
"@hapi/code": "^6.0.0",
"@hapi/hapi": "^18.4.0",
"@hapi/lab": "^20.3.2",
"@hapi/code": "^8.0.1",
"@hapi/hapi": "^19.1.1",
"@hapi/lab": "^22.0.3",
"confidence": "^4.0.2",
"pouchdb-server": "^4.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/core/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module.exports = {
if (err.isBoom) {
throw err;
}
throw new Boom(err.description, { statusCode: err.statusCode });
throw new Boom.Boom(err.description, { statusCode: err.statusCode });
}
});

Expand Down
2 changes: 1 addition & 1 deletion plugins/core/editor/configSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const target = Joi.object().pattern(
label: Joi.string().required(),
type: Joi.string()
.required()
.valid(["web", "AMP", "image", "application/json", "application/pdf"]),
.valid("web", "AMP", "image", "application/json", "application/pdf"),
context: Joi.object().keys({
stylesheets: Joi.array().items(
Joi.object().keys({ url: Joi.string().uri() })
Expand Down
2 changes: 1 addition & 1 deletion plugins/core/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
allowUnknown: true
}
);
if (targetConfigValidationResult.error !== null) {
if (targetConfigValidationResult.error) {
throw new Error(targetConfigValidationResult.error);
}

Expand Down
12 changes: 6 additions & 6 deletions plugins/core/rendering-info/configSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ const target = Joi.object().pattern(
label: Joi.string().required(),
type: Joi.string()
.required()
.valid(["web", "AMP", "image", "application/json", "application/pdf"]),
.valid("web", "AMP", "image", "application/json", "application/pdf"),
additionalRenderingInfo: Joi.object().when("type", {
is: Joi.string()
.required()
.valid(["web", "json"]),
.valid("web", "json"),
then: Joi.optional(),
otherwise: Joi.forbidden()
}),
processRenderingInfo: Joi.optional().allow([
processRenderingInfo: Joi.optional().allow(
Joi.func().arity(1),
Joi.array().items(Joi.func().arity(1))
])
)
})
);

Expand All @@ -28,10 +28,10 @@ const toolEndpoint = Joi.alternatives().try(
url: Joi.string().optional(),
additionalRenderingInfo: Joi.object().optional(),
toolRuntimeConfig: Joi.object().optional(),
processRenderingInfo: Joi.optional().allow([
processRenderingInfo: Joi.optional().allow(
Joi.func().arity(1),
Joi.array().items(Joi.func().arity(1))
])
)
})
.without("path", ["url"])
.without("url", ["path"]),
Expand Down
4 changes: 2 additions & 2 deletions plugins/core/rendering-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ module.exports = {
allowUnknown: true
}
);
if (targetConfigValidationResult.error !== null) {
if (targetConfigValidationResult.error) {
throw new Error(targetConfigValidationResult.error);
}

Expand All @@ -233,7 +233,7 @@ module.exports = {
allowUnknown: true
}
);
if (toolEndpointConfigValidationResult.error !== null) {
if (toolEndpointConfigValidationResult.error) {
throw new Error(
`failed to validate toolEndpoint config: ${JSON.stringify(
endpointConfig
Expand Down
2 changes: 1 addition & 1 deletion plugins/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module.exports = {
(err, data) => {
if (err) {
return reject(
new Boom("error", { statusCode: err.statusCode })
new Boom.Boom("error", { statusCode: err.statusCode })
);
}
return resolve(
Expand Down
18 changes: 6 additions & 12 deletions plugins/screenshot/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ async function getScreenshotResponse(server, h, params, item) {
});

if (response.statusCode !== 200) {
throw new Boom(
`Failed to get renderingInfo to load in headless chrome for screenshot for ${
item.tool
} and ${params.target} with the error: ${response.statusMessage}`,
throw new Boom.Boom(
`Failed to get renderingInfo to load in headless chrome for screenshot for ${item.tool} and ${params.target} with the error: ${response.statusMessage}`,
{
statusCode: response.statusCode
}
Expand Down Expand Up @@ -99,9 +97,7 @@ async function getScreenshotResponse(server, h, params, item) {

if (params.format === "png") {
const screenshotBuffer = await getScreenshotImage(
`${server.info.protocol}://localhost:${
server.info.port
}/screenshot/empty-page.html`,
`${server.info.protocol}://localhost:${server.info.port}/screenshot/empty-page.html`,
renderingInfo.markup,
scripts,
stylesheets,
Expand All @@ -113,9 +109,7 @@ async function getScreenshotResponse(server, h, params, item) {
return imageResponse;
} else if (params.format === "json") {
const screenshotInfo = await getScreenshotInfo(
`${server.info.protocol}://localhost:${
server.info.port
}/screenshot/empty-page.html`,
`${server.info.protocol}://localhost:${server.info.port}/screenshot/empty-page.html`,
renderingInfo.markup,
scripts,
stylesheets,
Expand All @@ -136,7 +130,7 @@ module.exports = {
validate: {
params: {
id: Joi.string().required(),
format: Joi.string().valid(["json", "png"])
format: Joi.string().valid("json", "png")
},
query: queryFormat,
options: {
Expand Down Expand Up @@ -173,7 +167,7 @@ module.exports = {
options: {
validate: {
params: {
format: Joi.string().valid(["json", "png"])
format: Joi.string().valid("json", "png")
},
payload: {
item: Joi.object().required(),
Expand Down
2 changes: 1 addition & 1 deletion test/config/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const targets = {
processRenderingInfo: ({ item, renderingInfo }) => {
renderingInfo.markup =
renderingInfo.markup +
`<div>appended by processRenderingInfo function in target</div>`;
`<div style="height: 50px;">appended by processRenderingInfo function in target</div>`;
return renderingInfo;
}
},
Expand Down
6 changes: 3 additions & 3 deletions test/e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ lab.experiment("correctly executes processRenderingInfo:", () => {
);

expect(response.result.markup).to.contain(
"<div>appended by processRenderingInfo function in target</div>"
'<div style="height: 50px;">appended by processRenderingInfo function in target</div>'
);
});

Expand Down Expand Up @@ -753,7 +753,7 @@ lab.experiment("screenshot plugin", async () => {
"public,max-age=1,s-maxage=1,stale-while-revalidate=1,stale-if-error=1"
);
expect(response.result.width).to.be.equal(500);
expect(response.result.height).to.be.equal(76.4375);
expect(response.result.height).to.be.equal(99);
}
);

Expand All @@ -778,7 +778,7 @@ lab.experiment("screenshot plugin", async () => {
"public,max-age=1,s-maxage=1,stale-while-revalidate=1,stale-if-error=1"
);
expect(response.result.width).to.be.equal(500);
expect(response.result.height).to.be.equal(76.4375);
expect(response.result.height).to.be.equal(99);
}
);
});
Expand Down
5 changes: 2 additions & 3 deletions test/mock/tool1.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const server = Hapi.server({
cors: true
}
});
server.validator(Joi);

const schema = {
$schema: "http://json-schema.org/draft-04/schema#",
Expand Down Expand Up @@ -84,9 +85,7 @@ server.route({
},
handler: function(request, h) {
return {
markup: `<h1>${request.payload.item.title} - itemStateInDb: ${
request.payload.itemStateInDb
}</h1>`,
markup: `<h1>${request.payload.item.title} - itemStateInDb: ${request.payload.itemStateInDb}</h1>`,
stylesheets: [
{
name: "mockstyle"
Expand Down
3 changes: 3 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Hapi = require("@hapi/hapi");
const Joi = require("@hapi/joi");

function getServer() {
let server = Hapi.server({
Expand All @@ -12,6 +13,8 @@ function getServer() {
}
});

server.validator(Joi);

// mock the auth strategy
server.auth.scheme("mock", function(server, options) {
return {
Expand Down