diff --git a/scripts/src/models/offers.ts b/scripts/src/models/offers.ts index 355e0594..f45f1ace 100644 --- a/scripts/src/models/offers.ts +++ b/scripts/src/models/offers.ts @@ -105,7 +105,7 @@ export class Asset extends CreationDateModel { public offerId!: string; @Column({ name: "owner_id", nullable: true }) - public ownerId!: string | null; // User.id + public ownerId?: string; // User.id @Column("simple-json") public value!: AssetValue; diff --git a/scripts/src/models/orders.ts b/scripts/src/models/orders.ts index af7c9297..eac9b49d 100644 --- a/scripts/src/models/orders.ts +++ b/scripts/src/models/orders.ts @@ -26,7 +26,7 @@ export class Order extends CreationDateModel { public type!: OfferType; @Column("simple-json", { name: "blockchain_data", nullable: true }) - public blockchainData!: BlockchainData; + public blockchainData?: BlockchainData; @Column({ name: "user_id" }) public userId!: string; @@ -38,10 +38,10 @@ export class Order extends CreationDateModel { public meta!: OrderMeta; @Column("simple-json", { nullable: true }) // the asset or JWT payment confirmation - public value: OrderValue | undefined; + public value?: OrderValue; @Column("simple-json", { nullable: true }) - public error: OrderError | undefined; + public error?: OrderError; @Column() public amount!: number; @@ -50,7 +50,7 @@ export class Order extends CreationDateModel { public status!: OrderStatus; @Column({ name: "completion_date", nullable: true }) - public completionDate!: Date; + public completionDate?: Date; } export type OpenOrder = { diff --git a/scripts/src/models/users.ts b/scripts/src/models/users.ts index af4e8734..cd5a3cf8 100644 --- a/scripts/src/models/users.ts +++ b/scripts/src/models/users.ts @@ -18,7 +18,7 @@ export class User extends CreationDateModel { public walletAddress!: string; @Column({ name: "activated_date", nullable: true }) - public activatedDate!: Date; + public activatedDate?: Date; public get activated(): boolean { return !!this.activatedDate; diff --git a/scripts/src/public/routes/index.ts b/scripts/src/public/routes/index.ts index 30e809c7..d343cc77 100644 --- a/scripts/src/public/routes/index.ts +++ b/scripts/src/public/routes/index.ts @@ -51,7 +51,7 @@ function router(): ExtendedRouter { const token = await authenticate(req); const user = await db.User.findOneById(token.userId); // XXX scopes should be per token and should not consider user data - if (scopes.includes(AuthScopes.TOS) && (!user || !user.activated || token.createdDate < user.activatedDate)) { + if (scopes.includes(AuthScopes.TOS) && (!user || !user.activated || token.createdDate < user.activatedDate!)) { throw Error("user did not approve TOS or using a pre activated token"); } req.context = { user, token }; diff --git a/scripts/src/public/services/orders.ts b/scripts/src/public/services/orders.ts index ff1fd45d..624d6a18 100644 --- a/scripts/src/public/services/orders.ts +++ b/scripts/src/public/services/orders.ts @@ -56,7 +56,7 @@ function orderDbToApi(order: db.Order, logger: LoggerInstance): Order { result: order.value, error: order.error, completion_date: (order.completionDate || order.createdDate).toISOString(), // XXX should we separate the dates? - blockchain_data: order.blockchainData, + blockchain_data: order.blockchainData!, offer_type: order.type, title: order.meta.title, description: order.meta.description,