@dimah-s3/server 1.1.1 → 1.2.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/dist/api/create-s3-endpoint.d.ts +3 -1
- package/dist/api/create-s3-endpoint.d.ts.map +1 -1
- package/dist/api/index.js +9 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/routes/confirm.d.ts.map +1 -1
- package/dist/api/routes/delete.d.ts.map +1 -1
- package/dist/api/routes/download.d.ts.map +1 -1
- package/dist/api/routes/file.d.ts.map +1 -1
- package/dist/api/routes/multipart/abort.d.ts.map +1 -1
- package/dist/api/routes/multipart/complete.d.ts.map +1 -1
- package/dist/api/routes/multipart/init.d.ts.map +1 -1
- package/dist/api/routes/multipart/list-parts.d.ts.map +1 -1
- package/dist/api/routes/multipart/part.d.ts.map +1 -1
- package/dist/api/routes/upload.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins.js +9 -0
- package/dist/plugins.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { S3_API_ROUTES, isAPIError, DimahS3Error, S3_ERROR_CODES, confirmBodySch
|
|
|
2
2
|
export { DimahS3Error, S3_ERROR_CODES, isAPIError, isDimahS3Error, isS3ErrorCode } from '@dimah-s3/core';
|
|
3
3
|
import { PutObjectCommand, DeleteObjectCommand, GetObjectCommand, CreateMultipartUploadCommand, UploadPartCommand, ListPartsCommand, AbortMultipartUploadCommand, CompleteMultipartUploadCommand, HeadObjectCommand } from '@aws-sdk/client-s3';
|
|
4
4
|
import { createMiddleware, createEndpoint, createRouter, toResponse } from 'better-call';
|
|
5
|
+
import * as z from 'zod';
|
|
5
6
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
6
7
|
import { createPresignedPost } from '@aws-sdk/s3-presigned-post';
|
|
7
8
|
|
|
@@ -646,9 +647,17 @@ var createS3Middleware = createMiddleware.create({
|
|
|
646
647
|
var createEndpointWithContext = createEndpoint.create({
|
|
647
648
|
use: [s3ContextMiddleware]
|
|
648
649
|
});
|
|
650
|
+
function compileIfZod(schema) {
|
|
651
|
+
if (schema !== null && typeof schema === "object" && "_zod" in schema) {
|
|
652
|
+
return z.compile(schema);
|
|
653
|
+
}
|
|
654
|
+
return schema;
|
|
655
|
+
}
|
|
649
656
|
function withS3Validation(options) {
|
|
650
657
|
return {
|
|
651
658
|
...options,
|
|
659
|
+
...options.body !== void 0 ? { body: compileIfZod(options.body) } : {},
|
|
660
|
+
...options.query !== void 0 ? { query: compileIfZod(options.query) } : {},
|
|
652
661
|
onValidationError: options.onValidationError ?? (({ message }) => {
|
|
653
662
|
throw errors.validationError(message);
|
|
654
663
|
})
|