@twreporter/redux
Advanced tools
Comparing version 5.0.0-beta.6 to 5.0.0-beta.7
@@ -9,3 +9,3 @@ "use strict"; | ||
var _apiConfig = _interopRequireDefault(require("../conf/api-config")); | ||
var _apiConfig = _interopRequireDefault(require("../constants/api-config")); | ||
@@ -27,7 +27,7 @@ var _actionTypes = _interopRequireDefault(require("../constants/action-types")); | ||
}; | ||
var timeout = _apiConfig["default"].API_TIME_OUT; | ||
var timeout = _apiConfig["default"].timeout; | ||
function getAccessToken(cookieList, releaseBranch) { | ||
return function (dispatch) { | ||
var endpoint = (0, _formApiUrl["default"])(releaseBranch, '/v2/auth/token'); | ||
var endpoint = (0, _formApiUrl["default"])('/v2/auth/token', {}, releaseBranch); | ||
var headers = {}; | ||
@@ -34,0 +34,0 @@ |
@@ -27,4 +27,2 @@ "use strict"; | ||
var _qs = _interopRequireDefault(require("qs")); | ||
var _get = _interopRequireDefault(require("lodash/get")); | ||
@@ -69,6 +67,3 @@ | ||
}; | ||
var urlParasString = _qs["default"].stringify(searchParas); | ||
var url = (0, _formApiUrl["default"])("search/posts?".concat(urlParasString), false); | ||
var url = (0, _formApiUrl["default"])("/v1/search/posts", searchParas, undefined, false); | ||
dispatch(requestAuthorCollection(authorId)); | ||
@@ -75,0 +70,0 @@ return (0, _isomorphicFetch["default"])(url).then(function (response) { |
@@ -23,4 +23,2 @@ "use strict"; | ||
var _qs = _interopRequireDefault(require("qs")); | ||
var _assign = _interopRequireDefault(require("lodash/assign")); | ||
@@ -63,3 +61,3 @@ | ||
}; | ||
var url = (0, _formApiUrl["default"])("search/authors?".concat(_qs["default"].stringify(searchParas)), false); | ||
var url = (0, _formApiUrl["default"])('/v1/search/authors', searchParas, undefined, false); | ||
dispatch(requestFetchAuthorDetails(authorId)); | ||
@@ -66,0 +64,0 @@ return (0, _isomorphicFetch["default"])(url).then(function (res) { |
@@ -27,4 +27,2 @@ "use strict"; | ||
var _qs = _interopRequireDefault(require("qs")); | ||
var _assign = _interopRequireDefault(require("lodash/assign")); | ||
@@ -77,6 +75,3 @@ | ||
}; | ||
var urlParasString = _qs["default"].stringify(searchParas); | ||
var url = (0, _formApiUrl["default"])("search/authors?".concat(urlParasString), false); | ||
var url = (0, _formApiUrl["default"])('/v1/search/authors', searchParas, undefined, false); | ||
dispatch(requestSearchAuthors(keywords)); | ||
@@ -83,0 +78,0 @@ return (0, _isomorphicFetch["default"])(url).then(function (response) { |
@@ -11,6 +11,4 @@ "use strict"; | ||
var _apiConfig = _interopRequireDefault(require("../conf/api-config")); | ||
var _apiConfig = _interopRequireDefault(require("../constants/api-config")); | ||
var _actionTypes = _interopRequireDefault(require("../constants/action-types")); | ||
var _errorActionCreators = _interopRequireDefault(require("./error-action-creators")); | ||
@@ -20,2 +18,4 @@ | ||
var _actionTypes = _interopRequireDefault(require("../constants/action-types")); | ||
var _get = _interopRequireDefault(require("lodash/get")); | ||
@@ -36,17 +36,3 @@ | ||
}; | ||
var apiTimeout = _apiConfig["default"].API_TIME_OUT; | ||
var apiEndpoints = { | ||
getBookmarks: function getBookmarks(userID) { | ||
return "users/".concat(userID, "/bookmarks"); | ||
}, | ||
getSingleBookmark: function getSingleBookmark(userID, bookmarkSlug, bookmarkHost) { | ||
return "users/".concat(userID, "/bookmarks/").concat(bookmarkSlug, "?host=").concat(bookmarkHost); | ||
}, | ||
createSingleBookmark: function createSingleBookmark(userID) { | ||
return "users/".concat(userID, "/bookmarks"); | ||
}, | ||
deleteSingleBookmark: function deleteSingleBookmark(userID, bookmarkID) { | ||
return "users/".concat(userID, "/bookmarks/").concat(bookmarkID); | ||
} | ||
}; | ||
var apiTimeout = _apiConfig["default"].timeout; | ||
@@ -65,3 +51,3 @@ function buildSuccessActionFromRes(axiosResponse, actionType) { | ||
function createSingleBookmark(jwt, uesrID, bookmarkToBeCreated) { | ||
function createSingleBookmark(jwt, userID, bookmarkToBeCreated) { | ||
var published_date = bookmarkToBeCreated.published_date, | ||
@@ -72,3 +58,3 @@ passedBookmarkProperties = _objectWithoutProperties(bookmarkToBeCreated, ["published_date"]); | ||
var httpClientWithToken = _ref.httpClientWithToken; | ||
var url = (0, _formApiUrl["default"])(apiEndpoints.createSingleBookmark(uesrID), false); | ||
var url = (0, _formApiUrl["default"])("/v1/users/".concat(userID, "/bookmarks"), {}, undefined, false); | ||
var axiosConfig = { | ||
@@ -114,3 +100,7 @@ timeout: apiTimeout, | ||
var httpClientWithToken = _ref2.httpClientWithToken; | ||
var url = (0, _formApiUrl["default"])("".concat(apiEndpoints.getBookmarks(userID), "?offset=").concat(offset, "&limit=").concat(limit, "&sort=").concat(sort), false); | ||
var url = (0, _formApiUrl["default"])("/v1/users/".concat(userID, "/bookmarks"), { | ||
offset: offset, | ||
limit: limit, | ||
sort: sort | ||
}, undefined, false); | ||
var axiosConfig = { | ||
@@ -153,3 +143,5 @@ timeout: apiTimeout, | ||
var httpClientWithToken = _ref3.httpClientWithToken; | ||
var url = (0, _formApiUrl["default"])("".concat(apiEndpoints.getSingleBookmark(userID, bookmarkSlug, bookmarkHost)), false); | ||
var url = (0, _formApiUrl["default"])("/v1/users/".concat(userID, "/bookmarks/").concat(bookmarkSlug), { | ||
host: bookmarkHost | ||
}, undefined, false); | ||
var axiosConfig = { | ||
@@ -192,3 +184,3 @@ timeout: apiTimeout, | ||
var httpClientWithToken = _ref4.httpClientWithToken; | ||
var url = (0, _formApiUrl["default"])(apiEndpoints.deleteSingleBookmark(userID, bookmarkID), false); | ||
var url = (0, _formApiUrl["default"])("/v1/users/".concat(userID, "/bookmarks/").concat(bookmarkID), {}, undefined, false); | ||
var axiosConfig = { | ||
@@ -195,0 +187,0 @@ timeout: apiTimeout, |
@@ -9,14 +9,14 @@ "use strict"; | ||
var _apiConfig = _interopRequireDefault(require("../conf/api-config")); | ||
var _apiConfig = _interopRequireDefault(require("../constants/api-config")); | ||
var _apiEndpoints = _interopRequireDefault(require("../constants/api-endpoints")); | ||
var _axios = _interopRequireDefault(require("axios")); | ||
var _actionTypes = _interopRequireDefault(require("../constants/action-types")); | ||
var _reduxStateFieldNames = _interopRequireDefault(require("../constants/redux-state-field-names")); | ||
var _apiEndpoints = _interopRequireDefault(require("../constants/api-endpoints")); | ||
var _formApiUrl = _interopRequireDefault(require("../utils/form-api-url")); | ||
var _actionTypes = _interopRequireDefault(require("../constants/action-types")); | ||
var _get = _interopRequireDefault(require("lodash/get")); | ||
@@ -33,4 +33,4 @@ | ||
function _fetch(dispatch, path) { | ||
var url = (0, _formApiUrl["default"])(path); | ||
function _fetch(dispatch, path, params) { | ||
var url = (0, _formApiUrl["default"])(path, params); | ||
dispatch({ | ||
@@ -41,3 +41,3 @@ type: _actionTypes["default"].START_TO_GET_INDEX_PAGE_CONTENT, | ||
return _axios["default"].get(url, { | ||
timeout: _apiConfig["default"].API_TIME_OUT | ||
timeout: _apiConfig["default"].timeout | ||
}).then(function (response) { | ||
@@ -77,4 +77,3 @@ var items = _.get(response, 'data.records', {}); | ||
var path = "".concat(_apiEndpoints["default"].indexPage); | ||
return _fetch(dispatch, path); | ||
return _fetch(dispatch, "/v1/".concat(_apiEndpoints["default"].indexPage)); | ||
}; | ||
@@ -102,5 +101,4 @@ } | ||
var path = "".concat(_apiEndpoints["default"].indexPageCategories); | ||
return _fetch(dispatch, path); | ||
return _fetch(dispatch, "/v1/".concat(_apiEndpoints["default"].indexPageCategories)); | ||
}; | ||
} |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _apiConfig = _interopRequireDefault(require("../conf/api-config")); | ||
var _apiConfig = _interopRequireDefault(require("../constants/api-config")); | ||
@@ -57,4 +57,6 @@ var _apiEndpoints = _interopRequireDefault(require("../constants/api-endpoints")); | ||
var path = "".concat(_apiEndpoints["default"].posts, "/").concat(slug, "?full=true"); | ||
var url = (0, _formApiUrl["default"])(path); | ||
var path = "/v1/".concat(_apiEndpoints["default"].posts, "/").concat(slug); | ||
var url = (0, _formApiUrl["default"])(path, { | ||
full: 'true' | ||
}); | ||
dispatch({ | ||
@@ -67,3 +69,3 @@ type: _actionTypes["default"].START_TO_GET_A_FULL_POST, | ||
return _axios["default"].get(url, { | ||
timeout: _apiConfig["default"].API_TIME_OUT | ||
timeout: _apiConfig["default"].timeout | ||
}).then(function (response) { | ||
@@ -86,6 +88,9 @@ return dispatch({ | ||
function _fetchPosts(dispatch, path, successActionType) { | ||
var failureActionType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _actionTypes["default"].ERROR_TO_GET_POSTS; | ||
var defaultPayload = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; | ||
var url = (0, _formApiUrl["default"])(path); | ||
function _fetchPosts(dispatch) { | ||
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var successActionType = arguments.length > 3 ? arguments[3] : undefined; | ||
var failureActionType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _actionTypes["default"].ERROR_TO_GET_POSTS; | ||
var defaultPayload = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {}; | ||
var url = (0, _formApiUrl["default"])(path, params); | ||
dispatch({ | ||
@@ -96,3 +101,3 @@ type: _actionTypes["default"].START_TO_GET_POSTS, | ||
return _axios["default"].get(url, { | ||
timeout: _apiConfig["default"].API_TIME_OUT | ||
timeout: _apiConfig["default"].timeout | ||
}).then(function (response) { | ||
@@ -135,4 +140,9 @@ return dispatch({ | ||
var offset = page > 0 ? (page - 1) * limit : _.get(list, 'items.length', 0); | ||
var path = "".concat(_apiEndpoints["default"].posts, "?where=").concat(JSON.stringify(where), "&limit=").concat(limit, "&offset=").concat(offset); | ||
return _fetchPosts(dispatch, path, _actionTypes["default"].GET_LISTED_POSTS, _actionTypes["default"].ERROR_TO_GET_LISTED_POSTS, { | ||
var path = "/v1/".concat(_apiEndpoints["default"].posts); | ||
var params = { | ||
where: JSON.stringify(where), | ||
limit: limit, | ||
offset: offset | ||
}; | ||
return _fetchPosts(dispatch, path, params, _actionTypes["default"].GET_LISTED_POSTS, _actionTypes["default"].ERROR_TO_GET_LISTED_POSTS, { | ||
listID: listID, | ||
@@ -154,4 +164,8 @@ page: page | ||
var path = "".concat(_apiEndpoints["default"].posts, "?where={\"is_featured\":true}&limit=6"); | ||
return _fetchPosts(dispatch, path, _actionTypes["default"].GET_EDITOR_PICKED_POSTS); | ||
var path = "/v1/".concat(_apiEndpoints["default"].posts); | ||
var params = { | ||
where: '{"is_featured":true}', | ||
limit: 6 | ||
}; | ||
return _fetchPosts(dispatch, path, params, _actionTypes["default"].GET_EDITOR_PICKED_POSTS); | ||
}; | ||
@@ -170,4 +184,8 @@ } | ||
var path = "".concat(_apiEndpoints["default"].posts, "?where={\"style\":\"").concat(_postStyles["default"].photography, "\"}&limit=6"); | ||
return _fetchPosts(dispatch, path, _actionTypes["default"].GET_PHOTOGRAPHY_POSTS_FOR_INDEX_PAGE); | ||
var path = "/v1/".concat(_apiEndpoints["default"].posts); | ||
var params = { | ||
where: "{\"style\":\"".concat(_postStyles["default"].photography, "\"}"), | ||
limit: 6 | ||
}; | ||
return _fetchPosts(dispatch, path, params, _actionTypes["default"].GET_PHOTOGRAPHY_POSTS_FOR_INDEX_PAGE); | ||
}; | ||
@@ -186,5 +204,9 @@ } | ||
var path = "".concat(_apiEndpoints["default"].posts, "?where={\"style\":\"").concat(_postStyles["default"].infographic, "\"}&limit=10"); | ||
return _fetchPosts(dispatch, path, _actionTypes["default"].GET_INFOGRAPHIC_POSTS_FOR_INDEX_PAGE); | ||
var path = "/v1/".concat(_apiEndpoints["default"].posts); | ||
var params = { | ||
where: "{\"style\":\"".concat(_postStyles["default"].infographic, "\"}"), | ||
limit: 10 | ||
}; | ||
return _fetchPosts(dispatch, path, params, _actionTypes["default"].GET_INFOGRAPHIC_POSTS_FOR_INDEX_PAGE); | ||
}; | ||
} |
@@ -10,3 +10,3 @@ "use strict"; | ||
var _apiConfig = _interopRequireDefault(require("../conf/api-config")); | ||
var _apiConfig = _interopRequireDefault(require("../constants/api-config")); | ||
@@ -53,3 +53,6 @@ var _axios = _interopRequireDefault(require("axios")); | ||
var path = "".concat(_apiEndpoints["default"].topics, "/").concat(slug, "?full=true"); | ||
var path = "/v1/".concat(_apiEndpoints["default"].topics, "/").concat(slug); | ||
var params = { | ||
full: 'true' | ||
}; | ||
dispatch({ | ||
@@ -61,4 +64,4 @@ type: _actionTypes["default"].START_TO_GET_A_FULL_TOPIC, | ||
}); | ||
return _axios["default"].get((0, _formApiUrl["default"])(path), { | ||
timeout: _apiConfig["default"].API_TIME_OUT | ||
return _axios["default"].get((0, _formApiUrl["default"])(path, params), { | ||
timeout: _apiConfig["default"].timeout | ||
}).then(function (response) { | ||
@@ -81,4 +84,4 @@ return dispatch({ | ||
function _fetchTopics(dispatch, path, successActionType) { | ||
var url = (0, _formApiUrl["default"])(path); | ||
function _fetchTopics(dispatch, path, params, successActionType) { | ||
var url = (0, _formApiUrl["default"])(path, params); | ||
dispatch({ | ||
@@ -89,3 +92,3 @@ type: _actionTypes["default"].START_TO_GET_TOPICS, | ||
return _axios["default"].get(url, { | ||
timeout: _apiConfig["default"].API_TIME_OUT | ||
timeout: _apiConfig["default"].timeout | ||
}).then(function (response) { | ||
@@ -138,4 +141,8 @@ var meta = _.get(response, 'data.meta', {}); | ||
var path = "".concat(_apiEndpoints["default"].topics, "?limit=").concat(limit, "&offset=").concat(offset); | ||
return _fetchTopics(dispatch, path, _actionTypes["default"].GET_TOPICS); | ||
var path = "/v1/".concat(_apiEndpoints["default"].topics); | ||
var params = { | ||
limit: limit, | ||
offset: offset | ||
}; | ||
return _fetchTopics(dispatch, path, params, _actionTypes["default"].GET_TOPICS); | ||
}; | ||
@@ -154,5 +161,9 @@ } | ||
var path = "".concat(_apiEndpoints["default"].topics, "?offset=1&limit=4"); | ||
return _fetchTopics(dispatch, path, _actionTypes["default"].GET_TOPICS_FOR_INDEX_PAGE); | ||
var path = "/v1/".concat(_apiEndpoints["default"].topics); | ||
var params = { | ||
offset: 1, | ||
limit: 4 | ||
}; | ||
return _fetchTopics(dispatch, path, params, _actionTypes["default"].GET_TOPICS_FOR_INDEX_PAGE); | ||
}; | ||
} |
@@ -22,3 +22,3 @@ "use strict"; | ||
ERROR_TO_GET_POSTS: 'ERROR_TO_GET_POSTS', | ||
GET_EDITOR_PICKED_POSTS: 'G∂ET_EDITOR_PICKED_POSTS', | ||
GET_EDITOR_PICKED_POSTS: 'GET_EDITOR_PICKED_POSTS', | ||
GET_LISTED_POSTS: 'GET_LISTED_POSTS', | ||
@@ -25,0 +25,0 @@ ERROR_TO_GET_LISTED_POSTS: 'ERROR_TO_GET_LISTED_POSTS', |
@@ -7,14 +7,9 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var topics = 'topics'; | ||
var indexPage = 'index_page'; | ||
var indexPageCategories = 'index_page_categories'; | ||
var posts = 'posts'; | ||
var users = 'users'; | ||
var _default = { | ||
topics: topics, | ||
indexPage: indexPage, | ||
indexPageCategories: indexPageCategories, | ||
posts: posts, | ||
users: users | ||
topics: 'topics', | ||
indexPage: 'index_page', | ||
indexPageCategories: 'index_page_categories', | ||
posts: 'posts', | ||
users: 'users' | ||
}; | ||
exports["default"] = _default; |
@@ -8,31 +8,52 @@ "use strict"; | ||
var _apiConfig = _interopRequireDefault(require("../conf/api-config")); | ||
var _urlOrigin = require("../constants/url-origin"); | ||
var _qs = _interopRequireDefault(require("qs")); | ||
var _releaseBranch = _interopRequireDefault(require("../constants/release-branch")); | ||
var _get = _interopRequireDefault(require("lodash/get")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var formAPIURL = function formAPIURL(path) { | ||
var toEncode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
var protocol; | ||
var host; | ||
var port; | ||
var version; | ||
var _ = { | ||
get: _get["default"] | ||
}; | ||
var _path = toEncode ? encodeURI(path) : path; | ||
function getReleaseBranchFromGlobal() { | ||
if (typeof process !== 'undefined') { | ||
var releaseBranch = _.get(process, 'env.RELEASE_BRANCH'); | ||
if (process.env.NODE_ENV === 'development') { | ||
protocol = process.env.API_PROTOCOL || 'http'; | ||
host = process.env.API_HOST || 'localhost'; | ||
port = process.env.API_PORT || '8080'; | ||
version = process.env.API_DEFAULT_VERSION || '/v1/'; | ||
} else { | ||
protocol = process.env.API_PROTOCOL || _apiConfig["default"].API_PROTOCOL; | ||
host = process.env.API_HOST || _apiConfig["default"].API_HOST; | ||
port = process.env.API_PORT || _apiConfig["default"].API_PORT; | ||
version = process.env.API_DEFAULT_VERSION || _apiConfig["default"].API_DEFAULT_VERSION; | ||
if (releaseBranch) { | ||
return releaseBranch; | ||
} | ||
var nodeEnv = _.get(process, 'env.NODE_ENV'); | ||
if (nodeEnv) { | ||
return nodeEnv === 'production' ? _releaseBranch["default"].release : _releaseBranch["default"].master; | ||
} | ||
} | ||
return "".concat(protocol, "://").concat(host, ":").concat(port).concat(version).concat(_path); | ||
}; | ||
if (typeof __DEVELOPMENT__ !== 'undefined') { | ||
return __DEVELOPMENT__ ? _releaseBranch["default"].master : _releaseBranch["default"].release; | ||
} | ||
return _releaseBranch["default"].master; | ||
} | ||
function formAPIURL() { | ||
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var releaseBranch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getReleaseBranchFromGlobal(); | ||
var uriEncode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; | ||
var query = _qs["default"].stringify(params, { | ||
encode: uriEncode | ||
}); | ||
return "".concat(_urlOrigin.api[releaseBranch]).concat(path).concat(query ? "?".concat(query) : ''); | ||
} | ||
var _default = formAPIURL; | ||
exports["default"] = _default; |
{ | ||
"name": "@twreporter/redux", | ||
"version": "5.0.0-beta.6", | ||
"version": "5.0.0-beta.7", | ||
"description": "redux actions and reducers for twreporter website", | ||
@@ -38,2 +38,3 @@ "main": "lib/index.js", | ||
"normalizr": "^3.2.4", | ||
"qs": "^6.5.1", | ||
"redux": "^3.6.0" | ||
@@ -40,0 +41,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
135820
50
2980
0
11
+ Addedqs@^6.5.1
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)