@dimah-s3/server 0.1.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/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/adapters/next.d.ts +18 -0
- package/dist/adapters/next.d.ts.map +1 -0
- package/dist/adapters/next.js +12 -0
- package/dist/adapters/next.js.map +1 -0
- package/dist/adapters/node.d.ts +16 -0
- package/dist/adapters/node.d.ts.map +1 -0
- package/dist/adapters/node.js +116 -0
- package/dist/adapters/node.js.map +1 -0
- package/dist/api.d.ts +5 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/dimah-s3.d.ts +36 -0
- package/dist/dimah-s3.d.ts.map +1 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/handler.d.ts +5 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/is-aws-not-found.d.ts +3 -0
- package/dist/helpers/is-aws-not-found.d.ts.map +1 -0
- package/dist/helpers/is-aws-not-found.test.d.ts +2 -0
- package/dist/helpers/is-aws-not-found.test.d.ts.map +1 -0
- package/dist/helpers/resolve-object-acl.d.ts +10 -0
- package/dist/helpers/resolve-object-acl.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1047 -0
- package/dist/index.js.map +1 -0
- package/dist/internal-helpers.d.ts +23 -0
- package/dist/internal-helpers.d.ts.map +1 -0
- package/dist/internal-helpers.test.d.ts +2 -0
- package/dist/internal-helpers.test.d.ts.map +1 -0
- package/dist/plugin/apply-plugins.d.ts +11 -0
- package/dist/plugin/apply-plugins.d.ts.map +1 -0
- package/dist/plugin/apply-plugins.test.d.ts +2 -0
- package/dist/plugin/apply-plugins.test.d.ts.map +1 -0
- package/dist/plugin/chain-hooks.d.ts +18 -0
- package/dist/plugin/chain-hooks.d.ts.map +1 -0
- package/dist/plugin/create-endpoint.d.ts +20 -0
- package/dist/plugin/create-endpoint.d.ts.map +1 -0
- package/dist/plugin/define-plugin.d.ts +17 -0
- package/dist/plugin/define-plugin.d.ts.map +1 -0
- package/dist/plugin/hook-registry.d.ts +12 -0
- package/dist/plugin/hook-registry.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +8 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +101 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/procedures/confirm.d.ts +8 -0
- package/dist/procedures/confirm.d.ts.map +1 -0
- package/dist/procedures/delete.d.ts +8 -0
- package/dist/procedures/delete.d.ts.map +1 -0
- package/dist/procedures/download.d.ts +10 -0
- package/dist/procedures/download.d.ts.map +1 -0
- package/dist/procedures/multipart/abort.d.ts +13 -0
- package/dist/procedures/multipart/abort.d.ts.map +1 -0
- package/dist/procedures/multipart/complete.d.ts +12 -0
- package/dist/procedures/multipart/complete.d.ts.map +1 -0
- package/dist/procedures/multipart/init.d.ts +13 -0
- package/dist/procedures/multipart/init.d.ts.map +1 -0
- package/dist/procedures/multipart/list-parts.d.ts +9 -0
- package/dist/procedures/multipart/list-parts.d.ts.map +1 -0
- package/dist/procedures/multipart/part.d.ts +12 -0
- package/dist/procedures/multipart/part.d.ts.map +1 -0
- package/dist/procedures/registry.d.ts +78 -0
- package/dist/procedures/registry.d.ts.map +1 -0
- package/dist/procedures/upload.d.ts +14 -0
- package/dist/procedures/upload.d.ts.map +1 -0
- package/dist/types/config.d.ts +87 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/hook-contexts.d.ts +147 -0
- package/dist/types/hook-contexts.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hamidreza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @dimah-s3/server
|
|
2
|
+
|
|
3
|
+
Presigned S3 handlers with HTTP `handler`, direct `api`, and an optional `plugins` array.
|
|
4
|
+
|
|
5
|
+
Full documentation: [dimah-s3.dev](https://dimah-s3.dev/docs/server)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @dimah-s3/server @aws-sdk/client-s3
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Minimal setup
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { dimahS3 } from "@dimah-s3/server";
|
|
17
|
+
import { s3Client, defaultBucket } from "@/lib/s3-client";
|
|
18
|
+
|
|
19
|
+
export const s3 = dimahS3({
|
|
20
|
+
s3: s3Client,
|
|
21
|
+
defaultBucket,
|
|
22
|
+
upload: { enabled: true },
|
|
23
|
+
download: { enabled: false },
|
|
24
|
+
delete: { enabled: false },
|
|
25
|
+
multipart: { enabled: false },
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { toNextJsHandler } from "@dimah-s3/server/next";
|
|
31
|
+
import { s3 } from "@/lib/s3";
|
|
32
|
+
|
|
33
|
+
export const { GET, POST, DELETE } = toNextJsHandler(s3);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Server-side (no HTTP):
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
await s3.api.download(key, { headers: await headers() });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Optional persistence: add `db()` from [`@dimah-s3/db`](../db) to `plugins`.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DimahS3 } from "../dimah-s3";
|
|
2
|
+
/**
|
|
3
|
+
* Adapt a {@link DimahS3} instance to Next.js App Router route handlers.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { toNextJsHandler } from "@dimah-s3/server/next";
|
|
8
|
+
* import { s3 } from "@/lib/s3";
|
|
9
|
+
*
|
|
10
|
+
* export const { GET, POST, DELETE } = toNextJsHandler(s3);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function toNextJsHandler(s3: Pick<DimahS3<Record<string, unknown>>, "handler">): {
|
|
14
|
+
GET: (request: Request) => Promise<Response>;
|
|
15
|
+
POST: (request: Request) => Promise<Response>;
|
|
16
|
+
DELETE: (request: Request) => Promise<Response>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC;IAGnD,GAAG;IACH,IAAI;IACJ,MAAM;EAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/next.ts"],"names":[],"mappings":";AAaO,SAAS,gBACd,EAAA,EACA;AACA,EAAA,OAAO;AAAA,IACL,KAAK,EAAA,CAAG,OAAA;AAAA,IACR,MAAM,EAAA,CAAG,OAAA;AAAA,IACT,QAAQ,EAAA,CAAG;AAAA,GACb;AACF","file":"next.js","sourcesContent":["import type { DimahS3 } from \"../dimah-s3\";\n\n/**\n * Adapt a {@link DimahS3} instance to Next.js App Router route handlers.\n *\n * @example\n * ```ts\n * import { toNextJsHandler } from \"@dimah-s3/server/next\";\n * import { s3 } from \"@/lib/s3\";\n *\n * export const { GET, POST, DELETE } = toNextJsHandler(s3);\n * ```\n */\nexport function toNextJsHandler(\n s3: Pick<DimahS3<Record<string, unknown>>, \"handler\">,\n) {\n return {\n GET: s3.handler,\n POST: s3.handler,\n DELETE: s3.handler,\n };\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { DimahS3 } from "../dimah-s3";
|
|
3
|
+
/**
|
|
4
|
+
* Adapt a {@link DimahS3} instance to Node.js `http` / Express-style handlers.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createServer } from "node:http";
|
|
9
|
+
* import { toNodeHandler } from "@dimah-s3/server/node";
|
|
10
|
+
* import { s3 } from "./s3";
|
|
11
|
+
*
|
|
12
|
+
* createServer(toNodeHandler(s3)).listen(3000);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function toNodeHandler(s3: Pick<DimahS3<Record<string, unknown>>, "handler">): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
16
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/adapters/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAuD3C;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,SAElC,eAAe,OAAO,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC,CAqBxE"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { DimahS3Error, S3_ERROR_CODES } from '@dimah-s3/core';
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var errors = {
|
|
5
|
+
notFound: () => new DimahS3Error("Not Found", 404, { code: S3_ERROR_CODES.NOT_FOUND }),
|
|
6
|
+
invalidJson: () => new DimahS3Error("Invalid JSON payload", 400, {
|
|
7
|
+
code: S3_ERROR_CODES.INVALID_JSON
|
|
8
|
+
}),
|
|
9
|
+
forbidden: () => new DimahS3Error("Forbidden", 403, { code: S3_ERROR_CODES.FORBIDDEN }),
|
|
10
|
+
internalError: () => new DimahS3Error("Internal server error", 500, {
|
|
11
|
+
code: S3_ERROR_CODES.INTERNAL_ERROR
|
|
12
|
+
}),
|
|
13
|
+
objectNotFound: () => new DimahS3Error("Object not found", 404, {
|
|
14
|
+
code: S3_ERROR_CODES.OBJECT_NOT_FOUND
|
|
15
|
+
}),
|
|
16
|
+
s3NetworkError: (code) => new DimahS3Error(
|
|
17
|
+
`S3 endpoint unreachable (${code}): check your endpoint URL and network connectivity`,
|
|
18
|
+
502,
|
|
19
|
+
{ code: S3_ERROR_CODES.S3_NETWORK_ERROR, params: { code } }
|
|
20
|
+
),
|
|
21
|
+
fieldRequired: (name) => new DimahS3Error(`${name} is required`, 400, {
|
|
22
|
+
code: S3_ERROR_CODES.FIELD_REQUIRED,
|
|
23
|
+
params: { name }
|
|
24
|
+
}),
|
|
25
|
+
/** Missing `key` on query-string routes (download / delete / list-parts). */
|
|
26
|
+
keyRequired: () => new DimahS3Error("key query parameter is required", 400, {
|
|
27
|
+
code: S3_ERROR_CODES.KEY_REQUIRED
|
|
28
|
+
}),
|
|
29
|
+
uploadIdRequired: () => new DimahS3Error("uploadId is required", 400, {
|
|
30
|
+
code: S3_ERROR_CODES.UPLOAD_ID_REQUIRED
|
|
31
|
+
}),
|
|
32
|
+
partNumberInvalid: () => new DimahS3Error("partNumber must be a positive integer", 400, {
|
|
33
|
+
code: S3_ERROR_CODES.PART_NUMBER_INVALID
|
|
34
|
+
}),
|
|
35
|
+
partsRequired: () => new DimahS3Error("At least one valid part is required", 400, {
|
|
36
|
+
code: S3_ERROR_CODES.PARTS_REQUIRED
|
|
37
|
+
}),
|
|
38
|
+
fileSizeRequiredUpload: () => new DimahS3Error(
|
|
39
|
+
"fileSize is required when upload.requireFileSize is enabled",
|
|
40
|
+
400,
|
|
41
|
+
{ code: S3_ERROR_CODES.FILE_SIZE_REQUIRED_UPLOAD }
|
|
42
|
+
),
|
|
43
|
+
fileSizeRequiredMultipart: () => new DimahS3Error(
|
|
44
|
+
"fileSize is required when multipart.requireFileSize is enabled",
|
|
45
|
+
400,
|
|
46
|
+
{ code: S3_ERROR_CODES.FILE_SIZE_REQUIRED_MULTIPART }
|
|
47
|
+
)
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/adapters/node.ts
|
|
51
|
+
function collectBody(req) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const chunks = [];
|
|
54
|
+
req.on("data", (chunk) => {
|
|
55
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
56
|
+
});
|
|
57
|
+
req.on("end", () => resolve(Buffer.concat(chunks)));
|
|
58
|
+
req.on("error", reject);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function toWebRequest(req, body) {
|
|
62
|
+
const host = req.headers.host ?? "localhost";
|
|
63
|
+
const protocol = req.socket.encrypted === true ? "https" : "http";
|
|
64
|
+
const url = new URL(req.url ?? "/", `${protocol}://${host}`);
|
|
65
|
+
const headers = new Headers();
|
|
66
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
67
|
+
if (value == null) continue;
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
for (const v of value) headers.append(key, v);
|
|
70
|
+
} else {
|
|
71
|
+
headers.set(key, value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const method = (req.method ?? "GET").toUpperCase();
|
|
75
|
+
const init = { method, headers };
|
|
76
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
77
|
+
init.body = new Uint8Array(body);
|
|
78
|
+
init.duplex = "half";
|
|
79
|
+
}
|
|
80
|
+
return new Request(url, init);
|
|
81
|
+
}
|
|
82
|
+
async function writeWebResponse(res, response) {
|
|
83
|
+
res.statusCode = response.status;
|
|
84
|
+
response.headers.forEach((value, key) => {
|
|
85
|
+
res.setHeader(key, value);
|
|
86
|
+
});
|
|
87
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
88
|
+
res.end(buffer);
|
|
89
|
+
}
|
|
90
|
+
function toNodeHandler(s3) {
|
|
91
|
+
return async (req, res) => {
|
|
92
|
+
try {
|
|
93
|
+
const body = await collectBody(req);
|
|
94
|
+
const request = toWebRequest(req, body);
|
|
95
|
+
const response = await s3.handler(request);
|
|
96
|
+
await writeWebResponse(res, response);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
console.error("[S3 API]", err);
|
|
99
|
+
if (!res.headersSent) {
|
|
100
|
+
const fallback = errors.internalError();
|
|
101
|
+
res.statusCode = fallback.status;
|
|
102
|
+
res.setHeader("Content-Type", "application/json");
|
|
103
|
+
res.end(
|
|
104
|
+
JSON.stringify({
|
|
105
|
+
message: fallback.message,
|
|
106
|
+
code: fallback.code
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { toNodeHandler };
|
|
115
|
+
//# sourceMappingURL=node.js.map
|
|
116
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors.ts","../../src/adapters/node.ts"],"names":[],"mappings":";;;AAKO,IAAM,MAAA,GAAS;AAAA,EACpB,QAAA,EAAU,MACR,IAAI,YAAA,CAAa,WAAA,EAAa,KAAK,EAAE,IAAA,EAAM,cAAA,CAAe,SAAA,EAAW,CAAA;AAAA,EAEvE,WAAA,EAAa,MACX,IAAI,YAAA,CAAa,wBAAwB,GAAA,EAAK;AAAA,IAC5C,MAAM,cAAA,CAAe;AAAA,GACtB,CAAA;AAAA,EAEH,SAAA,EAAW,MACT,IAAI,YAAA,CAAa,WAAA,EAAa,KAAK,EAAE,IAAA,EAAM,cAAA,CAAe,SAAA,EAAW,CAAA;AAAA,EAEvE,aAAA,EAAe,MACb,IAAI,YAAA,CAAa,yBAAyB,GAAA,EAAK;AAAA,IAC7C,MAAM,cAAA,CAAe;AAAA,GACtB,CAAA;AAAA,EAEH,cAAA,EAAgB,MACd,IAAI,YAAA,CAAa,oBAAoB,GAAA,EAAK;AAAA,IACxC,MAAM,cAAA,CAAe;AAAA,GACtB,CAAA;AAAA,EAEH,cAAA,EAAgB,CAAC,IAAA,KACf,IAAI,YAAA;AAAA,IACF,4BAA4B,IAAI,CAAA,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AAA,CAAI,aAAa,QAAA,CAAS,MAAA;AAC1B,QAAA,GAAA,CAAI,SAAA,CAAU,gBAAgB,kBAAkB,CAAA;AAChD,QAAA,GAAA,CAAI,GAAA;AAAA,UACF,KAAK,SAAA,CAAU;AAAA,YACb,SAAS,QAAA,CAAS,OAAA;AAAA,YAClB,MAAM,QAAA,CAAS;AAAA,WAChB;AAAA,SACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAA;AACF","file":"node.js","sourcesContent":["import { DimahS3Error, S3_ERROR_CODES, type S3ErrorCode } from \"@dimah-s3/core\";\n\nexport { DimahS3Error };\n\n/** English API errors with stable codes for client-side localization. */\nexport const errors = {\n notFound: () =>\n new DimahS3Error(\"Not Found\", 404, { code: S3_ERROR_CODES.NOT_FOUND }),\n\n invalidJson: () =>\n new DimahS3Error(\"Invalid JSON payload\", 400, {\n code: S3_ERROR_CODES.INVALID_JSON,\n }),\n\n forbidden: () =>\n new DimahS3Error(\"Forbidden\", 403, { code: S3_ERROR_CODES.FORBIDDEN }),\n\n internalError: () =>\n new DimahS3Error(\"Internal server error\", 500, {\n code: S3_ERROR_CODES.INTERNAL_ERROR,\n }),\n\n objectNotFound: () =>\n new DimahS3Error(\"Object not found\", 404, {\n code: S3_ERROR_CODES.OBJECT_NOT_FOUND,\n }),\n\n s3NetworkError: (code: string) =>\n new DimahS3Error(\n `S3 endpoint unreachable (${code}): check your endpoint URL and network connectivity`,\n 502,\n { code: S3_ERROR_CODES.S3_NETWORK_ERROR, params: { code } },\n ),\n\n fieldRequired: (name: string) =>\n new DimahS3Error(`${name} is required`, 400, {\n code: S3_ERROR_CODES.FIELD_REQUIRED,\n params: { name },\n }),\n\n /** Missing `key` on query-string routes (download / delete / list-parts). */\n keyRequired: () =>\n new DimahS3Error(\"key query parameter is required\", 400, {\n code: S3_ERROR_CODES.KEY_REQUIRED,\n }),\n\n uploadIdRequired: () =>\n new DimahS3Error(\"uploadId is required\", 400, {\n code: S3_ERROR_CODES.UPLOAD_ID_REQUIRED,\n }),\n\n partNumberInvalid: () =>\n new DimahS3Error(\"partNumber must be a positive integer\", 400, {\n code: S3_ERROR_CODES.PART_NUMBER_INVALID,\n }),\n\n partsRequired: () =>\n new DimahS3Error(\"At least one valid part is required\", 400, {\n code: S3_ERROR_CODES.PARTS_REQUIRED,\n }),\n\n fileSizeRequiredUpload: () =>\n new DimahS3Error(\n \"fileSize is required when upload.requireFileSize is enabled\",\n 400,\n { code: S3_ERROR_CODES.FILE_SIZE_REQUIRED_UPLOAD },\n ),\n\n fileSizeRequiredMultipart: () =>\n new DimahS3Error(\n \"fileSize is required when multipart.requireFileSize is enabled\",\n 400,\n { code: S3_ERROR_CODES.FILE_SIZE_REQUIRED_MULTIPART },\n ),\n} as const;\n\nexport type ServerErrors = typeof errors;\n\n/** Trim and require a non-empty string; throws {@link errors.fieldRequired}. */\nexport function requireString(value: unknown, name: string): string {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\";\n if (!trimmed) throw errors.fieldRequired(name);\n return trimmed;\n}\n\nfunction statusOf(err: unknown, fallback: number): number {\n return typeof (err as { status?: unknown })?.status === \"number\"\n ? (err as { status: number }).status\n : fallback;\n}\n\n/**\n * Convert hook/S3 throws into {@link DimahS3Error}.\n *\n * - Existing {@link DimahS3Error} instances are preserved (including subclasses).\n * - Plain `Error`s keep their message; `code` is only applied when provided\n * (omit it so clients show the custom English message instead of a mapped\n * library string).\n */\nexport function toDimahS3Error(\n err: unknown,\n fallbackMessage: string,\n fallbackStatus = 403,\n options?: { code?: S3ErrorCode | string },\n): DimahS3Error {\n if (err instanceof DimahS3Error) return err;\n\n const message =\n err instanceof Error && err.message.trim() ? err.message : fallbackMessage;\n const status = statusOf(err, fallbackStatus);\n\n return new DimahS3Error(message, status, {\n cause: err instanceof Error ? err : undefined,\n ...(options?.code !== undefined ? { code: options.code } : {}),\n });\n}\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { DimahS3 } from \"../dimah-s3\";\nimport { errors } from \"../errors\";\n\nfunction collectBody(req: IncomingMessage): Promise<Buffer> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n req.on(\"data\", (chunk: Buffer | string) => {\n chunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n });\n req.on(\"end\", () => resolve(Buffer.concat(chunks)));\n req.on(\"error\", reject);\n });\n}\n\nfunction toWebRequest(req: IncomingMessage, body: Buffer): Request {\n const host = req.headers.host ?? \"localhost\";\n const protocol =\n (req.socket as { encrypted?: boolean }).encrypted === true\n ? \"https\"\n : \"http\";\n const url = new URL(req.url ?? \"/\", `${protocol}://${host}`);\n\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (value == null) continue;\n if (Array.isArray(value)) {\n for (const v of value) headers.append(key, v);\n } else {\n headers.set(key, value);\n }\n }\n\n const method = (req.method ?? \"GET\").toUpperCase();\n const init: RequestInit = { method, headers };\n if (method !== \"GET\" && method !== \"HEAD\") {\n init.body = new Uint8Array(body);\n // @ts-expect-error Node fetch duplex for streaming bodies\n init.duplex = \"half\";\n }\n\n return new Request(url, init);\n}\n\nasync function writeWebResponse(\n res: ServerResponse,\n response: Response,\n): Promise<void> {\n res.statusCode = response.status;\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n const buffer = Buffer.from(await response.arrayBuffer());\n res.end(buffer);\n}\n\n/**\n * Adapt a {@link DimahS3} instance to Node.js `http` / Express-style handlers.\n *\n * @example\n * ```ts\n * import { createServer } from \"node:http\";\n * import { toNodeHandler } from \"@dimah-s3/server/node\";\n * import { s3 } from \"./s3\";\n *\n * createServer(toNodeHandler(s3)).listen(3000);\n * ```\n */\nexport function toNodeHandler(\n s3: Pick<DimahS3<Record<string, unknown>>, \"handler\">,\n) {\n return async (req: IncomingMessage, res: ServerResponse): Promise<void> => {\n try {\n const body = await collectBody(req);\n const request = toWebRequest(req, body);\n const response = await s3.handler(request);\n await writeWebResponse(res, response);\n } catch (err) {\n console.error(\"[S3 API]\", err);\n if (!res.headersSent) {\n const fallback = errors.internalError();\n res.statusCode = fallback.status;\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(\n JSON.stringify({\n message: fallback.message,\n code: fallback.code,\n }),\n );\n }\n }\n };\n}\n"]}
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { S3Api } from "@dimah-s3/core";
|
|
2
|
+
import type { DimahS3Config } from "./types";
|
|
3
|
+
/** Direct `S3Api` backed by the same procedures as the HTTP handler. */
|
|
4
|
+
export declare function createServerApi(config: DimahS3Config): S3Api;
|
|
5
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAkB7C,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK,CAqF5D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { S3Api } from "@dimah-s3/core";
|
|
2
|
+
import { type DimahS3Plugin, type PluginContextMap } from "./plugin";
|
|
3
|
+
import type { DimahS3Config } from "./types";
|
|
4
|
+
export type DimahS3<C extends Record<string, unknown> = Record<string, unknown>> = {
|
|
5
|
+
/** Framework-agnostic HTTP handler (`Request` → `Response`). */
|
|
6
|
+
handler: (request: Request) => Promise<Response>;
|
|
7
|
+
/** Same `S3Api` as the browser client — call from Server Actions / RSC without HTTP. */
|
|
8
|
+
api: S3Api;
|
|
9
|
+
/** Plugin contexts keyed by plugin id. */
|
|
10
|
+
context: C;
|
|
11
|
+
/** Lookup a registered plugin by id. */
|
|
12
|
+
getPlugin: (id: string) => DimahS3Plugin | undefined;
|
|
13
|
+
} & C;
|
|
14
|
+
/**
|
|
15
|
+
* Create a dimah-s3 server instance.
|
|
16
|
+
*
|
|
17
|
+
* Plugin contexts are available on `s3.context[id]` and flattened onto the
|
|
18
|
+
* instance itself (`s3.db` when the `db` plugin is registered, etc.).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* export const s3 = dimahS3({
|
|
23
|
+
* s3: s3Client,
|
|
24
|
+
* defaultBucket: "my-bucket",
|
|
25
|
+
* upload: { enabled: true },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* export const { GET, POST, DELETE } = toNextJsHandler(s3);
|
|
29
|
+
*
|
|
30
|
+
* await s3.api.download(key, { headers: await headers() });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function dimahS3<const P extends readonly DimahS3Plugin[] = []>(config: DimahS3Config & {
|
|
34
|
+
plugins?: P;
|
|
35
|
+
}): DimahS3<PluginContextMap<P>>;
|
|
36
|
+
//# sourceMappingURL=dimah-s3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimah-s3.d.ts","sourceRoot":"","sources":["../src/dimah-s3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,OAAO,CACjB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACzD;IACF,gEAAgE;IAChE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,wFAAwF;IACxF,GAAG,EAAE,KAAK,CAAC;IACX,0CAA0C;IAC1C,OAAO,EAAE,CAAC,CAAC;IACX,wCAAwC;IACxC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;CACtD,GAAG,CAAC,CAAC;AAEN;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EACnE,MAAM,EAAE,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,GACtC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAgB9B"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DimahS3Error, type S3ErrorCode } from "@dimah-s3/core";
|
|
2
|
+
export { DimahS3Error };
|
|
3
|
+
/** English API errors with stable codes for client-side localization. */
|
|
4
|
+
export declare const errors: {
|
|
5
|
+
readonly notFound: () => DimahS3Error;
|
|
6
|
+
readonly invalidJson: () => DimahS3Error;
|
|
7
|
+
readonly forbidden: () => DimahS3Error;
|
|
8
|
+
readonly internalError: () => DimahS3Error;
|
|
9
|
+
readonly objectNotFound: () => DimahS3Error;
|
|
10
|
+
readonly s3NetworkError: (code: string) => DimahS3Error;
|
|
11
|
+
readonly fieldRequired: (name: string) => DimahS3Error;
|
|
12
|
+
/** Missing `key` on query-string routes (download / delete / list-parts). */
|
|
13
|
+
readonly keyRequired: () => DimahS3Error;
|
|
14
|
+
readonly uploadIdRequired: () => DimahS3Error;
|
|
15
|
+
readonly partNumberInvalid: () => DimahS3Error;
|
|
16
|
+
readonly partsRequired: () => DimahS3Error;
|
|
17
|
+
readonly fileSizeRequiredUpload: () => DimahS3Error;
|
|
18
|
+
readonly fileSizeRequiredMultipart: () => DimahS3Error;
|
|
19
|
+
};
|
|
20
|
+
export type ServerErrors = typeof errors;
|
|
21
|
+
/** Trim and require a non-empty string; throws {@link errors.fieldRequired}. */
|
|
22
|
+
export declare function requireString(value: unknown, name: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Convert hook/S3 throws into {@link DimahS3Error}.
|
|
25
|
+
*
|
|
26
|
+
* - Existing {@link DimahS3Error} instances are preserved (including subclasses).
|
|
27
|
+
* - Plain `Error`s keep their message; `code` is only applied when provided
|
|
28
|
+
* (omit it so clients show the custom English message instead of a mapped
|
|
29
|
+
* library string).
|
|
30
|
+
*/
|
|
31
|
+
export declare function toDimahS3Error(err: unknown, fallbackMessage: string, fallbackStatus?: number, options?: {
|
|
32
|
+
code?: S3ErrorCode | string;
|
|
33
|
+
}): DimahS3Error;
|
|
34
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,yEAAyE;AACzE,eAAO,MAAM,MAAM;aACjB,QAAQ;aAGR,WAAW;aAKX,SAAS;aAGT,aAAa;aAKb,cAAc;aAKd,cAAc,SAAS,MAAM;aAO7B,aAAa,SAAS,MAAM;IAM5B,6EAA6E;aAC7E,WAAW;aAKX,gBAAgB;aAKhB,iBAAiB;aAKjB,aAAa;aAKb,sBAAsB;aAOtB,yBAAyB;CAMjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,OAAO,MAAM,CAAC;AAEzC,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlE;AAQD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,eAAe,EAAE,MAAM,EACvB,cAAc,SAAM,EACpB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;CAAE,GACxC,YAAY,CAWd"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ResolvedPluginEndpoint } from "./plugin/types";
|
|
2
|
+
import type { DimahS3Config } from "./types";
|
|
3
|
+
/** Framework-agnostic HTTP router (`Request` → `Response`). */
|
|
4
|
+
export declare function createHandler(config: DimahS3Config, basePath?: string, pluginEndpoints?: ResolvedPluginEndpoint[]): (request: Request) => Promise<Response>;
|
|
5
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAsE7C,+DAA+D;AAC/D,wBAAgB,aAAa,CAC3B,MAAM,EAAE,aAAa,EACrB,QAAQ,GAAE,MAAyB,EACnC,eAAe,GAAE,sBAAsB,EAAO,2CAyC/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-aws-not-found.d.ts","sourceRoot":"","sources":["../../src/helpers/is-aws-not-found.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAanD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-aws-not-found.test.d.ts","sourceRoot":"","sources":["../../src/helpers/is-aws-not-found.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type S3Client } from "@aws-sdk/client-s3";
|
|
2
|
+
/**
|
|
3
|
+
* Determines the ACL of an S3 object by querying `GetObjectAcl`.
|
|
4
|
+
*
|
|
5
|
+
* Returns `"public-read"` when the `AllUsers` grantee has `READ` or
|
|
6
|
+
* `FULL_CONTROL` permission, `"private"` when ACL is resolvable but not public,
|
|
7
|
+
* and `undefined` when ACL cannot be resolved (e.g. unsupported providers).
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveObjectAcl(s3: S3Client, bucket: string, key: string, timeoutMs?: number): Promise<"public-read" | "private" | undefined>;
|
|
10
|
+
//# sourceMappingURL=resolve-object-acl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-object-acl.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-object-acl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAIxE;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,MAAsC,GAChD,OAAO,CAAC,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC,CAoBhD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { dimahS3 } from "./dimah-s3";
|
|
2
|
+
export type { DimahS3 } from "./dimah-s3";
|
|
3
|
+
export { DimahS3Error, errors } from "./errors";
|
|
4
|
+
export type { ServerErrors } from "./errors";
|
|
5
|
+
export { resolveObjectAcl } from "./helpers/resolve-object-acl";
|
|
6
|
+
export { applyPlugins, chainHooks, createEndpoint, definePlugin, FEATURE_HOOK_KEYS, RESERVED_PLUGIN_IDS, } from "./plugin";
|
|
7
|
+
export type { AppliedPlugins, DimahS3Plugin, DimahS3PluginHooks, FeatureName, PluginContextMap, PluginEndpoint, PluginEndpointContext, PluginInitEnv, ReservedPluginId, ResolvedPluginEndpoint, } from "./plugin";
|
|
8
|
+
export type { DimahS3Config, UploadConfig, DownloadConfig, DeleteConfig, MultipartConfig, GuardContext, UploadPresignGuardContext, UploadOnPresignedContext, UploadConfirmGuardContext, UploadOnConfirmedContext, UploadOnUploadConfirmedContext, DownloadPresignGuardContext, DownloadOnPresignedContext, DeleteGuardContext, DeleteOnDeletedContext, MultipartUploadContext, MultipartInitGuardContext, MultipartGuardContext, MultipartPartGuardContext, MultipartCompleteGuardContext, MultipartAbortGuardContext, MultipartListGuardContext, MultipartOnInitContext, MultipartOnCompleteContext, MultipartOnAbortContext, MultipartOnListContext, } from "./types";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
|