@certik/skynet 0.14.0 → 0.15.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 +9 -0
- package/app.js +3 -3
- package/bun.lockb +0 -0
- package/deploy.js +2 -1
- package/package.json +2 -2
- package/s3.js +26 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.1
|
|
4
|
+
|
|
5
|
+
- BREAKING: changed api restart behavior to never fail the allocation
|
|
6
|
+
|
|
7
|
+
## 0.15.0
|
|
8
|
+
|
|
9
|
+
- BREAKING: only start one S3 client globally
|
|
10
|
+
- Fixed: Properly throw error if S3 client encounters them
|
|
11
|
+
|
|
3
12
|
## 0.14.0
|
|
4
13
|
|
|
5
14
|
- BREAKING: only start one DynamoDB client globally
|
package/app.js
CHANGED
|
@@ -46,7 +46,7 @@ async function checkDeployEnv(env) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return { name: key, ok: true };
|
|
49
|
-
})
|
|
49
|
+
}),
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
const missingEnvs = envStatus.filter((s) => !s.ok).map((s) => s.name);
|
|
@@ -694,8 +694,8 @@ function api({ name, routes, serve, beforeListen, env = {}, region = "us-east-1"
|
|
|
694
694
|
restart: {
|
|
695
695
|
attempts: 3,
|
|
696
696
|
delay: "15s",
|
|
697
|
-
mode: "
|
|
698
|
-
interval: "
|
|
697
|
+
mode: "delay",
|
|
698
|
+
interval: "2m",
|
|
699
699
|
},
|
|
700
700
|
count: serve.instances,
|
|
701
701
|
killTimeout: serve.killTimeout,
|
package/bun.lockb
CHANGED
|
Binary file
|
package/deploy.js
CHANGED
package/package.json
CHANGED
package/s3.js
CHANGED
|
@@ -6,11 +6,17 @@ import {
|
|
|
6
6
|
DeleteObjectCommand,
|
|
7
7
|
ListObjectsV2Command,
|
|
8
8
|
NotFound,
|
|
9
|
+
NoSuchKey,
|
|
9
10
|
} from "@aws-sdk/client-s3";
|
|
10
11
|
import { getAWSSDKConfig } from "./env.js";
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
let _s3Client;
|
|
14
|
+
|
|
15
|
+
function getS3(forceNew = false) {
|
|
16
|
+
if (!_s3Client || forceNew) {
|
|
17
|
+
_s3Client = new S3Client(getAWSSDKConfig());
|
|
18
|
+
}
|
|
19
|
+
return _s3Client;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
async function readFile(bucketName, key, verbose = false) {
|
|
@@ -21,12 +27,16 @@ async function readFile(bucketName, key, verbose = false) {
|
|
|
21
27
|
try {
|
|
22
28
|
const result = await s3.send(new GetObjectCommand(params));
|
|
23
29
|
return result.Body.transformToString();
|
|
24
|
-
} catch (
|
|
25
|
-
if (
|
|
26
|
-
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error instanceof NoSuchKey) {
|
|
32
|
+
if (verbose) {
|
|
33
|
+
console.log("no such bucket or key", bucketName, key);
|
|
34
|
+
}
|
|
35
|
+
// do nothing
|
|
36
|
+
return null;
|
|
27
37
|
}
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
|
|
39
|
+
throw error;
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
|
|
@@ -93,10 +103,16 @@ async function deleteFile(bucketName, key, verbose = false) {
|
|
|
93
103
|
|
|
94
104
|
try {
|
|
95
105
|
await s3.send(new DeleteObjectCommand(params));
|
|
96
|
-
} catch (
|
|
97
|
-
if (
|
|
98
|
-
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof NoSuchKey) {
|
|
108
|
+
if (verbose) {
|
|
109
|
+
console.log("no such bucket or key", bucketName, key);
|
|
110
|
+
}
|
|
111
|
+
// do nothing
|
|
112
|
+
return null;
|
|
99
113
|
}
|
|
114
|
+
|
|
115
|
+
throw error;
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
|