Socket
Socket
Sign inDemoInstall

@wildberries/service-cdn-uploader

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wildberries/service-cdn-uploader - npm Package Compare versions

Comparing version 2.0.6 to 3.0.0-beta.1

52

index.js

@@ -21,3 +21,3 @@ /* eslint-disable import/no-unresolved */

const renderGoAuth = process.env.CDN_API_TOKEN;
const renderGoAuth = process.env.CDN_API_TOKEN_BASE_64;
const CI_COMMIT_TAG = process.env.CI_COMMIT_TAG;

@@ -64,45 +64,34 @@ const APP_STATIC_NAMESPACE = process.env.APP_STATIC_NAMESPACE;

const fetchFile = async params => {
const {
staticPath,
renderGoUrl,
file,
filePath,
requestId,
tryNumber,
} = params;
const fetchFile = async ({
renderGoUrl,
file,
filePath,
requestId,
tryNumber,
}) => {
try {
console.log(
`File ${filePath} start uploading: try ${tryNumber}, Request_Id: ${
params.requestId
}, timestamp: ${new Date().toISOString()}`.yellow,
`File ${filePath} start uploading: try ${tryNumber}, Request_Id: ${requestId}, timestamp: ${new Date().toISOString()}`
.yellow,
);
const formData = new FormData();
const task = {
request_id: requestId,
expires: '2050-07-12T14:14:18Z',
export: [{ target: BUCKET, key: staticPath }],
};
formData.append('file', fs.createReadStream(file));
formData.append('task', JSON.stringify(task));
const uploadResponse = await fetch(renderGoUrl, {
const uploadResponse = await fetch(`${renderGoUrl}/${newStaticPath}`, {
method: 'POST',
body: formData,
headers: {
Authorization: `bearer ${renderGoAuth}`,
Authorization: `Basic ${renderGoAuth}`,
},
});
}).then(data => data.json());
if (uploadResponse.status !== 200) {
throw new Error(`Status code – ${uploadResponse.status}`.red);
if (uploadResponse.state !== 0) {
throw new Error(`Status code – ${uploadResponse.state}`.red);
}
console.log(
`File ${filePath} start downloading: try ${tryNumber}, Request_Id: ${
params.requestId
}, timestamp: ${new Date().toISOString()}`.yellow,
`File ${filePath} start downloading: try ${tryNumber}, Request_Id: ${requestId}, timestamp: ${new Date().toISOString()}`
.yellow,
);

@@ -119,5 +108,4 @@

console.log(
`File ${filePath} uploaded - try ${tryNumber}, Request_Id: ${
params.requestId
}, timestamp: ${new Date().toISOString()}`.green,
`File ${filePath} uploaded - try ${tryNumber}, Request_Id: ${requestId}, timestamp: ${new Date().toISOString()}`
.green,
);

@@ -179,4 +167,2 @@ } catch (error) {

renderGoUrl: SERVICE_URL,
fileName: file.replace(`${pathToStaticFolder}`, ''),
staticPath,
filePath: `${WB_STATIC_URL}/${staticPath}`,

@@ -183,0 +169,0 @@ requestId,

{
"name": "@wildberries/service-cdn-uploader",
"version": "2.0.6",
"version": "3.0.0-beta.1",
"main": "./index.js",

@@ -5,0 +5,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc