Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m18s
CI/CD Pipeline / Security Scanning (push) Successful in 2m34s
CI/CD Pipeline / Lint and Format (push) Failing after 54s
CI/CD Pipeline / Terraform Validation (push) Failing after 27s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 28s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 39s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 31s
Validation / validate-genesis (push) Successful in 28s
Validation / validate-terraform (push) Failing after 31s
Validation / validate-kubernetes (push) Failing after 11s
Validation / validate-smart-contracts (push) Failing after 11s
Validation / validate-security (push) Failing after 1m27s
Validation / validate-documentation (push) Failing after 21s
Verify Deployment / Verify Deployment (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import express from 'express';
|
|
import cors from 'cors';
|
|
import { loadCustomerSecurityPolicy } from '@dbis/integration-foundation';
|
|
import { createSettlementRouter } from './api/routes/settlement';
|
|
import { settlementRateLimiter } from './middleware/rate-limit';
|
|
import { port } from './config';
|
|
|
|
function corsOptions(): cors.CorsOptions {
|
|
const policy = loadCustomerSecurityPolicy();
|
|
const origins = policy.corsOrigins.filter(Boolean);
|
|
if (!origins.length) return {};
|
|
return {
|
|
origin(origin, cb) {
|
|
if (!origin || origins.includes(origin)) cb(null, true);
|
|
else cb(new Error('CORS not allowed'));
|
|
},
|
|
};
|
|
}
|
|
|
|
export function createApp() {
|
|
const app = express();
|
|
app.use(cors(corsOptions()));
|
|
app.use(express.json({ limit: '2mb' }));
|
|
app.use(express.text({ type: 'text/plain', limit: '2mb' }));
|
|
app.use('/api/v1/settlement', settlementRateLimiter, createSettlementRouter());
|
|
return app;
|
|
}
|
|
|
|
export function startServer(): void {
|
|
const app = createApp();
|
|
const p = port();
|
|
app.listen(p, () => {
|
|
console.log(`OMNL settlement middleware listening on http://localhost:${p}/api/v1/settlement`);
|
|
});
|
|
}
|