Commit 29bfba43 authored by David Björkheim's avatar David Björkheim Committed by Oyvind
Browse files

DEICH-5645 Deichman.no: Remove unfetch

parent 2a1485c3
......@@ -7,7 +7,7 @@
"": {
"name": "deichman-next",
"version": "1.0.0",
"license": "ISC",
"license": "GPL-3.0-only",
"dependencies": {
"@digibib/deichman-ui": "^7.2.2",
"@nrk/core-tabs": "^2.0.6",
......@@ -26,7 +26,6 @@
"formik": "^2.2.6",
"full-icu": "^1.2.1",
"helmet": "^4.1.1",
"isomorphic-unfetch": "^3.0.0",
"jsonld": "^5.0.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
......@@ -7599,15 +7598,6 @@
"node": ">=0.10.0"
}
},
"node_modules/isomorphic-unfetch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz",
"integrity": "sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==",
"dependencies": {
"node-fetch": "^2.6.1",
"unfetch": "^4.2.0"
}
},
"node_modules/jest-worker": {
"version": "24.9.0",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz",
......@@ -19574,11 +19564,6 @@
"debug": "^2.2.0"
}
},
"node_modules/unfetch": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz",
"integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA=="
},
"node_modules/union-value": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
......@@ -27438,15 +27423,6 @@
"isarray": "1.0.0"
}
},
"isomorphic-unfetch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz",
"integrity": "sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==",
"requires": {
"node-fetch": "^2.6.1",
"unfetch": "^4.2.0"
}
},
"jest-worker": {
"version": "24.9.0",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz",
......@@ -37251,11 +37227,6 @@
"debug": "^2.2.0"
}
},
"unfetch": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz",
"integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA=="
},
"union-value": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
......@@ -33,7 +33,6 @@
"formik": "^2.2.6",
"full-icu": "^1.2.1",
"helmet": "^4.1.1",
"isomorphic-unfetch": "^3.0.0",
"jsonld": "^5.0.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......@@ -31,12 +30,13 @@ class ListPage extends Component {
"field.status": "published"
};
// Determine what mediatype to display
const mediaTypeQuery = URL_TO_QUERY_MAP[mediaType];
const invalidMediaType = mediaTypeQuery === undefined;
await reduxStore.dispatch(getLists(req, queryWithFilter, mediaTypeQuery, page));
await reduxStore.dispatch(
getLists(req, queryWithFilter, mediaTypeQuery, page)
);
return {
mediaType,
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......
import "isomorphic-unfetch";
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
......@@ -149,7 +148,14 @@ SearchPage.propTypes = {
function mapStateToProps(state) {
const { listMode } = state.application;
const { biblioNumbers } = state.favourites;
const { currentQuery, results, overlayVisible, searchApi, agentResults, agentSearchApi } = state.search;
const {
currentQuery,
results,
overlayVisible,
searchApi,
agentResults,
agentSearchApi
} = state.search;
return {
favourites: biblioNumbers,
overlayVisible,
......
/* eslint-disable camelcase */
const fetch = require("isomorphic-unfetch");
const router = require("express").Router();
const jwt = require("jsonwebtoken");
const { verifyToken } = require("../utils/tokenChecker");
......
const routes = require("express").Router();
const fetch = require("isomorphic-unfetch");
const QueryString = require("query-string");
const logger = require("../../logger")(__filename);
......
const isofetch = require("isomorphic-unfetch");
const fetch = require("isomorphic-unfetch");
const { parseString } = require("xml2js");
const router = require("express").Router();
const cookieParser = require("../utils/cookieParser");
......@@ -190,7 +188,7 @@ router.post("/start-pay-fine", async (request, response) => {
}
}
const res = await isofetch(registerUrl);
const res = await fetch(registerUrl);
const xmlResponse = await res.text();
const jsonResponse = await xml2jsPromiseParser(xmlResponse);
const transactionId = jsonResponse.RegisterResponse.TransactionId;
......@@ -261,7 +259,7 @@ router.put("/process-fine-payment", async (request, response) => {
call_id: deichmanCallId
}
);
const res = await isofetch(processUrl);
const res = await fetch(processUrl);
const xmlResponse = await res.text();
const jsonResponse = await xml2jsPromiseParser(xmlResponse);
......
const router = require("express").Router();
const fetch = require("isomorphic-unfetch");
const kohaEndpoint = process.env.INTERNAL_URL_KOHA;
......
const resources = require("express").Router();
const fetch = require("isomorphic-unfetch");
const cookieParser = require("../utils/cookieParser");
const logger = require("../../logger")(__filename);
......
const router = require("express").Router();
const jwt = require("jsonwebtoken");
const fetch = require("isomorphic-unfetch");
const logger = require("../../logger")(__filename);
const { verifyToken } = require("../utils/tokenChecker");
......
const routes = require("express").Router();
const fetch = require("isomorphic-unfetch");
const logger = require("../../logger")(__filename);
const format = require("date-fns/format");
const {
......@@ -71,7 +70,7 @@ function filterLibraries(libraries, categorycode) {
"fsme",
"fsto",
"ftor",
"fgam",
"fgam"
].includes(l.branchcode)
) {
return true;
......@@ -79,7 +78,6 @@ function filterLibraries(libraries, categorycode) {
// allow test branch codes also
return /^[a-f0-9]{8}$/.test(l.branchcode);
});
}
......@@ -94,7 +92,9 @@ routes.get("/koha-branches", async (request, response) => {
response.status(res.status).send(res.statusText);
throw Error();
}
response.status(200).send(filterLibraries(json, request.query.categorycode));
response
.status(200)
.send(filterLibraries(json, request.query.categorycode));
} catch (error) {
logger.info(`ERROR in fetchin all libraries; ${error}`, {
...error,
......
const fetch = require("isomorphic-unfetch");
const router = require("express").Router();
const jwt = require("jsonwebtoken");
const { tokenChecker } = require("../utils/tokenChecker");
......
const fetch = require("isomorphic-unfetch");
const router = require("express").Router();
const jwt = require("jsonwebtoken");
const { tokenChecker } = require("../utils/tokenChecker");
......@@ -32,7 +31,6 @@ async function updatePin(borrowerNumber, newPin, deichmannCallId) {
});
}
// ---- Routes
// Change pin
......@@ -67,7 +65,6 @@ router.put("/", tokenChecker, async (request, response) => {
});
response.sendStatus(500);
}
});
module.exports = router;
/* eslint-disable camelcase */
const userSettingsMapper = require("../utils/userSettingsMapper");
const fetch = require("isomorphic-unfetch");
const router = require("express").Router();
const cookieParser = require("../utils/cookieParser");
......
const fetch = require("isomorphic-unfetch");
const logger = require("../../logger")(__filename);
const routes = require("express").Router();
const jwt = require("jsonwebtoken");
......
const routes = require("express").Router();
const fetch = require("isomorphic-unfetch");
const uniqBy = require("lodash/uniqBy");
const {
frameJsonLD,
......
const routes = require("express").Router();
const fetch = require("isomorphic-unfetch");
const { uniqBy } = require("lodash");
const QueryString = require("query-string");
const logger = require("../../logger")(__filename);
......@@ -234,7 +233,9 @@ routes.get("/agents", async (request, response) => {
queryParams.pageSize = query.pageSize;
}
const url = `${sibylEndpoint}/search/agent?${QueryString.stringify(queryParams)}`;
const url = `${sibylEndpoint}/search/agent?${QueryString.stringify(
queryParams
)}`;
try {
const res = await fetch(url);
......
const fetch = require("isomorphic-unfetch");
const router = require("express").Router();
const logger = require("../../logger")(__filename);
const CALL_ID_HEADER = "Deichman-CallID";
router.put("/cancel_hold", (request, response) => {
const deichmanCallId = request.headers[CALL_ID_HEADER];
logger.info(`Cancelling hold with uuid ${request.body.uuid}`, {
cancel_uuid: request.body.uuid,
call_id: deichmanCallId
});
fetch("http://koha:8082/api/patrons/cancel_hold", {
method: "PUT",
headers: {
Accept: "application/json, application/xml, text/plain, text/html, *.*",
"Content-Type": "application/json; charset=utf-8;",
"Deichman-CallID": deichmanCallId
},
body: JSON.stringify({
uuid: request.body.uuid
})
const deichmanCallId = request.headers[CALL_ID_HEADER];
logger.info(`Cancelling hold with uuid ${request.body.uuid}`, {
cancel_uuid: request.body.uuid,
call_id: deichmanCallId
});
fetch("http://koha:8082/api/patrons/cancel_hold", {
method: "PUT",
headers: {
Accept: "application/json, application/xml, text/plain, text/html, *.*",
"Content-Type": "application/json; charset=utf-8;",
"Deichman-CallID": deichmanCallId
},
body: JSON.stringify({
uuid: request.body.uuid
})
.then(res => {
if (res.status !== 200) {
logger.info(`Cancelling hold with uuid ${request.body.uuid}: koha failed with status ${res.status}`, {
}).then(res => {
if (res.status !== 200) {
logger.info(
`Cancelling hold with uuid ${
request.body.uuid
}: koha failed with status ${res.status}`,
{
cancel_uuid: request.body.uuid,
call_id: deichmanCallId
});
}
// always return OK even on failures, we don't want to leak and informations
// to users who may be not logged in.
response.sendStatus(200);
})
}
);
}
// always return OK even on failures, we don't want to leak and informations
// to users who may be not logged in.
response.sendStatus(200);
});
});
module.exports = router;
\ No newline at end of file
module.exports = router;
import fetch from "isomorphic-unfetch";
// Actions
const GET_AUDIO_VIDEO_REQUEST = "page/GET_AUDIO_VIDEO_REQUEST";
const GET_AUDIO_VIDEO_SUCCESS = "page/GET_AUDIO_VIDEO_SUCCESS";
......
import fetch from "isomorphic-unfetch";
import Router from "next/router";
import Errors from "../../constants/errors";
......
import fetch from "isomorphic-unfetch";
import { slugify } from "../../utilities/slug";
import { getAgeOfTimestampInHours } from "../../utilities/datetime";
......
import fetch from "isomorphic-unfetch";
import Errors from "../../constants/errors";
const REQUEST_EXTEND_LOAN = "checkouts/REQUEST_EXTEND_LOAN";
......
import fetch from "isomorphic-unfetch";
// Actions
const GET_EMPLOYEE_CONTRIBUTIONS_REQUEST =
"lists/GET_EMPLOYEE_CONTRIBUTIONS_REQUEST";
......
import fetch from "isomorphic-unfetch";
import { formatQueryParams } from "../../utilities/url";
import { checkIfEventDateHasPassed } from "../../utilities/infoScreens";
......
import fetch from "isomorphic-unfetch";
// Utilites
function responseToLists(response = []) {
const tags = [...new Set(response.map(i => i.tag))];
......
import fetch from "isomorphic-unfetch";
import { logout } from "../auth";
// Actions
......@@ -53,7 +52,7 @@ export default function reducer(state = initialState, action = {}) {
return {
...state,
isRegisteringIdPortenUser: true
}
};
case REGISTER_IDPORTEN_USER_SUCCESS:
return {
...state,
......
import fetch from "isomorphic-unfetch";
import { addDays, isBefore } from "date-fns";
import { shuffleWithSeed } from "../../utilities/array";
......@@ -272,7 +271,9 @@ export function fetchKohaBranches(req) {
const baseUrl = req
? `${req.protocol}://localhost:${process.env.PORT || 3000}`
: "";
return fetch(`${baseUrl}/api/libraries/koha-branches?categorycode=${categorycode}`)
return fetch(
`${baseUrl}/api/libraries/koha-branches?categorycode=${categorycode}`
)
.then(response => (req ? response.json() : response.clone().json()))
.then(result => {
return dispatch(getKohaBranchesSuccess(result));
......
import fetch from "isomorphic-unfetch";
import { formatQueryParams } from "../../utilities/url";
// Actions
......
import fetch from "isomorphic-unfetch";
// Actions
const CREATE_LIKE_REQUEST = "likes/CREATE_LIKE_REQUEST";
const CREATE_LIKE_SUCCESS = "likes/CREATE_LIKE_SUCCESS";
......
import fetch from "isomorphic-unfetch";
const PAGE_SIZE = 24;
// Actions
......
import fetch from "isomorphic-unfetch";
// Actions
const GET_PAGE_REQUEST = "page/GET_PAGE_REQUEST";
const GET_PAGE_SUCCESS = "page/GET_PAGE_SUCCESS";
......
import fetch from "isomorphic-unfetch";
import { fetchProfileLoans } from "../profile/index";
const PAYMENT_SUCCESS = "payments/PAYMENT_SUCCESS";
......
import fetch from "isomorphic-unfetch";
import Errors from "../../constants/errors";
import { triggerNotification } from "../application";
import Router from "next/router";
......@@ -149,11 +148,11 @@ export default function reducer(state = initialState, action = {}) {
cancelHoldDone: false
};
case CANCEL_HOLD_DONE:
return {
...state,
isCancellingHold: false,
cancelHoldDone: true
};
return {
...state,
isCancellingHold: false,
cancelHoldDone: true
};
case CHANGE_HISTORY_PRIVACY:
return {
...state,
......@@ -1203,8 +1202,7 @@ export function cancelHold(uuid) {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ uuid })
})
.then(dispatch(action(CANCEL_HOLD_DONE)));
}).then(dispatch(action(CANCEL_HOLD_DONE)));
};
}
......
import fetch from "isomorphic-unfetch";
import Errors from "../../constants/errors";
import { fetchProfileLoans } from "../profile";
import { triggerNotification } from "../application";
......
import fetch from "isomorphic-unfetch";
// Actions
const GET_WORK_REQUEST = "resources/GET_WORK_REQUEST";
const GET_WORK_SUCCESS = "resources/GET_WORK_SUCCESS";
......
/* eslint-disable prefer-destructuring */
import fetch from "isomorphic-unfetch";
import { formatQueryParamsLegacy } from "../../utilities/url";
// Actions
......@@ -256,9 +255,11 @@ export function search(query = {}) {
const reAgentSearch = /^aktør\:(\"(.+?)\"|[^\u2000-\u206F\u2E00-\u2E7F]+)$/g;
if (trimmedQuery.match(reAgentSearch)) {
const agentSearchQuery = trimmedQuery.replace("aktør:", "")
dispatch(agentSearchRequest(agentSearchQuery))
dispatch(agentSearch({searchQuery: agentSearchQuery, page: query.agentPage }))
const agentSearchQuery = trimmedQuery.replace("aktør:", "");
dispatch(agentSearchRequest(agentSearchQuery));
dispatch(
agentSearch({ searchQuery: agentSearchQuery, page: query.agentPage })
);
}
return fetch(url)
......@@ -294,7 +295,6 @@ export function agentSearch(query = {}) {
};
}
// Function for searching via predefined params (for the campaignpage section, mainly)
export function inlineSearch(
query = "",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment