miqro.js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +85 -0
  2. package/dist/cli.js +3164 -0
  3. package/dist/index.js +3033 -0
  4. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Miqro
2
+
3
+ A minimal, high-performance microservice engine built on [Bun](https://bun.sh/) and [Hono](https://hono.dev/).
4
+ Designed to process webhooks and run scheduled cron jobs utilizing file-based workflow configurations.
5
+
6
+ ## Quick Start
7
+
8
+ Create a new project automatically in your current directory:
9
+ ```bash
10
+ bunx miqro init
11
+ ```
12
+
13
+ This creates a `miqro.config.ts` and a `workflows/` directory.
14
+
15
+ Start the development server with hot-reloading:
16
+ ```bash
17
+ bunx miqro dev
18
+ ```
19
+
20
+ ## Commands
21
+
22
+ - `miqro init`: Scaffolds `miqro.config.ts` and a `workflows/` directory.
23
+ - `miqro dev`: Starts the engine in development mode with hot-reloading (`bun --watch`).
24
+ - `miqro start`: Starts the engine dynamically for production.
25
+ - `miqro build`: Compiles your project and workflows into a single standalone file at `./dist/index.js`.
26
+
27
+ ## Configuration
28
+
29
+ The engine is configured via `miqro.config.ts` in your project root:
30
+
31
+ ```typescript
32
+ // miqro.config.ts
33
+ import type { MiqroConfig } from 'miqro.js';
34
+
35
+ export default {
36
+ port: 3000,
37
+ workflowsDir: './workflows', // Directory containing workflows
38
+ } satisfies MiqroConfig;
39
+ ```
40
+
41
+ ## Workflows
42
+
43
+ Workflows belong in the directory specified by `workflowsDir`.
44
+ Miqro automatically discovers `.ts` or `.js` module exports and registers them.
45
+
46
+ ### Webhook Workflow
47
+
48
+ Webhooks respond to `POST /webhook?workflowId={id}`. Authentication supports `none`, `apiKey`, or `bearer`.
49
+
50
+ ```typescript
51
+ // workflows/example-webhook.ts
52
+ import type { Workflow } from 'miqro.js';
53
+
54
+ export default {
55
+ config: {
56
+ id: 'process-payment',
57
+ name: 'Payment Webhook',
58
+ auth: { type: 'apiKey', key: process.env.API_KEY || 'secret' }
59
+ },
60
+ execute: async (payload: any) => {
61
+ console.log(`Received payload!`, payload);
62
+ }
63
+ } satisfies Workflow;
64
+ ```
65
+
66
+ ### Scheduled Cron Workflow
67
+
68
+ If a workflow config provides a `schedule` property (a valid Cron string), it will be executed automatically.
69
+
70
+ ```typescript
71
+ // workflows/example-cron.ts
72
+ import type { Workflow } from 'miqro.js';
73
+
74
+ export default {
75
+ config: {
76
+ id: 'hourly-sync',
77
+ name: 'Sync Database',
78
+ auth: { type: 'none' }, // Auth is required but ignored for cron tasks
79
+ schedule: '0 * * * *' // Runs every hour
80
+ },
81
+ execute: async () => {
82
+ console.log(`Running background sync...`);
83
+ }
84
+ } satisfies Workflow;
85
+ ```