Skip to content

Commit

Permalink
Merge pull request #217 from nzzdev/release-10.0.5
Browse files Browse the repository at this point in the history
Release v10.0.5
  • Loading branch information
manuelroth authored May 26, 2021
2 parents 8415bc5 + 149931b commit d285b01
Show file tree
Hide file tree
Showing 13 changed files with 1,492 additions and 1,432 deletions.
14 changes: 0 additions & 14 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
14
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: trusty
sudo: true
language: node_js
node_js:
- "12"
- "14"
cache:
directories:
- node_modules
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Q Server

[![Greenkeeper badge](https://badges.greenkeeper.io/nzzdev/Q-server.svg)](https://greenkeeper.io/)

**Maintainer**: [Manuel Roth](https://github.com/manuelroth)

__Q__ is a system that lets journalists create visual elements for stories. It is developed by [NZZ Editorial Tech](https://twitter.com/NZZEditoTech) and [NZZ Visuals](https://twitter.com/NZZVisuals) and used in the [NZZ](https://www.nzz.ch) newsroom. There is a Demo over here: https://editor.q.tools
**Q** is a system that lets journalists create visual elements for stories. It is developed by [NZZ Editorial Tech](https://twitter.com/NZZEditoTech) and [NZZ Visuals](https://twitter.com/NZZVisuals) and used in the [NZZ](https://www.nzz.ch) newsroom. There is a Demo over here: https://editor.q.tools

This is the server for the Q Toolbox. To make use of Q server you will also need a [Q editor](https://github.com/nzzdev/Q-editor/).

Documentation: https://nzzdev.github.io/Q-server

## Development

### Tests

There is a 100% coverage aim with the tests. Please do not lower the coverage.
The tests use `pouchdb-server` to mock the database and implement a simple mock tool endpoint. This makes e2e testing completely self contained without the need for any external services running. Just do a `npm install` and then `npm run test` and you are good to go. There are e2e tests in `test/e2e-tests.js` and some unit tests in `test/unit-tests.js`.

## License

Copyright (c) 2019 Neue Zürcher Zeitung. All rights reserved.

This software is published under the MIT license.
22 changes: 11 additions & 11 deletions docs/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You have to define the following endpoint if you want to be able to migrate item
One example of one of our election tools:

```javascript
const Joi = require("@hapi/joi");
const Joi = require("joi");
const Boom = require("boom");

// register migration scripts here in order of version,
Expand All @@ -54,29 +54,29 @@ You have to define the following endpoint if you want to be able to migrate item
options: {
validate: {
payload: {
item: Joi.object().required()
}
}
item: Joi.object().required(),
},
},
},
handler: async (request, h) => {
let item = request.payload.item;
const results = migrationScripts.map(script => {
const results = migrationScripts.map((script) => {
const result = script.migrate(item);
if (result.isChanged) {
item = result.item;
}
return result;
});
const isChanged = results.findIndex(result => {
const isChanged = results.findIndex((result) => {
return result.isChanged;
});
if (isChanged >= 0) {
return {
item: item
item: item,
};
}
return h.response().code(304);
}
},
};
```

Expand All @@ -92,12 +92,12 @@ In the following example you see one migration module with just one method. Sinc
// contains all scripts which shall be executed to migrate to tool version 2.0.0
// each module has to return a result object holding the modified item and a
// flag property indicating if item was changed or not
module.exports.migrate = function(item) {
module.exports.migrate = function (item) {
let result = {
isChanged: false
isChanged: false,
};
if (item.parties) {
let truthyparties = item.parties.filter(party => {
let truthyparties = item.parties.filter((party) => {
return party.name !== undefined && party.name !== "";
});
if (truthyparties.length < item.parties.length) {
Expand Down
10 changes: 5 additions & 5 deletions helper/custom-joi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Bourne = require("@hapi/bourne");
const Joi = require("@hapi/joi");
const Joi = require("joi");

// As of Joi v16, strings are no longer automatically converted to objects/arrays,
// even if the convert option of any.validate() is "true" (which is the default).
Expand All @@ -24,8 +24,8 @@ module.exports = Joi.extend(
try {
return { value: Bourne.parse(value) };
} catch (ignoreErr) {}
}
}
},
},
},
{
type: "array",
Expand All @@ -43,7 +43,7 @@ module.exports = Joi.extend(
try {
return { value: Bourne.parse(value) };
} catch (ignoreErr) {}
}
}
},
},
}
);
Loading

0 comments on commit d285b01

Please sign in to comment.