mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
feat: switched from worker API to fs based
This commit is contained in:
@@ -15,14 +15,19 @@ npm install -g @morten-olsen/mini-loader-cli
|
|||||||
Now, let's write a basic script that outputs a single artifact named “hello”. Create a new file with the following JavaScript code:
|
Now, let's write a basic script that outputs a single artifact named “hello”. Create a new file with the following JavaScript code:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { artifacts } from "@morten-olsen/mini-loader";
|
import { artifacts } from '@morten-olsen/mini-loader';
|
||||||
|
|
||||||
artifacts.create('hello', 'world');
|
const run = async () => {
|
||||||
|
artifacts.create('hello', 'world');
|
||||||
|
};
|
||||||
|
|
||||||
|
run();
|
||||||
```
|
```
|
||||||
|
|
||||||
Save this file as `script.mjs`.
|
Save this file as `script.js`.
|
||||||
|
|
||||||
#### A Note on Dependencies
|
#### A Note on Dependencies
|
||||||
|
|
||||||
In this script, we're using the `@morten-olsen/mini-loader` package, which might not be installed in your local environment. No worries though, as mini loader can automatically download necessary packages when preparing the script. Alternatively, for a more structured approach (especially if you're using TypeScript), you can initialize a Node.js project and install the dependencies for complete access to typings.
|
In this script, we're using the `@morten-olsen/mini-loader` package, which might not be installed in your local environment. No worries though, as mini loader can automatically download necessary packages when preparing the script. Alternatively, for a more structured approach (especially if you're using TypeScript), you can initialize a Node.js project and install the dependencies for complete access to typings.
|
||||||
|
|
||||||
### Step 3: Run the Script Locally
|
### Step 3: Run the Script Locally
|
||||||
@@ -30,7 +35,7 @@ In this script, we're using the `@morten-olsen/mini-loader` package, which might
|
|||||||
To validate that your script is functioning correctly, execute it locally using the following command:
|
To validate that your script is functioning correctly, execute it locally using the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mini-loader local run script.mjs -ai
|
mini-loader local run script.js -ai
|
||||||
```
|
```
|
||||||
|
|
||||||
The `-ai` flag instructs the CLI to automatically download any referenced packages when bundling the script.
|
The `-ai` flag instructs the CLI to automatically download any referenced packages when bundling the script.
|
||||||
@@ -41,4 +46,4 @@ After running the command, you should see an output confirming that a new artifa
|
|||||||
|
|
||||||
Congratulations on setting up and running your first script with mini loader! You're now ready to take the next step.
|
Congratulations on setting up and running your first script with mini loader! You're now ready to take the next step.
|
||||||
|
|
||||||
[Next: Setting Up the Server](./setup-server.md)
|
[Next: Setting Up the Server](./setup-server.md)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ mini-loader artifacts ls
|
|||||||
To download a specific artifact:
|
To download a specific artifact:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mini-loader artifacts pull <id> > myfile.txt
|
mini-loader artifacts pull <id> myfile.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace `<id>` with the identifier of the artifact you wish to download.
|
Replace `<id>` with the identifier of the artifact you wish to download.
|
||||||
@@ -67,4 +67,4 @@ Replace `<id>` with the identifier of the artifact you wish to download.
|
|||||||
|
|
||||||
You're now equipped to manage loads, runs, logs, and artifacts using the mini loader CLI. For advanced usage, such as managing secrets, proceed to the next section.
|
You're now equipped to manage loads, runs, logs, and artifacts using the mini loader CLI. For advanced usage, such as managing secrets, proceed to the next section.
|
||||||
|
|
||||||
[Next: Managing Secrets](./managing-secrets.md)
|
[Next: Managing Secrets](./managing-secrets.md)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"@rollup/plugin-sucrase": "^5.0.2",
|
"@rollup/plugin-sucrase": "^5.0.2",
|
||||||
"@trpc/client": "^10.45.0",
|
"@trpc/client": "^10.45.0",
|
||||||
"commander": "^11.1.0",
|
"commander": "^11.1.0",
|
||||||
|
"env-paths": "^3.0.0",
|
||||||
"inquirer": "^9.2.12",
|
"inquirer": "^9.2.12",
|
||||||
"ora": "^8.0.1",
|
"ora": "^8.0.1",
|
||||||
"rollup": "^4.9.4",
|
"rollup": "^4.9.4",
|
||||||
|
|||||||
@@ -2,13 +2,20 @@ import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
|
|||||||
import superjson from 'superjson';
|
import superjson from 'superjson';
|
||||||
import type { Runtime } from '@morten-olsen/mini-loader-server';
|
import type { Runtime } from '@morten-olsen/mini-loader-server';
|
||||||
import type { RootRouter } from '@morten-olsen/mini-loader-server';
|
import type { RootRouter } from '@morten-olsen/mini-loader-server';
|
||||||
|
import { Context } from '../context/context.js';
|
||||||
|
|
||||||
const createClient = () => {
|
const createClient = (context: Context) => {
|
||||||
|
if (!context.host || !context.token) {
|
||||||
|
throw new Error('Not signed in');
|
||||||
|
}
|
||||||
const client = createTRPCProxyClient<RootRouter>({
|
const client = createTRPCProxyClient<RootRouter>({
|
||||||
transformer: superjson,
|
transformer: superjson,
|
||||||
links: [
|
links: [
|
||||||
httpBatchLink({
|
httpBatchLink({
|
||||||
url: 'http://localhost:4500/trpc',
|
url: `${context.host}/trpc`,
|
||||||
|
headers: {
|
||||||
|
authorization: `Bearer ${context.token}`,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const list = new Command('list');
|
const list = new Command('list');
|
||||||
|
|
||||||
@@ -20,8 +21,9 @@ list
|
|||||||
.option('-a, --limit <limit>', 'Limit', '1000')
|
.option('-a, --limit <limit>', 'Limit', '1000')
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
const { runId, loadId, offset, limit } = list.opts();
|
const { runId, loadId, offset, limit } = list.opts();
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
const artifacts = await step('Getting artifacts', async () => {
|
const artifacts = await step('Getting artifacts', async () => {
|
||||||
return await client.artifacts.find.query({
|
return await client.artifacts.find.query({
|
||||||
|
|||||||
32
packages/cli/src/commands/artifacts/artifacts.pull.ts
Normal file
32
packages/cli/src/commands/artifacts/artifacts.pull.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Command } from 'commander';
|
||||||
|
import { createClient } from '../../client/client.js';
|
||||||
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
import { dirname, resolve } from 'path';
|
||||||
|
import { mkdir, writeFile } from 'fs/promises';
|
||||||
|
|
||||||
|
const pull = new Command('pull');
|
||||||
|
|
||||||
|
pull
|
||||||
|
.description('Download artifact')
|
||||||
|
.argument('<artifact-id>', 'Artifact ID')
|
||||||
|
.argument('<file>', 'File to save')
|
||||||
|
.action(async (id, file) => {
|
||||||
|
const context = new Context();
|
||||||
|
const target = resolve(file);
|
||||||
|
const client = await step('Connecting to server', async () => {
|
||||||
|
return createClient(context);
|
||||||
|
});
|
||||||
|
const artifact = await step('Getting artifact', async () => {
|
||||||
|
const result = await client.artifacts.get.query(id);
|
||||||
|
if (!result) {
|
||||||
|
throw new Error('Artifact not found');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
await mkdir(dirname(target), { recursive: true });
|
||||||
|
const data = Buffer.from(artifact.data, 'base64').toString('utf-8');
|
||||||
|
await writeFile(target, data, 'utf-8');
|
||||||
|
});
|
||||||
|
|
||||||
|
export { pull };
|
||||||
59
packages/cli/src/commands/artifacts/artifacts.remove.ts
Normal file
59
packages/cli/src/commands/artifacts/artifacts.remove.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import { Command } from 'commander';
|
||||||
|
import { createClient } from '../../client/client.js';
|
||||||
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
import inquirer from 'inquirer';
|
||||||
|
|
||||||
|
const remove = new Command('remove');
|
||||||
|
|
||||||
|
const toInt = (value?: string) => {
|
||||||
|
if (!value) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return parseInt(value, 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
remove
|
||||||
|
.alias('ls')
|
||||||
|
.description('List logs')
|
||||||
|
.option('-r, --run-id <runId>', 'Run ID')
|
||||||
|
.option('-l, --load-id <loadId>', 'Load ID')
|
||||||
|
.option('-o, --offset <offset>', 'Offset')
|
||||||
|
.option('-a, --limit <limit>', 'Limit', '1000')
|
||||||
|
.action(async () => {
|
||||||
|
const { runId, loadId, offset, limit } = remove.opts();
|
||||||
|
const context = new Context();
|
||||||
|
const client = await step('Connecting to server', async () => {
|
||||||
|
return createClient(context);
|
||||||
|
});
|
||||||
|
const response = await step('Preparing to delete', async () => {
|
||||||
|
return await client.artifacts.prepareRemove.query({
|
||||||
|
runId,
|
||||||
|
loadId,
|
||||||
|
offset: toInt(offset),
|
||||||
|
limit: toInt(limit),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ids.length) {
|
||||||
|
console.log('No logs to delete');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { confirm } = await inquirer.prompt([
|
||||||
|
{
|
||||||
|
type: 'confirm',
|
||||||
|
name: 'confirm',
|
||||||
|
message: `Are you sure you want to delete ${response.ids.length} logs?`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await step('Deleting artifacts', async () => {
|
||||||
|
await client.artifacts.remove.mutate(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export { remove };
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { list } from './artifacts.list.js';
|
import { list } from './artifacts.list.js';
|
||||||
|
import { remove } from './artifacts.remove.js';
|
||||||
|
import { pull } from './artifacts.pull.js';
|
||||||
|
|
||||||
const artifacts = new Command('artifacts');
|
const artifacts = new Command('artifacts');
|
||||||
artifacts.addCommand(list);
|
artifacts.addCommand(list);
|
||||||
|
artifacts.addCommand(remove);
|
||||||
|
artifacts.addCommand(pull);
|
||||||
|
|
||||||
export { artifacts };
|
export { artifacts };
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import inquerer from 'inquirer';
|
import inquerer from 'inquirer';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
import { step } from '../../utils/step.js';
|
||||||
|
|
||||||
const login = new Command('login');
|
const login = new Command('login');
|
||||||
|
|
||||||
login.description('Login to your account');
|
login.description('Login to your account');
|
||||||
login.action(async () => {
|
login.action(async () => {
|
||||||
|
const context = new Context();
|
||||||
const { host, token } = await inquerer.prompt([
|
const { host, token } = await inquerer.prompt([
|
||||||
{
|
{
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'host',
|
name: 'host',
|
||||||
message: 'Enter the host of your server',
|
message: 'Enter the host of your server',
|
||||||
default: 'http://localhost:4500',
|
default: context.host ?? 'http://localhost:4500',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'password',
|
type: 'password',
|
||||||
@@ -19,7 +22,25 @@ login.action(async () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.log(host, token);
|
const healthResponse = await step('Getting auth status', async () => {
|
||||||
|
return await fetch(`${host}/health`, {
|
||||||
|
headers: {
|
||||||
|
authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!healthResponse.ok) {
|
||||||
|
throw new Error('Invalid token');
|
||||||
|
}
|
||||||
|
const health = await healthResponse.json();
|
||||||
|
if (!health.authorized) {
|
||||||
|
throw new Error('Invalid token');
|
||||||
|
}
|
||||||
|
|
||||||
|
await step('Saving login', async () => {
|
||||||
|
await context.saveLogin(host, token);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export { login };
|
export { login };
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const list = new Command('list');
|
const list = new Command('list');
|
||||||
|
|
||||||
@@ -8,11 +9,12 @@ list
|
|||||||
.alias('ls')
|
.alias('ls')
|
||||||
.description('List loads')
|
.description('List loads')
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
const loads = step('Getting data', async () => {
|
const loads = await step('Getting data', async () => {
|
||||||
await client.loads.find.query({});
|
return await client.loads.find.query({});
|
||||||
});
|
});
|
||||||
console.table(loads);
|
console.table(loads);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { resolve } from 'path';
|
|||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { bundle } from '../../bundler/bundler.js';
|
import { bundle } from '../../bundler/bundler.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const push = new Command('push');
|
const push = new Command('push');
|
||||||
|
|
||||||
@@ -14,9 +15,10 @@ push
|
|||||||
.option('-ai, --auto-install', 'Auto install dependencies', false)
|
.option('-ai, --auto-install', 'Auto install dependencies', false)
|
||||||
.action(async (script) => {
|
.action(async (script) => {
|
||||||
const opts = push.opts();
|
const opts = push.opts();
|
||||||
|
const context = new Context();
|
||||||
const location = resolve(script);
|
const location = resolve(script);
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
const code = await step('Bundling', async () => {
|
const code = await step('Bundling', async () => {
|
||||||
return await bundle({ entry: location, autoInstall: opts.autoInstall });
|
return await bundle({ entry: location, autoInstall: opts.autoInstall });
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const list = new Command('list');
|
const list = new Command('list');
|
||||||
|
|
||||||
@@ -22,8 +23,9 @@ list
|
|||||||
.option('-s, --sort <order>', 'Sort', 'desc')
|
.option('-s, --sort <order>', 'Sort', 'desc')
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
const { runId, loadId, severities, offset, limit, order } = list.opts();
|
const { runId, loadId, severities, offset, limit, order } = list.opts();
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
const logs = await step('Getting logs', async () => {
|
const logs = await step('Getting logs', async () => {
|
||||||
return await client.logs.find.query({
|
return await client.logs.find.query({
|
||||||
@@ -35,7 +37,7 @@ list
|
|||||||
order,
|
order,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
console.table(logs.reverse());
|
console.table(logs);
|
||||||
});
|
});
|
||||||
|
|
||||||
export { list };
|
export { list };
|
||||||
|
|||||||
63
packages/cli/src/commands/logs/logs.remove.ts
Normal file
63
packages/cli/src/commands/logs/logs.remove.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { Command } from 'commander';
|
||||||
|
import { createClient } from '../../client/client.js';
|
||||||
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
import inquirer from 'inquirer';
|
||||||
|
|
||||||
|
const remove = new Command('remove');
|
||||||
|
|
||||||
|
const toInt = (value?: string) => {
|
||||||
|
if (!value) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return parseInt(value, 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
remove
|
||||||
|
.alias('ls')
|
||||||
|
.description('List logs')
|
||||||
|
.option('-r, --run-id <runId>', 'Run ID')
|
||||||
|
.option('-l, --load-id <loadId>', 'Load ID')
|
||||||
|
.option('--severities <severities...>', 'Severities')
|
||||||
|
.option('-o, --offset <offset>', 'Offset')
|
||||||
|
.option('-a, --limit <limit>', 'Limit', '1000')
|
||||||
|
.option('-s, --sort <order>', 'Sort', 'desc')
|
||||||
|
.action(async () => {
|
||||||
|
const { runId, loadId, severities, offset, limit, order } = remove.opts();
|
||||||
|
const context = new Context();
|
||||||
|
const client = await step('Connecting to server', async () => {
|
||||||
|
return createClient(context);
|
||||||
|
});
|
||||||
|
const response = await step('Preparing to delete', async () => {
|
||||||
|
return await client.logs.prepareRemove.query({
|
||||||
|
runId,
|
||||||
|
loadId,
|
||||||
|
severities,
|
||||||
|
offset: toInt(offset),
|
||||||
|
limit: toInt(limit),
|
||||||
|
order,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ids.length) {
|
||||||
|
console.log('No logs to delete');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { confirm } = await inquirer.prompt([
|
||||||
|
{
|
||||||
|
type: 'confirm',
|
||||||
|
name: 'confirm',
|
||||||
|
message: `Are you sure you want to delete ${response.ids.length} logs?`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await step('Deleting logs', async () => {
|
||||||
|
await client.logs.remove.mutate(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export { remove };
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { list } from './logs.list.js';
|
import { list } from './logs.list.js';
|
||||||
|
import { remove } from './logs.remove.js';
|
||||||
|
|
||||||
const logs = new Command('logs');
|
const logs = new Command('logs');
|
||||||
logs.addCommand(list);
|
logs.addCommand(list);
|
||||||
|
logs.addCommand(remove);
|
||||||
|
|
||||||
export { logs };
|
export { logs };
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const create = new Command('create');
|
const create = new Command('create');
|
||||||
|
|
||||||
@@ -8,8 +9,9 @@ create
|
|||||||
.description('Create a new run')
|
.description('Create a new run')
|
||||||
.argument('load-id', 'Load ID')
|
.argument('load-id', 'Load ID')
|
||||||
.action(async (loadId) => {
|
.action(async (loadId) => {
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
await step('Creating run', async () => {
|
await step('Creating run', async () => {
|
||||||
await client.runs.create.mutate({ loadId });
|
await client.runs.create.mutate({ loadId });
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const list = new Command('create');
|
const list = new Command('list');
|
||||||
|
|
||||||
list
|
list
|
||||||
.alias('ls')
|
.alias('ls')
|
||||||
.description('Find a run')
|
.description('Find a run')
|
||||||
.argument('[load-id]', 'Load ID')
|
.argument('[load-id]', 'Load ID')
|
||||||
.action(async (loadId) => {
|
.action(async (loadId) => {
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
const runs = await step('Getting runs', async () => {
|
const runs = await step('Getting runs', async () => {
|
||||||
return await client.runs.find.query({ loadId });
|
return await client.runs.find.query({ loadId });
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const list = new Command('list');
|
const list = new Command('list');
|
||||||
|
|
||||||
@@ -18,8 +19,9 @@ list
|
|||||||
.option('-a, --limit <limit>', 'Limit', '1000')
|
.option('-a, --limit <limit>', 'Limit', '1000')
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
const { offset, limit } = list.opts();
|
const { offset, limit } = list.opts();
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
const secrets = await step('Getting secrets', async () => {
|
const secrets = await step('Getting secrets', async () => {
|
||||||
return await client.secrets.find.query({
|
return await client.secrets.find.query({
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const remove = new Command('remove');
|
const remove = new Command('remove');
|
||||||
|
|
||||||
@@ -8,8 +9,9 @@ remove
|
|||||||
.alias('rm')
|
.alias('rm')
|
||||||
.argument('<id>')
|
.argument('<id>')
|
||||||
.action(async (id) => {
|
.action(async (id) => {
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
await step('Removing', async () => {
|
await step('Removing', async () => {
|
||||||
await client.secrets.remove.mutate({
|
await client.secrets.remove.mutate({
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createClient } from '../../client/client.js';
|
import { createClient } from '../../client/client.js';
|
||||||
import { step } from '../../utils/step.js';
|
import { step } from '../../utils/step.js';
|
||||||
|
import { Context } from '../../context/context.js';
|
||||||
|
|
||||||
const set = new Command('set');
|
const set = new Command('set');
|
||||||
|
|
||||||
@@ -8,8 +9,9 @@ set
|
|||||||
.argument('<id>')
|
.argument('<id>')
|
||||||
.argument('[value]')
|
.argument('[value]')
|
||||||
.action(async (id, value) => {
|
.action(async (id, value) => {
|
||||||
|
const context = new Context();
|
||||||
const client = await step('Connecting to server', async () => {
|
const client = await step('Connecting to server', async () => {
|
||||||
return createClient();
|
return createClient(context);
|
||||||
});
|
});
|
||||||
await step('Setting secret', async () => {
|
await step('Setting secret', async () => {
|
||||||
await client.secrets.set.mutate({
|
await client.secrets.set.mutate({
|
||||||
|
|||||||
50
packages/cli/src/context/context.ts
Normal file
50
packages/cli/src/context/context.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import envPaths from 'env-paths';
|
||||||
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||||
|
import { mkdir } from 'fs/promises';
|
||||||
|
import { dirname } from 'path';
|
||||||
|
|
||||||
|
type ContextValues = {
|
||||||
|
host: string;
|
||||||
|
token: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Context {
|
||||||
|
#location: string;
|
||||||
|
#config?: ContextValues;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
const paths = envPaths('dws');
|
||||||
|
this.#location = paths.config;
|
||||||
|
if (existsSync(this.#location)) {
|
||||||
|
this.#config = JSON.parse(readFileSync(this.#location, 'utf-8'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public get host() {
|
||||||
|
return this.#config?.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get token() {
|
||||||
|
return this.#config?.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveLogin = (host: string, token: string) => {
|
||||||
|
this.#config = {
|
||||||
|
...(this.#config || {}),
|
||||||
|
host,
|
||||||
|
token,
|
||||||
|
};
|
||||||
|
this.save();
|
||||||
|
};
|
||||||
|
|
||||||
|
public save = async () => {
|
||||||
|
if (!this.#config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const json = JSON.stringify(this.#config);
|
||||||
|
mkdir(dirname(this.#location), { recursive: true });
|
||||||
|
writeFileSync(this.#location, json);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Context };
|
||||||
@@ -4,10 +4,10 @@ const step = async <T>(message: string, fn: () => Promise<T>): Promise<T> => {
|
|||||||
const spinner = ora(message).start();
|
const spinner = ora(message).start();
|
||||||
try {
|
try {
|
||||||
const result = await fn();
|
const result = await fn();
|
||||||
spinner.succeed();
|
await spinner.succeed();
|
||||||
return result;
|
return result;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
spinner.fail();
|
await spinner.fail();
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { artifacts, logger } from '@morten-olsen/mini-loader';
|
import { artifacts, logger } from '@morten-olsen/mini-loader';
|
||||||
|
|
||||||
logger.info('Hello world');
|
const run = async () => {
|
||||||
|
await logger.info('Hello world');
|
||||||
|
await artifacts.create('foo', 'bar');
|
||||||
|
};
|
||||||
|
|
||||||
artifacts.create('foo', 'bar');
|
run();
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ type ArtifactCreateEvent = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const create = (name: string, data: Buffer | string) => {
|
const create = async (name: string, data: Buffer | string) => {
|
||||||
send({
|
await send({
|
||||||
type: 'artifact:create',
|
type: 'artifact:create',
|
||||||
payload: {
|
payload: {
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
import { workerData } from 'worker_threads';
|
import { existsSync } from 'fs';
|
||||||
|
import { readFile } from 'fs/promises';
|
||||||
|
|
||||||
const get = <T>() => {
|
const path = process.env.INPUT_PATH;
|
||||||
return workerData as T;
|
const hasInput = path ? existsSync(path) : false;
|
||||||
|
|
||||||
|
const get = () => {
|
||||||
|
if (!hasInput || !path) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return readFile(path, 'utf-8');
|
||||||
};
|
};
|
||||||
|
|
||||||
const input = {
|
const input = {
|
||||||
|
|||||||
@@ -9,31 +9,31 @@ type LoggerEvent = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendLog = (event: LoggerEvent['payload']) => {
|
const sendLog = async (event: LoggerEvent['payload']) => {
|
||||||
send({
|
await send({
|
||||||
type: 'log',
|
type: 'log',
|
||||||
payload: event,
|
payload: event,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const info = (message: string, data?: unknown) => {
|
const info = async (message: string, data?: unknown) => {
|
||||||
sendLog({
|
await sendLog({
|
||||||
severity: 'info',
|
severity: 'info',
|
||||||
message,
|
message,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const warn = (message: string, data?: unknown) => {
|
const warn = async (message: string, data?: unknown) => {
|
||||||
sendLog({
|
await sendLog({
|
||||||
severity: 'warning',
|
severity: 'warning',
|
||||||
message,
|
message,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const error = (message: string, data?: unknown) => {
|
const error = async (message: string, data?: unknown) => {
|
||||||
sendLog({
|
await sendLog({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
message,
|
message,
|
||||||
data,
|
data,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { workerData } from 'worker_threads';
|
const secretData = JSON.parse(process.env.SECRETS || '{}');
|
||||||
|
|
||||||
const get = (id: string) => {
|
const get = (id: string) => {
|
||||||
const items = workerData?.secrets ?? {};
|
return secretData[id];
|
||||||
return items[id];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const secrets = {
|
const secrets = {
|
||||||
|
|||||||
@@ -1,8 +1,28 @@
|
|||||||
import { parentPort } from 'worker_threads';
|
import { Socket, createConnection } from 'net';
|
||||||
|
|
||||||
const send = (data: any) => {
|
const connect = () =>
|
||||||
const cleaned = JSON.parse(JSON.stringify(data));
|
new Promise<Socket>((resolve, reject) => {
|
||||||
parentPort?.postMessage(cleaned);
|
const current = createConnection(process.env.HOST_SOCKET!);
|
||||||
};
|
|
||||||
|
current.on('connect', () => {
|
||||||
|
resolve(current);
|
||||||
|
});
|
||||||
|
current.on('error', (error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const send = async (data: any) =>
|
||||||
|
new Promise<void>(async (resolve, reject) => {
|
||||||
|
const connection = await connect();
|
||||||
|
const cleaned = JSON.parse(JSON.stringify(data));
|
||||||
|
connection.write(JSON.stringify(cleaned), 'utf-8', (err) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
export { send };
|
export { send };
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@morten-olsen/mini-loader-configs": "workspace:^",
|
|
||||||
"@morten-olsen/mini-loader": "workspace:^",
|
"@morten-olsen/mini-loader": "workspace:^",
|
||||||
|
"@morten-olsen/mini-loader-configs": "workspace:^",
|
||||||
"@types/node": "^20.10.8",
|
"@types/node": "^20.10.8",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"eventemitter3": "^5.0.1"
|
"eventemitter3": "^5.0.1",
|
||||||
|
"nanoid": "^5.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
import { Worker } from 'worker_threads';
|
import { Worker } from 'worker_threads';
|
||||||
|
import os from 'os';
|
||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
import { Event } from '@morten-olsen/mini-loader';
|
import { Event } from '@morten-olsen/mini-loader';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { createServer } from 'http';
|
||||||
|
import { nanoid } from 'nanoid';
|
||||||
|
import { chmod, mkdir, rm, writeFile } from 'fs/promises';
|
||||||
|
|
||||||
type RunEvents = {
|
type RunEvents = {
|
||||||
message: (event: Event) => void;
|
message: (event: Event) => void;
|
||||||
@@ -10,29 +15,75 @@ type RunEvents = {
|
|||||||
|
|
||||||
type RunOptions = {
|
type RunOptions = {
|
||||||
script: string;
|
script: string;
|
||||||
input?: unknown;
|
input?: Buffer | string;
|
||||||
secrets?: Record<string, string>;
|
secrets?: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const run = async ({ script, input, secrets }: RunOptions) => {
|
const run = async ({ script, input, secrets }: RunOptions) => {
|
||||||
|
const dataDir = join(os.tmpdir(), 'mini-loader', nanoid());
|
||||||
|
await mkdir(dataDir, { recursive: true });
|
||||||
|
await chmod(dataDir, 0o700);
|
||||||
|
const hostSocket = join(dataDir, 'host');
|
||||||
|
const server = createServer();
|
||||||
|
const inputLocation = join(dataDir, 'input');
|
||||||
|
|
||||||
|
if (input) {
|
||||||
|
await writeFile(inputLocation, input);
|
||||||
|
}
|
||||||
|
|
||||||
const emitter = new EventEmitter<RunEvents>();
|
const emitter = new EventEmitter<RunEvents>();
|
||||||
|
|
||||||
|
server.on('connection', (socket) => {
|
||||||
|
socket.on('data', (data) => {
|
||||||
|
const message = JSON.parse(data.toString());
|
||||||
|
emitter.emit('message', message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
server.listen(hostSocket);
|
||||||
|
|
||||||
const worker = new Worker(script, {
|
const worker = new Worker(script, {
|
||||||
eval: true,
|
eval: true,
|
||||||
env: secrets,
|
stdin: false,
|
||||||
|
stdout: false,
|
||||||
|
stderr: false,
|
||||||
|
env: {
|
||||||
|
HOST_SOCKET: hostSocket,
|
||||||
|
SECRETS: JSON.stringify(secrets),
|
||||||
|
INPUT_PATH: inputLocation,
|
||||||
|
},
|
||||||
workerData: {
|
workerData: {
|
||||||
input,
|
input,
|
||||||
secrets,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const promise = new Promise<void>((resolve, reject) => {
|
worker.stdout?.on('data', (data) => {
|
||||||
worker.on('message', (message: Event) => {
|
emitter.emit('message', {
|
||||||
emitter.emit('message', message);
|
type: 'log',
|
||||||
|
payload: {
|
||||||
|
severity: 'info',
|
||||||
|
message: data.toString(),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
worker.on('exit', () => {
|
});
|
||||||
|
|
||||||
|
worker.stderr?.on('data', (data) => {
|
||||||
|
emitter.emit('message', {
|
||||||
|
type: 'log',
|
||||||
|
payload: {
|
||||||
|
severity: 'error',
|
||||||
|
message: data.toString(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const promise = new Promise<void>((resolve, reject) => {
|
||||||
|
worker.on('exit', async () => {
|
||||||
|
server.close();
|
||||||
|
await rm(dataDir, { recursive: true, force: true });
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
worker.on('error', (error) => {
|
worker.on('error', async (error) => {
|
||||||
|
server.close();
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,5 +27,9 @@ program.addCommand(createToken);
|
|||||||
|
|
||||||
await program.parseAsync(process.argv);
|
await program.parseAsync(process.argv);
|
||||||
|
|
||||||
|
process.on('unhandledRejection', (reason, p) => {
|
||||||
|
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||||
|
});
|
||||||
|
|
||||||
export type { Runtime } from './runtime/runtime.js';
|
export type { Runtime } from './runtime/runtime.js';
|
||||||
export type { RootRouter } from './router/router.js';
|
export type { RootRouter } from './router/router.js';
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ class ArtifactRepo extends EventEmitter<ArtifactRepoEvents> {
|
|||||||
this.#options = options;
|
this.#options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get = async (id: string) => {
|
||||||
|
const { database } = this.#options;
|
||||||
|
const db = await database.instance;
|
||||||
|
const result = await db('artifacts').where({ id }).first();
|
||||||
|
return result || null;
|
||||||
|
};
|
||||||
|
|
||||||
public add = async (options: AddArtifactOptions) => {
|
public add = async (options: AddArtifactOptions) => {
|
||||||
const { database } = this.#options;
|
const { database } = this.#options;
|
||||||
const db = await database.instance;
|
const db = await database.instance;
|
||||||
@@ -59,8 +66,9 @@ class ArtifactRepo extends EventEmitter<ArtifactRepoEvents> {
|
|||||||
query.limit(options.limit);
|
query.limit(options.limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = await query;
|
const result = await query;
|
||||||
const token = ids.map((id) => Buffer.from(id.id).toString('base64')).join('|');
|
const ids = result.map((row) => row.id);
|
||||||
|
const token = ids.map((id) => Buffer.from(id).toString('base64')).join('|');
|
||||||
const hash = createHash('sha256').update(token).digest('hex');
|
const hash = createHash('sha256').update(token).digest('hex');
|
||||||
return {
|
return {
|
||||||
ids,
|
ids,
|
||||||
|
|||||||
@@ -56,8 +56,9 @@ class LogRepo extends EventEmitter<LogRepoEvents> {
|
|||||||
query.whereIn('severity', options.severities);
|
query.whereIn('severity', options.severities);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = await query;
|
const result = await query;
|
||||||
const token = ids.map((id) => Buffer.from(id.id).toString('base64')).join('|');
|
const ids = result.map((row) => row.id);
|
||||||
|
const token = ids.map((id) => Buffer.from(id).toString('base64')).join('|');
|
||||||
const hash = createHash('sha256').update(token).digest('hex');
|
const hash = createHash('sha256').update(token).digest('hex');
|
||||||
return {
|
return {
|
||||||
ids,
|
ids,
|
||||||
|
|||||||
@@ -11,12 +11,21 @@ const find = publicProcedure.input(findArtifactsSchema).query(async ({ input, ct
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const get = publicProcedure.input(z.string()).query(async ({ input, ctx }) => {
|
||||||
|
const { runtime } = ctx;
|
||||||
|
const { repos } = runtime;
|
||||||
|
const { artifacts } = repos;
|
||||||
|
|
||||||
|
const result = await artifacts.get(input);
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
const prepareRemove = publicProcedure.input(findArtifactsSchema).query(async ({ input, ctx }) => {
|
const prepareRemove = publicProcedure.input(findArtifactsSchema).query(async ({ input, ctx }) => {
|
||||||
const { runtime } = ctx;
|
const { runtime } = ctx;
|
||||||
const { repos } = runtime;
|
const { repos } = runtime;
|
||||||
const { artifacts } = repos;
|
const { artifacts } = repos;
|
||||||
|
|
||||||
await artifacts.prepareRemove(input);
|
return await artifacts.prepareRemove(input);
|
||||||
});
|
});
|
||||||
|
|
||||||
const remove = publicProcedure
|
const remove = publicProcedure
|
||||||
@@ -35,6 +44,7 @@ const remove = publicProcedure
|
|||||||
});
|
});
|
||||||
|
|
||||||
const artifactsRouter = router({
|
const artifactsRouter = router({
|
||||||
|
get,
|
||||||
find,
|
find,
|
||||||
remove,
|
remove,
|
||||||
prepareRemove,
|
prepareRemove,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const prepareRemove = publicProcedure.input(findLogsSchema).query(async ({ input
|
|||||||
const { repos } = runtime;
|
const { repos } = runtime;
|
||||||
const { logs } = repos;
|
const { logs } = repos;
|
||||||
|
|
||||||
await logs.prepareRemove(input);
|
return await logs.prepareRemove(input);
|
||||||
});
|
});
|
||||||
|
|
||||||
const remove = publicProcedure
|
const remove = publicProcedure
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ const createContext = async ({ runtime }: ContextOptions) => {
|
|||||||
if (!authorization) {
|
if (!authorization) {
|
||||||
throw new Error('No authorization header');
|
throw new Error('No authorization header');
|
||||||
}
|
}
|
||||||
await auth.validateToken(authorization);
|
const [, token] = authorization.split(' ');
|
||||||
|
await auth.validateToken(token);
|
||||||
return {
|
return {
|
||||||
runtime,
|
runtime,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class RunnerInstance extends EventEmitter<RunnerInstanceEvents> {
|
|||||||
const { runs, secrets } = repos;
|
const { runs, secrets } = repos;
|
||||||
try {
|
try {
|
||||||
const { script: scriptHash, input } = await runs.getById(id);
|
const { script: scriptHash, input } = await runs.getById(id);
|
||||||
const scriptLocation = resolve(config.files.location, 'script', `${scriptHash}.js`);
|
const scriptLocation = resolve(config.files.location, 'scripts', `${scriptHash}.js`);
|
||||||
const script = await readFile(scriptLocation, 'utf-8');
|
const script = await readFile(scriptLocation, 'utf-8');
|
||||||
const allSecrets = await secrets.getAll();
|
const allSecrets = await secrets.getAll();
|
||||||
await runs.started(id);
|
await runs.started(id);
|
||||||
|
|||||||
@@ -10,6 +10,19 @@ const createServer = async (runtime: Runtime) => {
|
|||||||
return { hello: 'world' };
|
return { hello: 'world' };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.get('/health', async (req) => {
|
||||||
|
let authorized = false;
|
||||||
|
try {
|
||||||
|
const { authorization } = req.headers;
|
||||||
|
if (authorization) {
|
||||||
|
const [, token] = authorization.split(' ');
|
||||||
|
await runtime.auth.validateToken(token);
|
||||||
|
authorized = true;
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
return { authorized, status: 'ok' };
|
||||||
|
});
|
||||||
|
|
||||||
server.register(fastifyTRPCPlugin, {
|
server.register(fastifyTRPCPlugin, {
|
||||||
prefix: '/trpc',
|
prefix: '/trpc',
|
||||||
trpcOptions: {
|
trpcOptions: {
|
||||||
|
|||||||
11
pnpm-lock.yaml
generated
11
pnpm-lock.yaml
generated
@@ -60,6 +60,9 @@ importers:
|
|||||||
commander:
|
commander:
|
||||||
specifier: ^11.1.0
|
specifier: ^11.1.0
|
||||||
version: 11.1.0
|
version: 11.1.0
|
||||||
|
env-paths:
|
||||||
|
specifier: ^3.0.0
|
||||||
|
version: 3.0.0
|
||||||
inquirer:
|
inquirer:
|
||||||
specifier: ^9.2.12
|
specifier: ^9.2.12
|
||||||
version: 9.2.12
|
version: 9.2.12
|
||||||
@@ -132,6 +135,9 @@ importers:
|
|||||||
eventemitter3:
|
eventemitter3:
|
||||||
specifier: ^5.0.1
|
specifier: ^5.0.1
|
||||||
version: 5.0.1
|
version: 5.0.1
|
||||||
|
nanoid:
|
||||||
|
specifier: ^5.0.4
|
||||||
|
version: 5.0.4
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@morten-olsen/mini-loader':
|
'@morten-olsen/mini-loader':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
@@ -2206,6 +2212,11 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
/env-paths@3.0.0:
|
||||||
|
resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==}
|
||||||
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/err-code@2.0.3:
|
/err-code@2.0.3:
|
||||||
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
|
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
|
|||||||
Reference in New Issue
Block a user