serverless-offline 14.2.0 → 14.3.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/README.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Serverless Offline
|
|
2
2
|
|
|
3
|
+
<div align="center">
|
|
4
|
+
<p>
|
|
5
|
+
<sup>
|
|
6
|
+
<a href="https://github.com/sponsors/dherault">Serverless-offline is supported by the community.</a>
|
|
7
|
+
</sup>
|
|
8
|
+
</p>
|
|
9
|
+
<sup>
|
|
10
|
+
Special thanks to:
|
|
11
|
+
</sup>
|
|
12
|
+
<a href="https://arccode.dev?ref=so">
|
|
13
|
+
<div>
|
|
14
|
+
<img src="https://arccode.dev/images/logotype.png" height="64" alt="Arccode">
|
|
15
|
+
</div>
|
|
16
|
+
<b>
|
|
17
|
+
The first role-playing game for developers
|
|
18
|
+
</b>
|
|
19
|
+
<div>
|
|
20
|
+
XP, level ups and guilds. All while you work.
|
|
21
|
+
</div>
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
3
25
|
<p>
|
|
4
26
|
<a href="https://www.serverless.com">
|
|
5
27
|
<img src="http://public.serverless.com/badges/v3.svg">
|
|
@@ -195,6 +217,10 @@ Turns off all authorizers.
|
|
|
195
217
|
|
|
196
218
|
Don't prepend http routes with the stage.
|
|
197
219
|
|
|
220
|
+
#### noSponsor
|
|
221
|
+
|
|
222
|
+
Remove sponsor message from the output.
|
|
223
|
+
|
|
198
224
|
#### noTimeout
|
|
199
225
|
|
|
200
226
|
-t Disables the timeout feature.
|
|
@@ -239,6 +265,11 @@ Default: 600 (10 minutes)
|
|
|
239
265
|
WebSocket port to listen on.<br />
|
|
240
266
|
Default: 3001
|
|
241
267
|
|
|
268
|
+
#### preLoadModules
|
|
269
|
+
|
|
270
|
+
Pre-load specified modules in the main thread to avoid crashes when importing in worker threads. Provide module names as a comma-separated list (e.g., "sharp,canvas").<br />
|
|
271
|
+
Default: ''
|
|
272
|
+
|
|
242
273
|
Any of the CLI options can be added to your `serverless.yml`. For example:
|
|
243
274
|
|
|
244
275
|
```yml
|
package/package.json
CHANGED
package/src/ServerlessOffline.js
CHANGED
|
@@ -65,6 +65,8 @@ export default class ServerlessOffline {
|
|
|
65
65
|
async start() {
|
|
66
66
|
this.#mergeOptions()
|
|
67
67
|
|
|
68
|
+
this.#preLoadModules()
|
|
69
|
+
|
|
68
70
|
if (this.#cliOptions.noSponsor) {
|
|
69
71
|
log.notice()
|
|
70
72
|
} else {
|
|
@@ -423,6 +425,20 @@ export default class ServerlessOffline {
|
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
|
|
428
|
+
#preLoadModules() {
|
|
429
|
+
const modules = this.#options.preLoadModules.split(",")
|
|
430
|
+
|
|
431
|
+
modules.forEach((module) => {
|
|
432
|
+
if (!module) return
|
|
433
|
+
|
|
434
|
+
try {
|
|
435
|
+
import(module)
|
|
436
|
+
} catch (error) {
|
|
437
|
+
log.error(`Error importing module ${module}: ${error}`)
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
}
|
|
441
|
+
|
|
426
442
|
// TODO FIXME
|
|
427
443
|
// TEMP quick fix to expose for testing, look for better solution
|
|
428
444
|
internals() {
|
|
@@ -446,6 +462,10 @@ export default class ServerlessOffline {
|
|
|
446
462
|
mergeOptions: () => {
|
|
447
463
|
this.#mergeOptions()
|
|
448
464
|
},
|
|
465
|
+
|
|
466
|
+
preLoadModules: () => {
|
|
467
|
+
this.#preLoadModules()
|
|
468
|
+
},
|
|
449
469
|
}
|
|
450
470
|
}
|
|
451
471
|
}
|
|
@@ -104,6 +104,10 @@ export default {
|
|
|
104
104
|
usage:
|
|
105
105
|
"Adds a prefix to every path, to send your requests to http://localhost:3000/prefix/[your_path] instead.",
|
|
106
106
|
},
|
|
107
|
+
preLoadModules: {
|
|
108
|
+
type: "string",
|
|
109
|
+
usage: "A comma separated list of modules to preload on the main thread",
|
|
110
|
+
},
|
|
107
111
|
reloadHandler: {
|
|
108
112
|
type: "boolean",
|
|
109
113
|
usage: "Reloads handler with each request.",
|
|
@@ -104,7 +104,7 @@ if __name__ == '__main__':
|
|
|
104
104
|
'__offline_payload__': result
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
if isinstance(result['body'], bytes):
|
|
107
|
+
if hasattr(result, 'body') and isinstance(result['body'], bytes):
|
|
108
108
|
data['__offline_payload__']['body'] = base64.b64encode(result['body']).decode('utf-8')
|
|
109
109
|
data['isBase64Encoded'] = True
|
|
110
110
|
|