Skip to content

Commit dc90eb5

Browse files
authored
Revert "backend redesign (#98)"
This reverts commit 4b19b55.
1 parent 4b19b55 commit dc90eb5

60 files changed

Lines changed: 291 additions & 8369 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend-all/package.json

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
"contracts": "yarn contracts:sync && yarn contracts:typings",
1818
"contracts:sync": "SCRIPT=./src/gotbit-tools/scripts/shell/import-contracts.sh yarn script",
1919
"contracts:typings": "node ./src/gotbit-tools/scripts/typings.js",
20-
"typeorm": "typeorm-ts-node-commonjs",
21-
"migration:generate": "yarn typeorm migration:generate -d src/lib/database/data-source.ts",
22-
"migration:run": "yarn typeorm migration:run -d src/lib/database/data-source.ts",
23-
"migration:revert": "yarn typeorm migration:revert -d src/lib/database/data-source.ts",
24-
"migration:show": "yarn typeorm migration:show -d src/lib/database/data-source.ts",
25-
"schema:sync": "yarn typeorm schema:sync -d src/lib/database/data-source.ts",
26-
"schema:drop": "yarn typeorm schema:drop -d src/lib/database/data-source.ts",
2720
"\n# UTILS SCRIPTS:": "",
2821
"script": "chmod +x $SCRIPT && $SCRIPT",
2922
"dev-win": "yarn build-win && concurrently \"tsc -w\" \"cross-env DEBUG=true node-dev --respawn dist/app.js\"",
@@ -51,12 +44,8 @@
5144
"author": "kotsmile",
5245
"license": "MIT",
5346
"dependencies": {
54-
"@coral-xyz/anchor": "^0.31.1",
55-
"@solana/spl-token": "^0.4.13",
56-
"@solana/web3.js": "^1.98.4",
5747
"axios": "^0.27.2",
5848
"body-parser": "^1.20.0",
59-
"bs58": "^6.0.0",
6049
"cors": "^2.8.5",
6150
"dotenv": "^16.0.0",
6251
"ethers": "^5.6.6",
@@ -66,11 +55,7 @@
6655
"helmet": "^5.0.2",
6756
"module-alias": "^2.2.2",
6857
"moment": "^2.29.3",
69-
"morgan": "^1.10.0",
70-
"pg": "^8.8.0",
71-
"reflect-metadata": "^0.1.13",
72-
"typeorm": "^0.3.12",
73-
"winston": "^3.17.0"
58+
"morgan": "^1.10.0"
7459
},
7560
"devDependencies": {
7661
"@types/chai": "^4.3.3",
@@ -80,7 +65,6 @@
8065
"@types/mocha": "^9.1.1",
8166
"@types/morgan": "^1.9.3",
8267
"@types/node": "^17.0.31",
83-
"@types/pg": "^8.6.6",
8468
"@types/supertest": "^2.0.12",
8569
"c8": "^7.11.3",
8670
"chai": "^4.3.6",
@@ -90,6 +74,6 @@
9074
"node-dev": "^7.4.3",
9175
"supertest": "^6.2.4",
9276
"ts-jest": "^29.0.0",
93-
"typescript": "^5.0.0"
77+
"typescript": "^4.6.4"
9478
}
9579
}

backend-all/src/app.ts

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'reflect-metadata'
21
import express from 'express'
32
import path from 'path'
43

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

14-
import { config } from '@/config'
15-
import { dbConnection } from '@/lib/database'
16-
import { isPublicRelayer } from './utils/env-var'
13+
import config from '@/config'
1714

1815
const app = express()
1916

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

26-
// Initialize database connection and start server
27-
const startServer = async () => {
28-
try {
29-
// Connect to database
30-
31-
if (isPublicRelayer) {
32-
await dbConnection.connect()
33-
34-
// Run migrations on startup (optional - you might want to run them manually)
35-
await dbConnection.runMigrations()
36-
}
37-
38-
if (!process.env.TEST) {
39-
app.listen(config.port, () => {
40-
console.log(`Server started on port ${config.port}`)
41-
console.log(`DEBUG=${process.env.DEBUG}`)
42-
console.log('Database connected successfully')
43-
})
44-
}
45-
} catch (error) {
46-
console.error('Failed to start server:', error)
47-
process.exit(1)
48-
}
49-
}
50-
51-
// Graceful shutdown
52-
process.on('SIGINT', async () => {
53-
console.log('Shutting down gracefully...')
54-
55-
56-
await dbConnection.disconnect()
57-
process.exit(0)
58-
})
59-
60-
process.on('SIGTERM', async () => {
61-
console.log('Shutting down gracefully...')
62-
63-
await dbConnection.disconnect()
64-
process.exit(0)
65-
})
66-
67-
startServer()
23+
if (!process.env.TEST)
24+
app.listen(config.port, () => {
25+
console.log(`Server started on port ${config.port}`)
26+
console.log(`DEBUG=${process.env.DEBUG}`)
27+
})
6828

6929
export default app

backend-all/src/config.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
console.log(process.env.DATABASE_USERNAME)
2-
export const config = {
1+
export default {
32
morganLogger:
43
':date[web] :method :url :status :res[content-length] - :response-time ms',
54
port: process.env.PORT,
6-
database: {
7-
host: process.env.DATABASE_HOST || 'localhost',
8-
port: parseInt(process.env.DATABASE_PORT || '5432'),
9-
username: process.env.DATABASE_USERNAME || 'postgres',
10-
password: process.env.DATABASE_PASSWORD || 'password',
11-
database: process.env.DATABASE_NAME || 'assetchain_bridge',
12-
logging: process.env.DB_LOGGING === 'true',
13-
ssl: process.env.DB_SSL === 'true',
14-
},
15-
};
5+
}

backend-all/src/confirmations.json

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
{
2-
"1": 10,
3-
"97": 10,
4-
"56": 10,
5-
"137": 10,
6-
"369": 10,
7-
"5000": 10,
8-
"31337": 10,
9-
"42161": 10,
10-
"5001": 10,
11-
"43113": 10,
12-
"80001": 10,
13-
"421614": 10,
14-
"8453": 10,
15-
"42421": 5,
16-
"80002": 10,
17-
"84532": 10,
18-
"11155111": 10,
19-
"200810": 10,
20-
"200901": 10,
21-
"42420": 5,
22-
"solana": 10,
23-
"sol.devnet": 10,
24-
"sol.mainnet": 10
2+
"1": 7,
3+
"97": 42,
4+
"56": 42,
5+
"137": 42,
6+
"369": 42,
7+
"5000": 42,
8+
"31337": 42,
9+
"42161": 42,
10+
"5001": 42,
11+
"43113": 42,
12+
"80001": 42,
13+
"421614": 42,
14+
"8453": 42,
15+
"42421": 42,
16+
"80002": 42,
17+
"84532": 42,
18+
"11155111": 42,
19+
"200810": 42,
20+
"200901": 42,
21+
"42420": 42
2522
}

backend-all/src/lib/database/connection.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

backend-all/src/lib/database/data-source.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

backend-all/src/lib/database/entities/BaseEntity.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

backend-all/src/lib/database/entities/BlockscanInfo.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

backend-all/src/lib/database/entities/BridgeInfo.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

backend-all/src/lib/database/entities/Token.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)