-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61560df
commit e20ddb9
Showing
10 changed files
with
232 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ConnectionOptions } from "typeorm"; | ||
import { Position } from "./entity/Position"; | ||
import { Price } from "./entity/Price"; | ||
import { Transaction } from "./entity/Transaction"; | ||
import { Event } from "./entity/Event"; | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
|
||
const sqliteOptions: ConnectionOptions = { | ||
type: "sqlite", | ||
database: "./data/database.sqlite", | ||
synchronize: true, | ||
logging: true, | ||
entities: [Price, Position, Transaction, Event], | ||
}; | ||
|
||
const postgresOptions: ConnectionOptions = { | ||
type: "postgres", | ||
url: process.env.DATABASE_URL, | ||
synchronize: true, | ||
logging: true, | ||
entities: [Price, Position, Transaction, Event], | ||
}; | ||
|
||
const connectionOptions = isProduction ? postgresOptions : sqliteOptions; | ||
|
||
export default connectionOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { exec } from 'child_process'; | ||
|
||
// Function to run a script with child_process | ||
const runScript = (script: string) => { | ||
return new Promise((resolve, reject) => { | ||
const process = exec(`ts-node ${script}`, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`Error executing ${script}:`, error); | ||
reject(error); | ||
} | ||
if (stderr) { | ||
console.error(`Stderr from ${script}:`, stderr); | ||
} | ||
console.log(`Stdout from ${script}:`, stdout); | ||
resolve(stdout); | ||
}); | ||
|
||
process.on('exit', (code) => { | ||
console.log(`Process ${script} exited with code ${code}`); | ||
}); | ||
}); | ||
}; | ||
|
||
// Run both scripts in parallel | ||
Promise.all([ | ||
runScript('packages/data/src/processes/chain.ts'), | ||
runScript('packages/data/src/processes/market.ts') | ||
]).catch(error => { | ||
console.error('Error running scripts in parallel:', error); | ||
}); |
Oops, something went wrong.