Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dull-candies-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly/server": patch
---

✨ add maturity check and worker
17 changes: 4 additions & 13 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"language": "en",
"import": [
"@cspell/dict-es-es/cspell-ext.json",
"@cspell/dict-pt-br/cspell-ext.json"
],
"import": ["@cspell/dict-es-es/cspell-ext.json", "@cspell/dict-pt-br/cspell-ext.json"],
"ignorePaths": [
"*.svg",
"*.local.yaml",
Expand Down Expand Up @@ -213,6 +210,7 @@
"refinancia",
"refinanciamiento",
"refinanciar",
"repágala",
"verifícate"
]
},
Expand Down Expand Up @@ -288,15 +286,8 @@
{
"filename": "**/i18n/**/pt.json",
"language": "en,pt",
"words": [
"autocustódia",
"criptomoedas"
]
"words": ["autocustódia", "criptomoedas"]
}
],
"ignoreRegExpList": [
"\\bitmpl_\\w+\\b",
"\\b(w|stat)?aBas\\w+\\b",
"\\baOpt\\w+\\b"
]
"ignoreRegExpList": ["\\bitmpl_\\w+\\b", "\\b(w|stat)?aBas\\w+\\b", "\\baOpt\\w+\\b"]
}
3 changes: 3 additions & 0 deletions server/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"Card purchase": "Compra con tarjeta",
"Credit mode activated": "Modo crédito activado",
"Credit mode is active": "El modo crédito está activo",
"Debt Maturity Alert": "Alerta de vencimiento de deuda",
Comment thread
aguxez marked this conversation as resolved.
"Deposited funds": "Fondos depositados",
"Exa Card purchase rejected": "Compra con Exa Card rechazada",
"Fiat onramp activated": "Cuenta fiat activada",
"Funds received": "Fondos recibidos",
"Refund processed": "Reembolso procesado",
"Transaction at {{merchantName}} for {{amount}} rejected: {{reason}}": "Transacción en {{merchantName}} por {{amount}} rechazada: {{reason}}",
"Withdraw completed": "Retiro completado",
"Your debt is due in 1 hour. Repay now to avoid liquidation.": "Tu deuda vence en 1 hora. Repágala ahora para evitar la liquidación.",
"Your debt is due in 24 hours. Repay now to avoid liquidation.": "Tu deuda vence en 24 horas. Repágala ahora para evitar la liquidación.",
"Your fiat onramp account has been activated": "Tu cuenta para depositar dinero fiat ha sido activada",
"frozen card": "tarjeta bloqueada",
"insufficient funds": "fondos insuficientes",
Expand Down
3 changes: 3 additions & 0 deletions server/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"Card purchase": "Compra no cartão",
"Credit mode activated": "Modo crédito ativado",
"Credit mode is active": "O modo crédito está ativo",
"Debt Maturity Alert": "Alerta de vencimento de dívida",
"Deposited funds": "Fundos depositados",
"Exa Card purchase rejected": "Compra com Exa Card recusada",
"Fiat onramp activated": "Conta fiat ativada",
"Funds received": "Fundos recebidos",
"Refund processed": "Reembolso processado",
"Transaction at {{merchantName}} for {{amount}} rejected: {{reason}}": "Transação em {{merchantName}} de {{amount}} recusada: {{reason}}",
"Withdraw completed": "Saque concluído",
"Your debt is due in 1 hour. Repay now to avoid liquidation.": "Sua dívida vence em 1 hora. Pague agora para evitar a liquidação.",
"Your debt is due in 24 hours. Repay now to avoid liquidation.": "Sua dívida vence em 24 horas. Pague agora para evitar a liquidação.",
"Your fiat onramp account has been activated": "Sua conta para depositar dinheiro fiat foi ativada",
"frozen card": "cartão bloqueado",
"insufficient funds": "fundos insuficientes",
Expand Down
29 changes: 19 additions & 10 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import panda from "./hooks/panda";
import persona from "./hooks/persona";
import androidFingerprints from "./utils/android/fingerprints";
import appOrigin from "./utils/appOrigin";
import { closeQueue as closeMaturityQueue, scheduleMaturityChecks } from "./utils/maturity";
import { close as closeRedis } from "./utils/redis";
import { closeAndFlush as closeSegment } from "./utils/segment";

Expand Down Expand Up @@ -320,20 +321,28 @@ export default app;
const server = serve(app);

export async function close() {
return new Promise((resolve, reject) => {
server.close((error) => {
Promise.allSettled([closeSentry(), closeRedis(), closeSegment(), database.$client.end()])
.then((results) => {
if (error) reject(error);
else if (results.some((result) => result.status === "rejected")) reject(new Error("closing services failed"));
else resolve(null);
})
.catch(reject);
});
const serverError = await new Promise<Error | undefined>((resolve) => {
server.close((error) => resolve(error));
});
const results = await Promise.allSettled([
closeSentry(),
closeSegment(),
database.$client.end(),
closeMaturityQueue(),
closeRedis(),
Comment thread
aguxez marked this conversation as resolved.
]);
Comment thread
aguxez marked this conversation as resolved.
Comment thread
aguxez marked this conversation as resolved.
Comment thread
aguxez marked this conversation as resolved.
Comment thread
aguxez marked this conversation as resolved.
Comment thread
aguxez marked this conversation as resolved.
const errors = [
...(serverError ? [serverError] : []),
...results.filter((r): r is PromiseRejectedResult => r.status === "rejected").map((r) => r.reason as unknown),
];
if (errors.length > 0) throw new AggregateError(errors, "closing services failed");
}

Comment thread
aguxez marked this conversation as resolved.
if (!process.env.VITEST) {
scheduleMaturityChecks().catch((error: unknown) => {
captureException(error, { level: "error", tags: { unhandled: true } });
});
Comment thread
aguxez marked this conversation as resolved.

["SIGINT", "SIGTERM"].map((code) => {
process.on(code, () => {
close()
Expand Down
Loading