add project

This commit is contained in:
ZOMBIIIIIII
2026-04-08 14:11:27 +03:00
parent bfa95223a0
commit a81e29807c
115 changed files with 18413 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import knex, { Knex } from 'knex';
import { env } from './env';
let _db: Knex | null = null;
function getDb(): Knex {
if (!_db) {
_db = knex({
client: 'pg',
connection: {
host: env.db.host,
port: env.db.port,
user: env.db.user,
password: env.db.password,
database: env.db.name,
},
pool: { min: 2, max: 10 },
});
}
return _db;
}
const callableDb = (() => undefined) as unknown as Knex;
export const db = new Proxy(callableDb, {
apply(_target, _thisArg, args) {
return (getDb() as any)(...args);
},
get(_target, prop) {
return (getDb() as any)[prop];
},
}) as Knex;

View File

@@ -0,0 +1,28 @@
import dotenv from 'dotenv';
import path from 'path';
dotenv.config({ path: path.resolve(__dirname, '../../../../.env') });
export const env = {
db: {
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432'),
user: process.env.DB_USER || 'postgres',
password: process.env.DB_PASSWORD || 'postgres',
name: process.env.DB_NAME || 'cryptowallet_v2',
},
jwt: {
jwksUrl: process.env.JWT_JWKS_URL || '',
publicKey: process.env.JWT_PUBLIC_KEY || '',
algorithm: process.env.JWT_ALGORITHM || 'RS256',
issuer: process.env.JWT_ISSUER || '',
audience: process.env.JWT_AUDIENCE || '',
},
port: parseInt(process.env.API_PORT || '3001'),
frontendUrl: process.env.FRONTEND_URL || 'http://localhost:3000',
relayApiKey: process.env.RELAY_API_KEY || null,
tronApiKey: process.env.TRON_API_KEY || null,
jupiterApiKey: process.env.JUPITER_API_KEY || null,
jupiterReferralAccount: process.env.JUPITER_REFERRAL_ACCOUNT || null,
jupiterFeeBps: parseInt(process.env.JUPITER_FEE_BPS || '70'),
};

View File

@@ -0,0 +1,5 @@
import fs from 'fs';
import path from 'path';
const swaggerPath = path.resolve(__dirname, '../../swagger.json');
export const swaggerSpec = JSON.parse(fs.readFileSync(swaggerPath, 'utf-8'));