diff options
| author | Peerawas Archavanuntakun <[email protected]> | 2022-01-06 03:30:32 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-05 14:30:32 -0600 |
| commit | 51d378e4cb4584196b14132b4d330b8d370f8fb3 (patch) | |
| tree | 176959c304bcb28ef33df0a3546bb4b88d691b09 /src/utils | |
| parent | 129d121364c7e976c7bf5e2da3976da230058d77 (diff) | |
| download | muse-51d378e4cb4584196b14132b4d330b8d370f8fb3.tar.xz muse-51d378e4cb4584196b14132b4d330b8d370f8fb3.zip | |
Setup and migrate to Prisma (#456)
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/create-database-url.ts | 5 | ||||
| -rw-r--r-- | src/utils/db.ts | 13 | ||||
| -rw-r--r-- | src/utils/log-banner.ts | 16 |
3 files changed, 23 insertions, 11 deletions
diff --git a/src/utils/create-database-url.ts b/src/utils/create-database-url.ts new file mode 100644 index 0000000..cab398e --- /dev/null +++ b/src/utils/create-database-url.ts @@ -0,0 +1,5 @@ +export const createDatabasePath = (directory: string) => `${directory}/db.sqlite`; + +const createDatabaseUrl = (directory: string) => `file:${createDatabasePath(directory)}`; + +export default createDatabaseUrl; diff --git a/src/utils/db.ts b/src/utils/db.ts index 15a2d79..b630320 100644 --- a/src/utils/db.ts +++ b/src/utils/db.ts @@ -1,12 +1,3 @@ -import {Sequelize} from 'sequelize-typescript'; -import path from 'path'; -import {DATA_DIR} from '../services/config.js'; -import {FileCache, KeyValueCache, Settings, Shortcut} from '../models/index.js'; +import Prisma from '@prisma/client'; -export const sequelize = new Sequelize({ - dialect: 'sqlite', - database: 'muse', - storage: path.join(DATA_DIR, 'db.sqlite'), - models: [FileCache, KeyValueCache, Settings, Shortcut], - logging: false, -}); +export const prisma = new Prisma.PrismaClient(); diff --git a/src/utils/log-banner.ts b/src/utils/log-banner.ts new file mode 100644 index 0000000..0ad6466 --- /dev/null +++ b/src/utils/log-banner.ts @@ -0,0 +1,16 @@ +import {makeLines} from 'nodesplash'; +import metadata from '../../package.json'; + +const logBanner = () => { + console.log(makeLines({ + user: 'codetheweb', + repository: 'muse', + version: metadata.version, + paypalUser: 'codetheweb', + githubSponsor: 'codetheweb', + madeByPrefix: 'Made with 🎶 by ', + }).join('\n')); + console.log('\n'); +}; + +export default logBanner; |
