feat: Typescript for API layer (#817)
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> Co-authored-by: Zakaria El Asri <33696020+zakariaelas@users.noreply.github.com> Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com> Co-authored-by: Sebastian Rindom <seb@medusa-commerce.com>
This commit is contained in:
co-authored by
Philip Korsholm
Zakaria El Asri
Kasper Fabricius Kristensen
Philip Korsholm
Sebastian Rindom
parent
55e200bf68
commit
373532ecbc
@@ -1,23 +1,22 @@
|
||||
import {
|
||||
Entity,
|
||||
Generated,
|
||||
BeforeInsert,
|
||||
Index,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
Entity,
|
||||
Generated,
|
||||
Index,
|
||||
JoinColumn,
|
||||
OneToOne,
|
||||
PrimaryColumn,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import {
|
||||
resolveDbType,
|
||||
resolveDbGenerationStrategy,
|
||||
DbAwareColumn,
|
||||
resolveDbGenerationStrategy,
|
||||
resolveDbType,
|
||||
} from "../utils/db-aware-column"
|
||||
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
||||
|
||||
import { Cart } from "./cart"
|
||||
import { Order } from "./order"
|
||||
|
||||
@@ -77,14 +76,18 @@ export class DraftOrder {
|
||||
idempotency_key: string
|
||||
|
||||
@BeforeInsert()
|
||||
private async beforeInsert() {
|
||||
private async beforeInsert(): Promise<void> {
|
||||
if (!this.id) {
|
||||
const id = ulid()
|
||||
this.id = `dorder_${id}`
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === "development" && !this.display_id) {
|
||||
this.display_id = await manualAutoIncrement("draft_order")
|
||||
const disId = await manualAutoIncrement("draft_order")
|
||||
|
||||
if (disId) {
|
||||
this.display_id = disId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user