fix: persist database storage volume and throw explicit missing asaas api key error
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 45s
Details
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 45s
Details
This commit is contained in:
parent
ba998abbc7
commit
41536cc11c
|
|
@ -41,6 +41,8 @@ services:
|
|||
- DATABASE_URL=postgresql://microtecflix_user:MicrotecFlixSecurePass2026!@postgres-microtecflix:5432/microtecflix
|
||||
- JWT_SECRET=microtecflix_jwt_secret_key_2026_super_secure
|
||||
- ASAAS_ENVIRONMENT=sandbox
|
||||
volumes:
|
||||
- appdata-microtecflix:/app/data
|
||||
networks:
|
||||
- microtecflix-net
|
||||
- network_public
|
||||
|
|
@ -60,19 +62,18 @@ services:
|
|||
- "traefik.http.routers.microtecflix-student.entrypoints=websecure"
|
||||
- "traefik.http.routers.microtecflix-student.tls=true"
|
||||
- "traefik.http.routers.microtecflix-student.tls.certresolver=leresolver"
|
||||
- "traefik.http.routers.microtecflix-student.service=microtecflix-student"
|
||||
- "traefik.http.services.microtecflix-student.loadbalancer.server.port=3000"
|
||||
# Painel Admin
|
||||
- "traefik.http.routers.microtecflix-admin.rule=Host(`admin-estudo.microtecinformaticacurso.com.br`)"
|
||||
- "traefik.http.routers.microtecflix-admin.entrypoints=websecure"
|
||||
- "traefik.http.routers.microtecflix-admin.tls=true"
|
||||
- "traefik.http.routers.microtecflix-admin.tls.certresolver=leresolver"
|
||||
- "traefik.http.routers.microtecflix-admin.service=microtecflix-admin"
|
||||
- "traefik.http.services.microtecflix-admin.loadbalancer.server.port=3000"
|
||||
- "traefik.docker.network=network_public"
|
||||
|
||||
volumes:
|
||||
pgdata-microtecflix:
|
||||
appdata-microtecflix:
|
||||
|
||||
networks:
|
||||
microtecflix-net:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import path from 'path';
|
|||
import bcrypt from 'bcryptjs';
|
||||
import { User, Course, Module, Lesson, Note, LessonProgress, WebhookLog, SubscriptionPayment } from '../types';
|
||||
|
||||
const DB_FILE = path.join(process.cwd(), 'database.json');
|
||||
const DATA_DIR = process.env.DATA_DIR || (fs.existsSync('/app/data') ? '/app/data' : process.cwd());
|
||||
const DB_FILE = path.join(DATA_DIR, 'database.json');
|
||||
|
||||
export interface DatabaseSchema {
|
||||
users: User[];
|
||||
|
|
|
|||
|
|
@ -122,22 +122,7 @@ export class AsaasService {
|
|||
): Promise<{ subscriptionId: string; payment: Partial<SubscriptionPayment> }> {
|
||||
const apiKey = this.getApiKey();
|
||||
if (!apiKey) {
|
||||
console.warn('ASAAS_API_KEY not configured. Simulating subscription creation.');
|
||||
const subId = `sub_sim_${Math.random().toString(36).substring(2, 9)}`;
|
||||
const invoiceUrl = `https://sandbox.asaas.com/i/simulated_${subId}`;
|
||||
return {
|
||||
subscriptionId: subId,
|
||||
payment: {
|
||||
id: `pay_sim_${Math.random().toString(36).substring(2, 9)}`,
|
||||
value,
|
||||
status: 'PENDING',
|
||||
billingType,
|
||||
invoiceUrl,
|
||||
dueDate: new Date(Date.now() + 3 * 24 * 3600 * 1000).toISOString().split('T')[0],
|
||||
paidAt: null,
|
||||
createdAt: new Date().toISOString()
|
||||
}
|
||||
};
|
||||
throw new Error('A Chave de API do Asaas (API Key) não foi configurada. Acesse o Painel Admin -> Configurações Globais, cole a sua chave do Asaas Sandbox e clique em Salvar Configurações.');
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -297,16 +282,7 @@ export class AsaasService {
|
|||
const futureDueDate = new Date(Date.now() + 3 * 24 * 3600 * 1000).toISOString().split('T')[0];
|
||||
|
||||
if (!apiKey) {
|
||||
console.warn('ASAAS_API_KEY not configured. Simulating payment creation.');
|
||||
const payId = `pay_sim_${Math.random().toString(36).substring(2, 9)}`;
|
||||
return {
|
||||
id: payId,
|
||||
value,
|
||||
status: 'PENDING',
|
||||
billingType,
|
||||
invoiceUrl: `https://sandbox.asaas.com/i/simulated_${payId}`,
|
||||
dueDate: futureDueDate,
|
||||
};
|
||||
throw new Error('A Chave de API do Asaas (API Key) não foi configurada. Acesse o Painel Admin -> Configurações Globais, cole a sua chave do Asaas Sandbox e clique em Salvar Configurações.');
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue