two-stroke 1.1.7 → 3.0.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/package.json +1 -1
- package/src/index.ts +12 -10
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Toucan } from "toucan-js";
|
|
2
|
-
import { ZodObject, ZodSchema, z } from "zod";
|
|
3
|
-
import { verify as pbkdfVerify } from "pbkdf-subtle";
|
|
4
1
|
import { verify as jwkVerify } from "jwk-subtle";
|
|
5
|
-
import {
|
|
2
|
+
import { verify as pbkdfVerify } from "pbkdf-subtle";
|
|
3
|
+
import { Toucan } from "toucan-js";
|
|
4
|
+
import { SafeParseReturnType, ZodObject, ZodSchema, z } from "zod";
|
|
6
5
|
import { openAPI } from "./open-api";
|
|
6
|
+
import { Env, Handler, Route } from "./types";
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
9
9
|
const noAuth = async () => null;
|
|
@@ -292,18 +292,20 @@ export function twoStroke<T extends Env>(title: string, release: string) {
|
|
|
292
292
|
input: I,
|
|
293
293
|
handler: (c: {
|
|
294
294
|
env: T;
|
|
295
|
-
batch: MessageBatch<z.
|
|
295
|
+
batch: MessageBatch<z.input<I>>;
|
|
296
296
|
sentry: Toucan;
|
|
297
|
+
parsedBatch: SafeParseReturnType<z.input<I>, z.infer<I>>[];
|
|
297
298
|
}) => Promise<void>,
|
|
298
299
|
) {
|
|
299
300
|
_queue = async ({ batch, env, sentry }) => {
|
|
300
|
-
batch.messages.map((message)
|
|
301
|
-
const
|
|
302
|
-
if (!
|
|
303
|
-
console.error(
|
|
301
|
+
const parsedBatch = batch.messages.map((message) => {
|
|
302
|
+
const passed = input.safeParse(message.body);
|
|
303
|
+
if (!passed.success) {
|
|
304
|
+
console.error(passed.error, message);
|
|
304
305
|
}
|
|
306
|
+
return passed;
|
|
305
307
|
});
|
|
306
|
-
await handler({ batch, env, sentry });
|
|
308
|
+
await handler({ batch, env, sentry, parsedBatch });
|
|
307
309
|
console.log("Queue batch finished");
|
|
308
310
|
};
|
|
309
311
|
},
|