feat: implement database setup, logging, and workflow management
- Added database configuration and migration setup using Knex. - Implemented a logging system with Pino, including log persistence and flushing. - Created a server runner with Fastify, integrating authentication and various API routes. - Introduced a script sandbox for executing user-defined scripts with restricted access. - Established initial workflows and scripts for manual and cron triggers. - Included documentation for API endpoints and workflows.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const dbPath = process.env.SCRUNNER_DB_PATH ?? path.resolve("data/scrunner.db");
|
||||
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
|
||||
|
||||
/** @type {import("knex").Knex.Config} */
|
||||
const config = {
|
||||
client: "better-sqlite3",
|
||||
connection: {
|
||||
filename: dbPath,
|
||||
},
|
||||
useNullAsDefault: true,
|
||||
migrations: {
|
||||
directory: "./migrations",
|
||||
extension: "js",
|
||||
loadExtensions: [".js"],
|
||||
},
|
||||
pool: {
|
||||
afterCreate(conn, done) {
|
||||
try {
|
||||
conn.pragma("journal_mode = WAL");
|
||||
conn.pragma("busy_timeout = 5000");
|
||||
conn.pragma("foreign_keys = ON");
|
||||
done(null, conn);
|
||||
} catch (err) {
|
||||
done(err, conn);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
Reference in New Issue
Block a user