secure-upload-fastify-sdk 1.0.1 → 1.0.2
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 +139 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.js +7 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +7 -4
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/routes/smart.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1570,9 +1570,11 @@ var FileInitItemSchema = z2.object({
|
|
|
1570
1570
|
expectedHash: z2.string().regex(/^[a-f0-9]{64}$/i).optional(),
|
|
1571
1571
|
meta: z2.record(z2.unknown()).optional()
|
|
1572
1572
|
}).strict();
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1573
|
+
function makeSmartInitBodySchema(maxFiles) {
|
|
1574
|
+
return z2.object({
|
|
1575
|
+
files: z2.array(FileInitItemSchema).min(1).max(maxFiles)
|
|
1576
|
+
}).strict();
|
|
1577
|
+
}
|
|
1576
1578
|
async function processOneFile(req, rt, file, index) {
|
|
1577
1579
|
try {
|
|
1578
1580
|
const { userId } = await resolveSession(req, file.isPublic, rt.validateSession);
|
|
@@ -1686,7 +1688,8 @@ async function registerSmartRoutes(app, rt) {
|
|
|
1686
1688
|
"\u{1F527} smart-routes: \u6CE8\u518C smart \u4E0A\u4F20\u8DEF\u7531(part/complete/abort/status \u590D\u7528 multipart/*)..."
|
|
1687
1689
|
);
|
|
1688
1690
|
app.post(`${base}/init`, async (req) => {
|
|
1689
|
-
const
|
|
1691
|
+
const schema = makeSmartInitBodySchema(rt.config.smartMaxFiles);
|
|
1692
|
+
const body = schema.parse(req.body ?? {});
|
|
1690
1693
|
if (body.files.length > rt.config.smartMaxFiles) {
|
|
1691
1694
|
throw new SecureError(
|
|
1692
1695
|
1511 /* BATCH_TOO_MANY_FILES */,
|