Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable no-console */
const assert = require("assert");
// eslint-disable-next-line import/no-extraneous-dependencies
const DataPoint = require("data-point");
const dp = DataPoint.create();
dp.use("before", (acc, next) => {
console.log("Entity model:MyModel is being called");
next();
});
dp.use("before", (acc, next) => {
console.log("hijacking");
next(null, "hijacked");
});
dp.use("before", (acc, next) => {
console.log("never got here");
next();
});
const PersonRequest = Request("PersonRequest", {
url: "https://swapi.co/api/people/{value}/"
});
const PersonModel = Model("PersonModel", {
value: {
name: "$name",
birthYear: "$birth_year"
}
});
const options = {
trace: false // <-- set to true to enable tracing, a file will be created
};
const dataPoint = DataPoint.create();
dataPoint.transform([PersonRequest, PersonModel], 1, options).then(() => {
/*
a file with the name data-point-trace-.json will
be created.
File follows the structure of:
{
"id": "1",
"reducer": {
"type": "ReducerList",
"reducers": [...]
},
"hrtime": [
405103,