@crvouga/mockingbird-service-s3 3.6.0 → 3.8.0
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 +14 -1
- package/README.md +13 -1
- package/dist/{chunk-PZ2JLZAI.js → chunk-2B5OVZSH.js} +153 -20
- package/dist/chunk-2B5OVZSH.js.map +7 -0
- package/dist/{chunk-PCW23MUG.js → chunk-NNRVXV6X.js} +637 -127
- package/dist/chunk-NNRVXV6X.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +93 -8
- package/dist/index.js +3 -1
- package/dist/server.d.ts +135 -7
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-PCW23MUG.js.map +0 -7
- package/dist/chunk-PZ2JLZAI.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-s3
|
|
2
2
|
|
|
3
|
-
## 3.
|
|
3
|
+
## 3.8.0 (2026-10-21)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- raise the serve and fleet body limit to the S3 maximum ([86b9e2b](https://github.com/crvouga/mockingbird/commit/86b9e2b80bcaaaef57f52edbac50b27da0b42f33))
|
|
8
|
+
- response overrides, copy conditionals, chunked uploads and related S3 parity ([8f21aa7](https://github.com/crvouga/mockingbird/commit/8f21aa717837a0fd5de3ed833c8e3b03a84b4e5a))
|
|
9
|
+
|
|
10
|
+
## 3.7.0 (2026-10-18)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- resolve the agent-reported issue queue in one batch ([25c52b6](https://github.com/crvouga/mockingbird/commit/25c52b668a53ddb80b968419601a20abf33f956b))
|
|
15
|
+
|
|
16
|
+
## 3.6.0 (2026-10-16)
|
|
4
17
|
|
|
5
18
|
### Features
|
|
6
19
|
|
package/README.md
CHANGED
|
@@ -42,6 +42,17 @@ await server.close()
|
|
|
42
42
|
|
|
43
43
|
Set an application's S3 endpoint environment variable to the server URL and its region to `us-east-1`. Supported REST operations are CreateBucket, HeadBucket, PutObject, GetObject, HeadObject, DeleteObject, DeleteObjects, CopyObject, ListObjectsV2, and multipart create/upload/complete/abort. SDK `GetObject` bodies retain its streaming helpers.
|
|
44
44
|
|
|
45
|
+
### Request semantics
|
|
46
|
+
|
|
47
|
+
Each behavior follows the linked Amazon S3 reference.
|
|
48
|
+
|
|
49
|
+
- **Response header overrides** ([GetObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html)): `response-cache-control`, `response-content-disposition`, `response-content-encoding`, `response-content-language`, `response-content-type` and `response-expires` replace the stored header on a 200 or 206 GetObject and on HeadObject. Like S3, they are refused with `400 InvalidRequest` on anonymous requests.
|
|
50
|
+
- **Copy-source preconditions** ([CopyObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html)): `x-amz-copy-source-if-match`, `-if-none-match`, `-if-modified-since` and `-if-unmodified-since` are evaluated against the source object. An unmet precondition answers `412 PreconditionFailed` and copies nothing; a true `if-match` overrides a false `if-unmodified-since`, and a matching `if-none-match` is `412` whatever `if-modified-since` says, as documented. When `if-none-match` is present, `if-modified-since` is not consulted (best guess, not oracle-verified: the reference does not state it).
|
|
51
|
+
- **Streaming uploads** ([SigV4 streaming](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html), [with trailers](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming-trailers.html)): `Content-Encoding: aws-chunked` bodies (signed and `STREAMING-UNSIGNED-PAYLOAD-TRAILER`) are decoded before storing, on PutObject and UploadPart. The stored length is `x-amz-decoded-content-length`; a trailer or header `x-amz-checksum-*` that does not match, or a wrong decoded length, is rejected with `400` (`BadDigest` / `IncompleteBody`) and stores nothing. Chunk signatures are not verified.
|
|
52
|
+
- **Body size** ([upload limits](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html)): `createServer` accepts bodies up to 5 GiB, the S3 maximum for one PUT or part, and answers larger ones with S3's `EntityTooLarge`. `createServer({ maxBodyBytes })` lowers the limit. `mockingbird-s3 serve` and fleet entries use the same 5 GiB limit (the target sets `maxBodyBytes`; other services keep the adapter's 16 MiB default).
|
|
53
|
+
- **Virtual-hosted-style addressing** ([VirtualHosting](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html)): `Host: <bucket>.<base host>` names the bucket and the path is the key, so an SDK client without `forcePathStyle` works against `AWS_ENDPOINT_URL_S3=http://localhost:<port>`. The base hosts default to `localhost` (so `docs.localhost`); set `virtualHosts` (`--virtual-host a,b`, empty for path-style only) to change them. Path-style requests and IP or other hosts are unchanged, an unknown bucket is `NoSuchBucket`, no request ever creates a bucket as a side effect, presigned URLs are verified against the virtual host, and the admin prefix keeps its path on any host.
|
|
54
|
+
- **Bucket CORS** ([CORS](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html), [PutBucketCors](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html), [OPTIONS object](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTOPTIONSobject.html)): the stored `CORSConfiguration` is enforced. An unauthenticated `OPTIONS` preflight (any `X-Amz-*` query is ignored) is answered by the first rule matching origin, method and requested headers with `Access-Control-Allow-Origin/-Methods/-Headers/-Max-Age/-Expose-Headers` and `Vary`; otherwise it is `403 AccessForbidden` ("CORSResponse: This CORS request is not allowed.", or "CORS is not enabled for this bucket." with no rules or after `DeleteBucketCors`) with no `Access-Control-*` headers. Actual requests with an allowed `Origin` and method get `Access-Control-Allow-Origin`, `Access-Control-Expose-Headers` and `Vary: Origin`, errors included. `PutBucketCors` rejects empty rule sets, unsupported methods and multiple wildcards. Best guess, not oracle-verified: the exact set and ordering of preflight headers beyond what the docs list (the `AccessForbidden` error code matches what S3 and s3rver return for a disabled bucket); no live AWS bucket was exercised.
|
|
55
|
+
|
|
45
56
|
### Admin and deterministic controls
|
|
46
57
|
|
|
47
58
|
- `GET/POST /__admin/objects` inspects metadata or seeds an object; `GET /__admin/objects/:bucket/:key` downloads its bytes.
|
|
@@ -54,7 +65,7 @@ The shared runtime also provides health, reset, journal, metrics, timeline, and
|
|
|
54
65
|
|
|
55
66
|
### Deliberately not modelled
|
|
56
67
|
|
|
57
|
-
Operations outside the surface listed above, object versioning, ACL/IAM policy evaluation, storage classes, checksums beyond ETags, production quotas, AWS dashboards and billing,
|
|
68
|
+
Operations outside the surface listed above, object versioning, ACL/IAM policy evaluation, storage classes, checksums beyond ETags, production quotas, AWS dashboards and billing, and real SQS delivery are not modelled. SQS consumers can use the same captured notification payload through a configured HTTP sink.
|
|
58
69
|
|
|
59
70
|
## API
|
|
60
71
|
|
|
@@ -62,6 +73,7 @@ Operations outside the surface listed above, object versioning, ACL/IAM policy e
|
|
|
62
73
|
- `S3Notification`, `S3Object`, `S3SeedObject`: notification, state, and fixture types.
|
|
63
74
|
- `createRuntime`, `S3Runtime`, `S3RuntimeOptions`: full Mockingbird runtime and webhook hub.
|
|
64
75
|
- `S3_NAMESPACE`, `S3_PRESETS`, `accessKeyCredential`: constants and fault controls.
|
|
76
|
+
- `S3_MAX_UPLOAD_BYTES`: the default request body limit (5 GiB) for `createServer`.
|
|
65
77
|
- `document`, `operationIds`, `supportedOperationIds`: generated OpenAPI metadata.
|
|
66
78
|
- `createServer`, `S3ServerOptions`, `DEFAULT_PORT`, `serveTarget` from `./server`: Node HTTP adapter and CLI integration.
|
|
67
79
|
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
|
+
S3_MAX_UPLOAD_BYTES,
|
|
2
3
|
createClock,
|
|
3
4
|
createRuntime,
|
|
4
5
|
normalizeBootControls,
|
|
5
6
|
normalizeControls,
|
|
7
|
+
normalizeIdBase,
|
|
6
8
|
ownedTransport,
|
|
7
9
|
parseDuration,
|
|
8
10
|
parseFaultHeader,
|
|
9
11
|
resolveAdminPrefix,
|
|
10
12
|
restoreClock
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NNRVXV6X.js";
|
|
12
14
|
|
|
13
15
|
// ../../adapters/node/dist/cli.js
|
|
14
16
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
15
17
|
import { parseArgs } from "node:util";
|
|
16
18
|
|
|
19
|
+
// ../../adapters/node/dist/boot-settings.js
|
|
20
|
+
var checkSettings = (target, settings, label) => {
|
|
21
|
+
if (!target.parseSettings)
|
|
22
|
+
throw new Error(`${label}: ${target.name} takes no boot settings`);
|
|
23
|
+
try {
|
|
24
|
+
return target.parseSettings(settings);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
throw new Error(`${label}: ${error instanceof Error ? error.message : String(error)}`, {
|
|
27
|
+
cause: error
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
17
32
|
// ../../adapters/node/dist/fleet.js
|
|
18
33
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
19
34
|
import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -2663,6 +2678,9 @@ var fleet_config_schema_default = {
|
|
|
2663
2678
|
adminControls: {
|
|
2664
2679
|
$ref: "#/$defs/controls"
|
|
2665
2680
|
},
|
|
2681
|
+
idBase: {
|
|
2682
|
+
$ref: "#/$defs/idBase"
|
|
2683
|
+
},
|
|
2666
2684
|
namespace: {
|
|
2667
2685
|
type: "string",
|
|
2668
2686
|
pattern: "^[A-Za-z0-9_.-]{1,64}$"
|
|
@@ -2752,6 +2770,12 @@ var fleet_config_schema_default = {
|
|
|
2752
2770
|
adminControls: {
|
|
2753
2771
|
$ref: "#/$defs/controls"
|
|
2754
2772
|
},
|
|
2773
|
+
idBase: {
|
|
2774
|
+
$ref: "#/$defs/idBase"
|
|
2775
|
+
},
|
|
2776
|
+
settings: {
|
|
2777
|
+
type: "object"
|
|
2778
|
+
},
|
|
2755
2779
|
fixtures: {
|
|
2756
2780
|
type: "object"
|
|
2757
2781
|
},
|
|
@@ -2798,6 +2822,18 @@ var fleet_config_schema_default = {
|
|
|
2798
2822
|
}
|
|
2799
2823
|
}
|
|
2800
2824
|
},
|
|
2825
|
+
idBase: {
|
|
2826
|
+
anyOf: [
|
|
2827
|
+
{
|
|
2828
|
+
type: "integer",
|
|
2829
|
+
minimum: 0
|
|
2830
|
+
},
|
|
2831
|
+
{
|
|
2832
|
+
type: "string",
|
|
2833
|
+
pattern: "^(boot|[0-9]+)$"
|
|
2834
|
+
}
|
|
2835
|
+
]
|
|
2836
|
+
},
|
|
2801
2837
|
controls: {
|
|
2802
2838
|
type: "object",
|
|
2803
2839
|
additionalProperties: false,
|
|
@@ -2947,6 +2983,8 @@ async function preflightFleet(config, options) {
|
|
|
2947
2983
|
throw new Error("protected archive policy requires a protected repository; configure its protector before startup");
|
|
2948
2984
|
resolveAdminPrefix(config.adminPrefix);
|
|
2949
2985
|
normalizeBootControls(config.adminControls);
|
|
2986
|
+
if (config.idBase !== void 0)
|
|
2987
|
+
normalizeIdBase(config.idBase, "idBase");
|
|
2950
2988
|
const targets = /* @__PURE__ */ new Map();
|
|
2951
2989
|
const ports = /* @__PURE__ */ new Set();
|
|
2952
2990
|
for (const [name, entry] of Object.entries(config.services)) {
|
|
@@ -2978,6 +3016,13 @@ async function preflightFleet(config, options) {
|
|
|
2978
3016
|
throw new Error("invalid protocol namespace selector");
|
|
2979
3017
|
}
|
|
2980
3018
|
}
|
|
3019
|
+
if (entry.idBase !== void 0)
|
|
3020
|
+
normalizeIdBase(entry.idBase, "idBase");
|
|
3021
|
+
if (entry.settings !== void 0) {
|
|
3022
|
+
if (protocol !== "http" || !("create" in target))
|
|
3023
|
+
throw new Error("settings: only HTTP services take boot settings");
|
|
3024
|
+
checkSettings(target, entry.settings, "settings");
|
|
3025
|
+
}
|
|
2981
3026
|
const port = entry.port ?? target.defaultPort;
|
|
2982
3027
|
if (port !== 0) {
|
|
2983
3028
|
const key = `${entry.host ?? "127.0.0.1"}:${port}`;
|
|
@@ -3013,7 +3058,7 @@ async function preflightFleet(config, options) {
|
|
|
3013
3058
|
break;
|
|
3014
3059
|
}
|
|
3015
3060
|
}
|
|
3016
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.
|
|
3061
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.8.0" });
|
|
3017
3062
|
} catch (error) {
|
|
3018
3063
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3019
3064
|
}
|
|
@@ -3239,7 +3284,11 @@ var serve = async (api, options = {}) => {
|
|
|
3239
3284
|
// ../../adapters/node/dist/listen.js
|
|
3240
3285
|
var listen = async (api, options = {}) => {
|
|
3241
3286
|
const host = options.host ?? "127.0.0.1";
|
|
3242
|
-
const server = await serve(api, {
|
|
3287
|
+
const server = await serve(api, {
|
|
3288
|
+
port: options.port ?? 0,
|
|
3289
|
+
host,
|
|
3290
|
+
...options.maxBodyBytes !== void 0 ? { maxBodyBytes: options.maxBodyBytes } : {}
|
|
3291
|
+
});
|
|
3243
3292
|
const address = server.address();
|
|
3244
3293
|
const port = typeof address === "object" && address !== null ? address.port : options.port ?? 0;
|
|
3245
3294
|
const shown = host.includes(":") ? `[${host}]` : host;
|
|
@@ -3333,6 +3382,7 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
|
|
|
3333
3382
|
options.onLog?.(entry2);
|
|
3334
3383
|
},
|
|
3335
3384
|
...entry.adminControls !== void 0 ? { adminControls: entry.adminControls } : {},
|
|
3385
|
+
...entry.settings !== void 0 ? { settings: checkSettings(target, entry.settings, "settings") } : {},
|
|
3336
3386
|
...entry.fixtures !== void 0 ? { fixtures: entry.fixtures } : {},
|
|
3337
3387
|
...(advertisedHttpBase(entry) ?? entry.baseUrl) !== void 0 ? { baseUrl: advertisedHttpBase(entry) ?? entry.baseUrl } : {}
|
|
3338
3388
|
});
|
|
@@ -3351,6 +3401,8 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
|
|
|
3351
3401
|
].some((method) => typeof created[method] !== "function"))
|
|
3352
3402
|
throw new Error("HTTP target does not implement the fleet runtime protocol; build/install matching supported service versions");
|
|
3353
3403
|
const runtime = created;
|
|
3404
|
+
if (entry.idBase !== void 0)
|
|
3405
|
+
runtime.setIdBase?.(entry.idBase);
|
|
3354
3406
|
const unobserve = runtime.webhooks?.observeDeliveries(observer.delivery);
|
|
3355
3407
|
if (options.outbound && runtime.webhooks)
|
|
3356
3408
|
runtime.webhooks.setTransportPolicy(ownedTransport(options.outbound));
|
|
@@ -3435,7 +3487,8 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
|
|
|
3435
3487
|
try {
|
|
3436
3488
|
server = await listen(api, {
|
|
3437
3489
|
port: entry.port ?? target.defaultPort,
|
|
3438
|
-
host: entry.host ?? "127.0.0.1"
|
|
3490
|
+
host: entry.host ?? "127.0.0.1",
|
|
3491
|
+
...target.maxBodyBytes !== void 0 ? { maxBodyBytes: target.maxBodyBytes } : {}
|
|
3439
3492
|
});
|
|
3440
3493
|
target.listening?.(server);
|
|
3441
3494
|
} catch (error) {
|
|
@@ -3949,6 +4002,7 @@ async function startFleet(config, options) {
|
|
|
3949
4002
|
...entry,
|
|
3950
4003
|
adminPrefix: resolveAdminPrefix(entry.adminPrefix ?? adminPrefix),
|
|
3951
4004
|
...adminKey !== void 0 ? { adminKey } : {},
|
|
4005
|
+
...(entry.idBase ?? config.idBase) !== void 0 ? { idBase: entry.idBase ?? config.idBase } : {},
|
|
3952
4006
|
// Fleet-wide controls, with the service's own keys replacing them.
|
|
3953
4007
|
...config.adminControls !== void 0 || entry.adminControls !== void 0 ? { adminControls: { ...config.adminControls, ...entry.adminControls } } : {}
|
|
3954
4008
|
}, options, (namespace, request) => management?.admit(namespace, request), (namespace) => management?.generation(namespace), (namespace, request) => management?.privateRequest(namespace, request) ?? false, {
|
|
@@ -4633,6 +4687,16 @@ var COMMON_SERVE_OPTIONS = {
|
|
|
4633
4687
|
value: "<seed>",
|
|
4634
4688
|
description: "Seed for every random choice (env MOCKINGBIRD_SEED)"
|
|
4635
4689
|
},
|
|
4690
|
+
"id-base": {
|
|
4691
|
+
type: "string",
|
|
4692
|
+
value: "<n|boot>",
|
|
4693
|
+
description: "Start generated ids at this base so a restart does not reissue the last boot's ids; boot derives one from the clock (env MOCKINGBIRD_ID_BASE; default 0, the same ids every boot)"
|
|
4694
|
+
},
|
|
4695
|
+
settings: {
|
|
4696
|
+
type: "string",
|
|
4697
|
+
value: "<json|file>",
|
|
4698
|
+
description: "Service settings to boot with, as JSON or a JSON file; every namespace starts from them (env MOCKINGBIRD_SETTINGS; only for services that declare settings)"
|
|
4699
|
+
},
|
|
4636
4700
|
"admin-controls": {
|
|
4637
4701
|
type: "string",
|
|
4638
4702
|
value: "<json|file>",
|
|
@@ -4727,19 +4791,40 @@ var readJsonFile = async (path, label) => {
|
|
|
4727
4791
|
}
|
|
4728
4792
|
};
|
|
4729
4793
|
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4794
|
+
var readJsonOption = async (source, label) => {
|
|
4795
|
+
const trimmed = source.trim();
|
|
4796
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
4797
|
+
try {
|
|
4798
|
+
return JSON.parse(trimmed);
|
|
4799
|
+
} catch {
|
|
4800
|
+
throw new Error(`${label}: not valid JSON`);
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
return readJsonFile(source, label);
|
|
4804
|
+
};
|
|
4805
|
+
var resolveServeIdBase = (values, env = process.env) => {
|
|
4806
|
+
const source = asString(values["id-base"]) ?? env.MOCKINGBIRD_ID_BASE;
|
|
4807
|
+
if (source === void 0 || source.trim() === "")
|
|
4808
|
+
return void 0;
|
|
4809
|
+
normalizeIdBase(source.trim(), "--id-base");
|
|
4810
|
+
return source.trim();
|
|
4811
|
+
};
|
|
4812
|
+
var resolveServeSettings = async (target, values, env = process.env) => {
|
|
4813
|
+
const flag = asString(values.settings);
|
|
4814
|
+
const source = flag ?? env.MOCKINGBIRD_SETTINGS;
|
|
4815
|
+
if (source === void 0 || source.trim() === "")
|
|
4816
|
+
return void 0;
|
|
4817
|
+
const label = flag !== void 0 ? "--settings" : "MOCKINGBIRD_SETTINGS";
|
|
4818
|
+
const parsed = await readJsonOption(source, label);
|
|
4819
|
+
if (!isObject2(parsed))
|
|
4820
|
+
throw new Error(`${label}: expected a JSON object`);
|
|
4821
|
+
return checkSettings(target, parsed, label);
|
|
4822
|
+
};
|
|
4730
4823
|
var resolveServeControls = async (values, env = process.env, base) => {
|
|
4731
4824
|
const source = asString(values["admin-controls"]) ?? env.MOCKINGBIRD_ADMIN_CONTROLS;
|
|
4732
4825
|
let document = isObject2(base) ? { ...base } : {};
|
|
4733
4826
|
if (source !== void 0 && source.trim() !== "") {
|
|
4734
|
-
|
|
4735
|
-
if (source.trim().startsWith("{")) {
|
|
4736
|
-
try {
|
|
4737
|
-
parsed = JSON.parse(source);
|
|
4738
|
-
} catch {
|
|
4739
|
-
throw new Error("--admin-controls: not valid JSON");
|
|
4740
|
-
}
|
|
4741
|
-
} else
|
|
4742
|
-
parsed = await readJsonFile(source, "--admin-controls");
|
|
4827
|
+
const parsed = source.trim().startsWith("{") ? await readJsonOption(source, "--admin-controls") : await readJsonFile(source, "--admin-controls");
|
|
4743
4828
|
if (!isObject2(parsed))
|
|
4744
4829
|
throw new Error("--admin-controls: expected a JSON object");
|
|
4745
4830
|
document = { ...document, ...parsed };
|
|
@@ -4789,9 +4874,16 @@ var start = async (target, values, config) => {
|
|
|
4789
4874
|
adminKey: config.adminKey,
|
|
4790
4875
|
seed: config.seed,
|
|
4791
4876
|
onLog: formatLog(config.log),
|
|
4877
|
+
...config.settings !== void 0 ? { settings: config.settings } : {},
|
|
4792
4878
|
...config.adminControls !== void 0 ? { adminControls: config.adminControls } : {}
|
|
4793
4879
|
});
|
|
4794
|
-
|
|
4880
|
+
if (config.idBase !== void 0)
|
|
4881
|
+
runtime.setIdBase?.(config.idBase);
|
|
4882
|
+
const listening = await listen(runtime, {
|
|
4883
|
+
port: config.port,
|
|
4884
|
+
host: config.host,
|
|
4885
|
+
...target.maxBodyBytes !== void 0 ? { maxBodyBytes: target.maxBodyBytes } : {}
|
|
4886
|
+
});
|
|
4795
4887
|
target.listening?.(listening);
|
|
4796
4888
|
console.log(`${target.name} emulator listening on ${listening.url}`);
|
|
4797
4889
|
console.log(`${target.name} health: GET ${listening.url}${adminPrefix}/health`);
|
|
@@ -4836,6 +4928,11 @@ var serveCommand = (target) => ({
|
|
|
4836
4928
|
const adminControls = await resolveServeControls(values, process.env, config.adminControls);
|
|
4837
4929
|
if (adminControls !== void 0)
|
|
4838
4930
|
config.adminControls = adminControls;
|
|
4931
|
+
if (values.settings !== void 0)
|
|
4932
|
+
throw new Error("--settings serves a single service; give each service its own `settings` in the config");
|
|
4933
|
+
const idBase = config.idBase ?? resolveServeIdBase(values);
|
|
4934
|
+
if (idBase !== void 0)
|
|
4935
|
+
config.idBase = idBase;
|
|
4839
4936
|
const fleet = await startFleet(config, {
|
|
4840
4937
|
load: (name) => loadTarget(name, target),
|
|
4841
4938
|
onLog: formatLog(config.log ?? log),
|
|
@@ -4865,8 +4962,12 @@ var serveCommand = (target) => ({
|
|
|
4865
4962
|
let listening;
|
|
4866
4963
|
try {
|
|
4867
4964
|
const adminControls = await resolveServeControls(values);
|
|
4965
|
+
const idBase = resolveServeIdBase(values);
|
|
4966
|
+
const settings = await resolveServeSettings(target, values);
|
|
4868
4967
|
listening = await start(target, values, {
|
|
4869
4968
|
...adminControls !== void 0 ? { adminControls } : {},
|
|
4969
|
+
...idBase !== void 0 ? { idBase } : {},
|
|
4970
|
+
...settings !== void 0 ? { settings } : {},
|
|
4870
4971
|
adminPrefix: resolveAdminPrefix(asString(values["admin-prefix"]) ?? process.env.MOCKINGBIRD_ADMIN_PREFIX),
|
|
4871
4972
|
port: port === void 0 ? target.defaultPort : Number.parseInt(port, 10),
|
|
4872
4973
|
host: asString(values.host) ?? "127.0.0.1",
|
|
@@ -4885,22 +4986,54 @@ var serveCommand = (target) => ({
|
|
|
4885
4986
|
// src/server.ts
|
|
4886
4987
|
var DEFAULT_PORT = 8812;
|
|
4887
4988
|
var createServer2 = async (options = {}) => {
|
|
4888
|
-
const { port, host, ...rest } = options;
|
|
4989
|
+
const { port, host, maxBodyBytes, ...rest } = options;
|
|
4889
4990
|
const runtime = createRuntime(rest);
|
|
4890
|
-
|
|
4991
|
+
const bind = host ?? "127.0.0.1";
|
|
4992
|
+
const server = await serve(runtime, {
|
|
4993
|
+
port: port ?? 0,
|
|
4994
|
+
host: bind,
|
|
4995
|
+
maxBodyBytes: maxBodyBytes ?? S3_MAX_UPLOAD_BYTES
|
|
4996
|
+
});
|
|
4997
|
+
const address = server.address();
|
|
4998
|
+
const bound = typeof address === "object" && address !== null ? address.port : port ?? 0;
|
|
4999
|
+
return {
|
|
5000
|
+
url: `http://${bind.includes(":") ? `[${bind}]` : bind}:${bound}`,
|
|
5001
|
+
port: bound,
|
|
5002
|
+
host: bind,
|
|
5003
|
+
server,
|
|
5004
|
+
runtime,
|
|
5005
|
+
close: () => new Promise((resolve4, reject) => {
|
|
5006
|
+
server.close((error) => {
|
|
5007
|
+
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") reject(error);
|
|
5008
|
+
else resolve4();
|
|
5009
|
+
});
|
|
5010
|
+
server.closeAllConnections?.();
|
|
5011
|
+
})
|
|
5012
|
+
};
|
|
4891
5013
|
};
|
|
4892
5014
|
var serveTarget = {
|
|
4893
5015
|
name: "s3",
|
|
4894
5016
|
defaultPort: DEFAULT_PORT,
|
|
4895
|
-
|
|
5017
|
+
maxBodyBytes: S3_MAX_UPLOAD_BYTES,
|
|
5018
|
+
options: {
|
|
5019
|
+
"virtual-host": {
|
|
5020
|
+
type: "string",
|
|
5021
|
+
value: "<hosts>",
|
|
5022
|
+
description: "Comma-separated base hosts for virtual-hosted-style requests: Host <bucket>.<host> names the bucket (default localhost; empty for path-style only)"
|
|
5023
|
+
}
|
|
5024
|
+
},
|
|
5025
|
+
create: (values, common) => createRuntime({
|
|
4896
5026
|
...common.adminPrefix !== void 0 ? { adminPrefix: common.adminPrefix } : {},
|
|
4897
5027
|
...common.adminKey !== void 0 ? { adminKey: common.adminKey } : {},
|
|
4898
5028
|
...common.adminControls !== void 0 ? { adminControls: common.adminControls } : {},
|
|
4899
5029
|
...common.seed !== void 0 ? { seed: common.seed } : {},
|
|
4900
|
-
...common.onLog ? { onLog: common.onLog } : {}
|
|
5030
|
+
...common.onLog ? { onLog: common.onLog } : {},
|
|
5031
|
+
...typeof values["virtual-host"] === "string" ? {
|
|
5032
|
+
virtualHosts: values["virtual-host"].split(",").map((host) => host.trim()).filter(Boolean)
|
|
5033
|
+
} : {}
|
|
4901
5034
|
}),
|
|
4902
5035
|
banner: () => [
|
|
4903
|
-
"AWS SDK endpoint: set forcePathStyle=true
|
|
5036
|
+
"AWS SDK endpoint: set endpoint to this URL; forcePathStyle=true, or a client that addresses <bucket>.localhost",
|
|
4904
5037
|
"admin: POST /__admin/objects; GET /__admin/objects"
|
|
4905
5038
|
]
|
|
4906
5039
|
};
|
|
@@ -4912,4 +5045,4 @@ export {
|
|
|
4912
5045
|
createServer2 as createServer,
|
|
4913
5046
|
serveTarget
|
|
4914
5047
|
};
|
|
4915
|
-
//# sourceMappingURL=chunk-
|
|
5048
|
+
//# sourceMappingURL=chunk-2B5OVZSH.js.map
|