mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
docs: completed v1 docs (#36)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import knex, { Knex } from 'knex';
|
||||
|
||||
import { source } from './migrations/migrations.source.js';
|
||||
import { mkdir } from 'fs/promises';
|
||||
import { dirname } from 'path';
|
||||
|
||||
const tableNames = {
|
||||
loads: 'loads',
|
||||
@@ -20,6 +22,15 @@ class Database {
|
||||
}
|
||||
|
||||
#setup = async (config: Knex.Config) => {
|
||||
if (
|
||||
config.connection &&
|
||||
typeof config.connection !== 'string' &&
|
||||
'filename' in config.connection &&
|
||||
typeof config.connection.filename === 'string' &&
|
||||
config.connection.filename !== ':memory:'
|
||||
) {
|
||||
await mkdir(dirname(config.connection.filename), { recursive: true });
|
||||
}
|
||||
const db = knex(config);
|
||||
await db.migrate.latest();
|
||||
return db;
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import pkg from '../../package.json';
|
||||
import { fastifyTRPCPlugin, FastifyTRPCPluginOptions } from '@trpc/server/adapters/fastify';
|
||||
import fastify from 'fastify';
|
||||
import { RootRouter, rootRouter } from '../router/router.js';
|
||||
import { createContext } from '../router/router.utils.js';
|
||||
import { Runtime } from '../runtime/runtime.js';
|
||||
import { gateway } from '../gateway/gateway.js';
|
||||
import { createRequire } from 'module';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const createServer = async (runtime: Runtime) => {
|
||||
const pkgLocation = require.resolve('#pkg');
|
||||
const pkg = JSON.parse(await readFile(pkgLocation, 'utf-8'));
|
||||
|
||||
const server = fastify({
|
||||
maxParamLength: 10000,
|
||||
bodyLimit: 30 * 1024 * 1024,
|
||||
|
||||
Reference in New Issue
Block a user