Implement list order

This commit is contained in:
Fang-Pen Lin
2025-11-04 11:19:06 -08:00
parent 82d03a1129
commit bf39f5eb17
2 changed files with 19 additions and 8 deletions

View File

@@ -60,9 +60,19 @@ export const pkiAcmeOrderDALFactory = (db: TDbClient) => {
}
};
const listByAccountId = async (accountId: string, tx?: Knex) => {
try {
const orders = await (tx || db)(TableName.PkiAcmeOrder).where({ accountId }).orderBy("createdAt", "desc");
return orders;
} catch (error) {
throw new DatabaseError({ error, name: "List PKI ACME orders by account id" });
}
};
return {
...pkiAcmeOrderOrm,
findByIdForFinalization,
findByAccountAndOrderIdWithAuthorizations
findByAccountAndOrderIdWithAuthorizations,
listByAccountId
};
};

View File

@@ -84,7 +84,12 @@ type TPkiAcmeServiceFactoryDep = {
>;
acmeOrderDAL: Pick<
TPkiAcmeOrderDALFactory,
"create" | "transaction" | "updateById" | "findByAccountAndOrderIdWithAuthorizations" | "findByIdForFinalization"
| "create"
| "transaction"
| "updateById"
| "findByAccountAndOrderIdWithAuthorizations"
| "findByIdForFinalization"
| "listByAccountId"
>;
acmeAuthDAL: Pick<TPkiAcmeAuthDALFactory, "create" | "findByAccountIdAndAuthIdWithChallenges">;
acmeOrderAuthDAL: Pick<TPkiAcmeOrderAuthDALFactory, "insertMany">;
@@ -727,15 +732,11 @@ export const pkiAcmeServiceFactory = ({
profileId: string;
accountId: string;
}): Promise<TAcmeResponse<TListAcmeOrdersResponse>> => {
const profile = await validateAcmeProfile(profileId);
// FIXME: Implement ACME list orders
const orders = await acmeOrderDAL.listByAccountId(accountId);
return {
status: 200,
body: {
orders: []
},
body: { orders: orders.map((order) => buildUrl(profileId, `/orders/${order.id}`)) },
headers: {
Location: buildUrl(profileId, `/accounts/${accountId}/orders`),
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
}
};