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,4 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import 'source-map-support/register.js';
|
||||
import '../dist/esm/src/index.js';
|
||||
import '../dist/esm/index.js';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@morten-olsen/mini-loader-cli",
|
||||
"version": "1.0.0",
|
||||
"main": "./dist/esm/src/index.js",
|
||||
"types": "./dist/esm/src/index.d.ts",
|
||||
"main": "./dist/esm/index.js",
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"license": "GPL-3.0",
|
||||
"bin": {
|
||||
"mini-loader": "./bin/index.mjs"
|
||||
@@ -14,9 +14,12 @@
|
||||
"files": [
|
||||
"./dist"
|
||||
],
|
||||
"imports": {
|
||||
"#pkg": "./package.json"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/esm/src/index.js"
|
||||
"import": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
|
||||
import superjson from 'superjson';
|
||||
import { createRequire } from 'module';
|
||||
import type { Runtime } from '@morten-olsen/mini-loader-server';
|
||||
import type { RootRouter } from '@morten-olsen/mini-loader-server';
|
||||
import pkg from '../../package.json';
|
||||
import { Context } from '../context/context.js';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const pkg = JSON.parse(await readFile(require.resolve('#pkg'), 'utf-8'));
|
||||
const createClient = (context: Context) => {
|
||||
if (!context.host || !context.token) {
|
||||
throw new Error('Not signed in');
|
||||
|
||||
@@ -6,7 +6,7 @@ import { join } from 'path';
|
||||
const ENV_PREFIX = 'ML_S_';
|
||||
|
||||
const readSecrets = async () => {
|
||||
let secretLocation = join(process.cwd(), '.secret');
|
||||
let secretLocation = join(process.cwd(), '.secrets');
|
||||
|
||||
let secrets: Record<string, string> = {};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Command, program } from 'commander';
|
||||
import pkg from '../package.json';
|
||||
import { createRequire } from 'module';
|
||||
import { loads } from './commands/loads/loads.js';
|
||||
import { runs } from './commands/runs/runs.js';
|
||||
import { logs } from './commands/logs/logs.js';
|
||||
@@ -9,6 +9,11 @@ import { local } from './commands/local/local.js';
|
||||
import { auth } from './commands/auth/auth.js';
|
||||
import { contexts } from './commands/contexts/contexts.js';
|
||||
import { schedules } from './commands/schedules/schedules.js';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const pkg = JSON.parse(await readFile(require.resolve('#pkg'), 'utf-8'));
|
||||
|
||||
program.addCommand(loads);
|
||||
program.addCommand(runs);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "@morten-olsen/mini-loader-configs/tsconfig.esm.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist/esm",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*.ts"
|
||||
|
||||
1
packages/examples/.secrets
Normal file
1
packages/examples/.secrets
Normal file
@@ -0,0 +1 @@
|
||||
demo=foobar
|
||||
3
packages/examples/src/secrets.ts
Normal file
3
packages/examples/src/secrets.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { secrets } from '@morten-olsen/mini-loader';
|
||||
|
||||
console.log(secrets.get('demo'));
|
||||
@@ -3,7 +3,6 @@ import { artifacts, logger } from '@morten-olsen/mini-loader';
|
||||
const run = async () => {
|
||||
await logger.info('Hello world');
|
||||
await artifacts.create('foo', 'bar');
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
run();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Socket, createConnection } from 'net';
|
||||
import { Event } from './index.js';
|
||||
|
||||
const connect = () =>
|
||||
new Promise<Socket>((resolve, reject) => {
|
||||
@@ -12,7 +13,7 @@ const connect = () =>
|
||||
});
|
||||
});
|
||||
|
||||
const send = async (data: any) =>
|
||||
const send = async (data: Event) =>
|
||||
new Promise<void>(async (resolve, reject) => {
|
||||
const connection = await connect();
|
||||
const cleaned = JSON.parse(JSON.stringify(data));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import 'source-map-support/register.js';
|
||||
import '../dist/esm/src/index.js';
|
||||
import '../dist/esm/index.js';
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"name": "@morten-olsen/mini-loader-server",
|
||||
"version": "1.0.0",
|
||||
"license": "GPL-3.0",
|
||||
"main": "./dist/esm/src/index.js",
|
||||
"types": "./dist/esm/src/index.d.ts",
|
||||
"main": "./dist/esm/index.js",
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"bin": {
|
||||
"mini-loader-server": "./bin/index.mjs"
|
||||
},
|
||||
@@ -14,9 +14,12 @@
|
||||
"files": [
|
||||
"./dist"
|
||||
],
|
||||
"imports": {
|
||||
"#pkg": "./package.json"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/esm/src/index.js"
|
||||
"import": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "@morten-olsen/mini-loader-configs/tsconfig.esm.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist/esm",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
|
||||
Reference in New Issue
Block a user