feat: add app serve

This commit is contained in:
2024-10-17 01:18:03 +08:00
parent edb0d56094
commit 5c3f454d8c
17 changed files with 1314 additions and 36 deletions

View File

@@ -5,6 +5,9 @@ import fs from 'fs';
const envisionPath = path.join(os.homedir(), '.config', 'envision');
const configPath = path.join(os.homedir(), '.config', 'envision', 'config.json');
export const pidFilePath = path.join(envisionPath, 'app.pid');
export const dbPath = path.join(envisionPath, 'db.sqlite');
export const checkFileExists = (filePath: string) => {
try {
fs.accessSync(filePath, fs.constants.F_OK);

13
src/module/sequelize.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Sequelize } from 'sequelize';
import { dbPath } from './get-config.ts';
// connect to db
export const sequelize = new Sequelize({
dialect: 'sqlite',
// storage: 'db.sqlite',
storage: dbPath,
// logging: false,
});
sequelize.authenticate({ logging: false }).then(() => {
console.log('Connection sqlite has been established successfully.');
});