edge-functions 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### [1.7.1](https://github.com/aziontech/vulcan/compare/v1.7.0...v1.7.1) (2023-10-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * adding the stage url ([18463ec](https://github.com/aziontech/vulcan/commit/18463ec530e7555e4e979d79ba1fdf70290cc81f))
7
+ * removing utf8 when reading file ([579c975](https://github.com/aziontech/vulcan/commit/579c975a8dc2e6e8b0596c9c228a346a98fed37d))
8
+ * removing utf8 when reading file ([#146](https://github.com/aziontech/vulcan/issues/146)) ([bd99219](https://github.com/aziontech/vulcan/commit/bd99219fefad5f718f9c6add32bb372063814ff9))
9
+
10
+ ### [1.7.1-stage.1](https://github.com/aziontech/vulcan/compare/v1.7.0...v1.7.1-stage.1) (2023-10-10)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * adding the stage url ([18463ec](https://github.com/aziontech/vulcan/commit/18463ec530e7555e4e979d79ba1fdf70290cc81f))
16
+ * removing utf8 when reading file ([579c975](https://github.com/aziontech/vulcan/commit/579c975a8dc2e6e8b0596c9c228a346a98fed37d))
17
+ * removing utf8 when reading file ([#146](https://github.com/aziontech/vulcan/issues/146)) ([bd99219](https://github.com/aziontech/vulcan/commit/bd99219fefad5f718f9c6add32bb372063814ff9))
18
+
1
19
  ## [1.7.0](https://github.com/aziontech/vulcan/compare/v1.6.5...v1.7.0) (2023-09-14)
2
20
 
3
21
 
@@ -41,28 +41,41 @@ async function uploadStatics(versionId, basePath, currentPath = '') {
41
41
  const fileStat = await promisify(fs.stat)(fullFilePath);
42
42
 
43
43
  if (fileStat.isFile()) {
44
- const fileContent = await promisify(fs.readFile)(fullFilePath, 'utf8');
44
+ const fileContent = await promisify(fs.readFile)(fullFilePath);
45
45
  const mimeType = mime.lookup(fullFilePath);
46
46
  const staticPath = path.join(currentPath, filePath).replace(/\\/g, '/');
47
47
 
48
48
  try {
49
- const response = await StorageService.upload(versionId, fileContent, staticPath, mimeType);
49
+ const response = await StorageService.upload(
50
+ versionId,
51
+ fileContent,
52
+ staticPath,
53
+ mimeType,
54
+ );
50
55
  if (response.statusText === 'OK') {
51
56
  successUploadCount += 1;
52
57
  feedback.statics.success(
53
58
  Messages.platform.storage.success.file_uploaded_success(filePath),
54
59
  );
55
60
  }
56
- if (!response.status === 'OK') { throw new Error(response); }
61
+ if (!response.status === 'OK') {
62
+ throw new Error(response);
63
+ }
57
64
  } catch (error) {
58
- feedback.statics.error(Messages.platform.storage.errors.file_upload_failed(filePath));
65
+ feedback.statics.error(
66
+ Messages.platform.storage.errors.file_upload_failed(filePath),
67
+ );
59
68
  debug.error(error);
60
69
  }
61
70
  } else if (fileStat.isDirectory()) {
62
71
  const subDirPath = path.join(currentPath, filePath);
63
- const subDirFiles = await promisify(fs.readdir)(path.join(basePath, subDirPath));
72
+ const subDirFiles = await promisify(fs.readdir)(
73
+ path.join(basePath, subDirPath),
74
+ );
64
75
 
65
- await Promise.all(subDirFiles.map((file) => uploadFiles(path.join(subDirPath, file))));
76
+ await Promise.all(
77
+ subDirFiles.map((file) => uploadFiles(path.join(subDirPath, file))),
78
+ );
66
79
  }
67
80
  }
68
81
 
@@ -75,7 +88,9 @@ async function uploadStatics(versionId, basePath, currentPath = '') {
75
88
  }
76
89
 
77
90
  feedback.statics.success(
78
- Messages.platform.storage.success.statics_uploaded_finish(successUploadCount),
91
+ Messages.platform.storage.success.statics_uploaded_finish(
92
+ successUploadCount,
93
+ ),
79
94
  );
80
95
  return successUploadCount;
81
96
  }
@@ -1,5 +1,11 @@
1
1
  import BaseService from './base.service.js';
2
2
 
3
+ const env = globalThis.vulcan?.env ? globalThis.vulcan.env : 'production';
4
+ const API = {
5
+ stage: 'https://stage-storage-api.azion.com',
6
+ production: 'https://storage-api.azion.com',
7
+ };
8
+
3
9
  /**
4
10
  * Service for interacting with the Azion Storage API.
5
11
  * Extends the BaseService class.
@@ -10,7 +16,7 @@ class StorageService extends BaseService {
10
16
  * Sets the base URL for the Storage API.
11
17
  */
12
18
  constructor() {
13
- super('https://storage-api.azion.com/storage');
19
+ super(`${API[env]}/storage`);
14
20
  }
15
21
 
16
22
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "edge-functions",
3
3
  "type": "module",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
5
5
  "description": "Tool to launch and build JavaScript/Frameworks. This tool automates polyfills for Edge Computing and assists in creating Workers, notably for the Azion platform.",
6
6
  "main": "lib/main.js",
7
7
  "bin": {