mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +03:00
Initial push
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'reflect-metadata'
|
||||
import path from 'path'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { ChatFlow } from './entity/ChatFlow'
|
||||
import { ChatMessage } from './entity/ChatMessage'
|
||||
import { getUserHome } from './utils'
|
||||
|
||||
let appDataSource: DataSource
|
||||
|
||||
export const init = async (): Promise<void> => {
|
||||
const homePath = path.join(getUserHome(), '.flowise')
|
||||
|
||||
appDataSource = new DataSource({
|
||||
type: 'sqlite',
|
||||
database: path.resolve(homePath, 'database.sqlite'),
|
||||
synchronize: true,
|
||||
entities: [ChatFlow, ChatMessage],
|
||||
migrations: []
|
||||
})
|
||||
}
|
||||
|
||||
export function getDataSource(): DataSource {
|
||||
if (appDataSource === undefined) {
|
||||
init()
|
||||
}
|
||||
return appDataSource
|
||||
}
|
||||
Reference in New Issue
Block a user