Restructure services
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
export class CalculatorService {
|
||||
import { LevelCalculator, Standards, DEFAULT_STANDARDS_DATA } from "@blade-and-brawn/calculator";
|
||||
import type { ActivityPerformance, Player } from "@blade-and-brawn/domain";
|
||||
|
||||
export class CalculatorService {
|
||||
private readonly levelCalculator;
|
||||
|
||||
constructor() {
|
||||
this.levelCalculator = new LevelCalculator(
|
||||
new Standards(DEFAULT_STANDARDS_DATA),
|
||||
);
|
||||
}
|
||||
|
||||
calculate(player: Player, activityPerformances: ActivityPerformance[]) {
|
||||
return this.levelCalculator.calculate(player, activityPerformances)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PrintfulClient, ProductSyncer, WebflowClient, type ProductSyncerOptions } from "@blade-and-brawn/commerce";
|
||||
import { log } from "../util";
|
||||
import { env, log } from "../util";
|
||||
import { db } from "../database/db";
|
||||
import { DatabaseError } from "pg";
|
||||
import type { Insertable, Selectable } from "kysely";
|
||||
@@ -18,12 +18,24 @@ type QueuedSync = {
|
||||
|
||||
class AlreadyClaimedError extends Error { }
|
||||
|
||||
export class SyncService {
|
||||
export class CommerceService {
|
||||
public readonly printful: PrintfulClient;
|
||||
public readonly webflow: WebflowClient;
|
||||
private readonly productSyncer: ProductSyncer;
|
||||
readonly queue: SyncQueue;
|
||||
|
||||
constructor(printful: PrintfulClient, webflow: WebflowClient) {
|
||||
this.productSyncer = new ProductSyncer(printful, webflow, log);
|
||||
constructor() {
|
||||
this.printful = new PrintfulClient({
|
||||
token: env.PRINTFUL_AUTH,
|
||||
storeId: env.PRINTFUL_STORE_ID,
|
||||
});
|
||||
this.webflow = new WebflowClient({
|
||||
siteId: env.WEBFLOW_SITE_ID,
|
||||
collectionsId: env.WEBFLOW_COLLECTION_ID,
|
||||
token: env.WEBFLOW_AUTH,
|
||||
webhookSecret: env.WEBFLOW_WEBHOOK_SECRET,
|
||||
});
|
||||
this.productSyncer = new ProductSyncer(this.printful, this.webflow, log);
|
||||
this.queue = new SyncQueue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user