Skip to content
Merged
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
20 changes: 2 additions & 18 deletions backend-all/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
"contracts": "yarn contracts:sync && yarn contracts:typings",
"contracts:sync": "SCRIPT=./src/gotbit-tools/scripts/shell/import-contracts.sh yarn script",
"contracts:typings": "node ./src/gotbit-tools/scripts/typings.js",
"typeorm": "typeorm-ts-node-commonjs",
"migration:generate": "yarn typeorm migration:generate -d src/lib/database/data-source.ts",
"migration:run": "yarn typeorm migration:run -d src/lib/database/data-source.ts",
"migration:revert": "yarn typeorm migration:revert -d src/lib/database/data-source.ts",
"migration:show": "yarn typeorm migration:show -d src/lib/database/data-source.ts",
"schema:sync": "yarn typeorm schema:sync -d src/lib/database/data-source.ts",
"schema:drop": "yarn typeorm schema:drop -d src/lib/database/data-source.ts",
"\n# UTILS SCRIPTS:": "",
"script": "chmod +x $SCRIPT && $SCRIPT",
"dev-win": "yarn build-win && concurrently \"tsc -w\" \"cross-env DEBUG=true node-dev --respawn dist/app.js\"",
Expand Down Expand Up @@ -51,12 +44,8 @@
"author": "kotsmile",
"license": "MIT",
"dependencies": {
"@coral-xyz/anchor": "^0.31.1",
"@solana/spl-token": "^0.4.13",
"@solana/web3.js": "^1.98.4",
"axios": "^0.27.2",
"body-parser": "^1.20.0",
"bs58": "^6.0.0",
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"ethers": "^5.6.6",
Expand All @@ -66,11 +55,7 @@
"helmet": "^5.0.2",
"module-alias": "^2.2.2",
"moment": "^2.29.3",
"morgan": "^1.10.0",
"pg": "^8.8.0",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.3.12",
"winston": "^3.17.0"
"morgan": "^1.10.0"
},
"devDependencies": {
"@types/chai": "^4.3.3",
Expand All @@ -80,7 +65,6 @@
"@types/mocha": "^9.1.1",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.31",
"@types/pg": "^8.6.6",
"@types/supertest": "^2.0.12",
"c8": "^7.11.3",
"chai": "^4.3.6",
Expand All @@ -90,6 +74,6 @@
"node-dev": "^7.4.3",
"supertest": "^6.2.4",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
"typescript": "^4.6.4"
}
}
52 changes: 6 additions & 46 deletions backend-all/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'reflect-metadata'
import express from 'express'
import path from 'path'

Expand All @@ -11,9 +10,7 @@ import 'module-alias/register'
import * as dotenv from 'dotenv'
dotenv.config()

import { config } from '@/config'
import { dbConnection } from '@/lib/database'
import { isPublicRelayer } from './utils/env-var'
import config from '@/config'

const app = express()

Expand All @@ -23,47 +20,10 @@ autoroutes(app, {
dir: path.join(__dirname, 'routes'),
})

// Initialize database connection and start server
const startServer = async () => {
try {
// Connect to database

if (isPublicRelayer) {
await dbConnection.connect()

// Run migrations on startup (optional - you might want to run them manually)
await dbConnection.runMigrations()
}

if (!process.env.TEST) {
app.listen(config.port, () => {
console.log(`Server started on port ${config.port}`)
console.log(`DEBUG=${process.env.DEBUG}`)
console.log('Database connected successfully')
})
}
} catch (error) {
console.error('Failed to start server:', error)
process.exit(1)
}
}

// Graceful shutdown
process.on('SIGINT', async () => {
console.log('Shutting down gracefully...')


await dbConnection.disconnect()
process.exit(0)
})

process.on('SIGTERM', async () => {
console.log('Shutting down gracefully...')

await dbConnection.disconnect()
process.exit(0)
})

startServer()
if (!process.env.TEST)
app.listen(config.port, () => {
console.log(`Server started on port ${config.port}`)
console.log(`DEBUG=${process.env.DEBUG}`)
})

export default app
14 changes: 2 additions & 12 deletions backend-all/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
console.log(process.env.DATABASE_USERNAME)
export const config = {
export default {
morganLogger:
':date[web] :method :url :status :res[content-length] - :response-time ms',
port: process.env.PORT,
database: {
host: process.env.DATABASE_HOST || 'localhost',
port: parseInt(process.env.DATABASE_PORT || '5432'),
username: process.env.DATABASE_USERNAME || 'postgres',
password: process.env.DATABASE_PASSWORD || 'password',
database: process.env.DATABASE_NAME || 'assetchain_bridge',
logging: process.env.DB_LOGGING === 'true',
ssl: process.env.DB_SSL === 'true',
},
};
}
43 changes: 20 additions & 23 deletions backend-all/src/confirmations.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
{
"1": 10,
"97": 10,
"56": 10,
"137": 10,
"369": 10,
"5000": 10,
"31337": 10,
"42161": 10,
"5001": 10,
"43113": 10,
"80001": 10,
"421614": 10,
"8453": 10,
"42421": 5,
"80002": 10,
"84532": 10,
"11155111": 10,
"200810": 10,
"200901": 10,
"42420": 5,
"solana": 10,
"sol.devnet": 10,
"sol.mainnet": 10
"1": 7,
"97": 42,
"56": 42,
"137": 42,
"369": 42,
"5000": 42,
"31337": 42,
"42161": 42,
"5001": 42,
"43113": 42,
"80001": 42,
"421614": 42,
"8453": 42,
"42421": 42,
"80002": 42,
"84532": 42,
"11155111": 42,
"200810": 42,
"200901": 42,
"42420": 42
}
88 changes: 0 additions & 88 deletions backend-all/src/lib/database/connection.ts

This file was deleted.

21 changes: 0 additions & 21 deletions backend-all/src/lib/database/data-source.ts

This file was deleted.

12 changes: 0 additions & 12 deletions backend-all/src/lib/database/entities/BaseEntity.ts

This file was deleted.

14 changes: 0 additions & 14 deletions backend-all/src/lib/database/entities/BlockscanInfo.ts

This file was deleted.

38 changes: 0 additions & 38 deletions backend-all/src/lib/database/entities/BridgeInfo.ts

This file was deleted.

24 changes: 0 additions & 24 deletions backend-all/src/lib/database/entities/Token.ts

This file was deleted.

Loading