Implement events api routes
This commit is contained in:
@@ -6,7 +6,8 @@ import { Type as t } from "@sinclair/typebox";
|
||||
import { Value } from "@sinclair/typebox/value";
|
||||
import { sql } from "kysely";
|
||||
import zipcodesUs from "zipcodes-us";
|
||||
import { minToMs, secToMs } from "@blade-and-brawn/domain";
|
||||
import { secToMs } from "@blade-and-brawn/domain";
|
||||
import { EventsService } from "./events";
|
||||
|
||||
export class CommerceService {
|
||||
readonly Printful = new PrintfulClient({
|
||||
@@ -39,9 +40,9 @@ class ApparelOrdersService {
|
||||
group: "apparel_order",
|
||||
cfg: {
|
||||
error: { limit: 3, initialRetryDelayMs: secToMs(1) },
|
||||
concurrency: { limit: 1, timeoutMs: minToMs(10) }
|
||||
concurrency: { limit: 1 }
|
||||
},
|
||||
events: {
|
||||
types: {
|
||||
"apparel_order_create": defineEventType({
|
||||
schemas: { payload: t.Object({ wOrder: t.Object({}) }), state: t.Null() },
|
||||
processor: async (payload) => {
|
||||
@@ -107,9 +108,9 @@ class ApparelSyncService {
|
||||
group: "apparel_sync",
|
||||
cfg: {
|
||||
error: { limit: 3, initialRetryDelayMs: secToMs(1) },
|
||||
concurrency: { limit: 1, timeoutMs: minToMs(10) }
|
||||
concurrency: { limit: 1 }
|
||||
},
|
||||
events: {
|
||||
types: {
|
||||
"apparel_sync_update": defineEventType({
|
||||
schemas: {
|
||||
payload: t.Object({
|
||||
@@ -164,11 +165,11 @@ class ApparelSyncService {
|
||||
.executeTakeFirst();
|
||||
if (!latestSync) return;
|
||||
|
||||
Value.Assert(this.Queue.events["apparel_sync_update"].schemas.state, latestSync.state);
|
||||
Value.Assert(this.Queue.types["apparel_sync_update"].schemas.state, latestSync.state);
|
||||
|
||||
return {
|
||||
startDate: latestSync.started_at,
|
||||
status: EventQueue.status(latestSync),
|
||||
status: EventsService.status(latestSync),
|
||||
syncingPProductIds: latestSync.state?.pProductIds ?? []
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user