@concavejs/runtime-bun 0.0.1-alpha.4
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.
Potentially problematic release.
This version of @concavejs/runtime-bun might be problematic. Click here for more details.
- package/README.md +81 -0
- package/dist/index.js +46445 -0
- package/dist/server/index.js +44533 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @concavejs/runtime-bun
|
|
2
|
+
|
|
3
|
+
Library-first Bun runtime for Concave.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @concavejs/runtime-bun
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createConcave } from "@concavejs/runtime-bun";
|
|
15
|
+
|
|
16
|
+
const server = createConcave({
|
|
17
|
+
convexDir: "./convex",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
await server.listen({ port: 3000 });
|
|
21
|
+
console.log(server.url);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Custom adapters
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createConcave, SqliteDocStore, FsBlobStore } from "@concavejs/runtime-bun";
|
|
28
|
+
|
|
29
|
+
const server = createConcave({
|
|
30
|
+
convexDir: "./convex",
|
|
31
|
+
docstore: new SqliteDocStore("./data/db.sqlite"),
|
|
32
|
+
blobstore: new FsBlobStore("./data/storage"),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await server.listen({ port: 3000, hostname: "127.0.0.1" });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You can also pass builders:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const server = createConcave({
|
|
42
|
+
convexDir: "./convex",
|
|
43
|
+
docstore: ({ runtime }) => {
|
|
44
|
+
if (runtime !== "bun") throw new Error("Unexpected runtime");
|
|
45
|
+
return new SqliteDocStore("./data/db.sqlite");
|
|
46
|
+
},
|
|
47
|
+
blobstore: () => new FsBlobStore("./data/storage"),
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Module loading
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const server = createConcave({
|
|
55
|
+
modules: {
|
|
56
|
+
"messages.ts": () => import("./convex/messages.ts"),
|
|
57
|
+
"tasks.ts": () => import("./convex/tasks.ts"),
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`modules` also accepts a single loader function or an array of loader sources.
|
|
63
|
+
|
|
64
|
+
## API
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
type ConcaveOptions = {
|
|
68
|
+
convexDir?: string;
|
|
69
|
+
docstore?: DocStore | ((context: { runtime: "bun"; options: Readonly<ConcaveOptions> }) => DocStore);
|
|
70
|
+
blobstore?: BlobStore | ((context: { runtime: "bun"; options: Readonly<ConcaveOptions> }) => BlobStore);
|
|
71
|
+
schema?: "auto" | "skip";
|
|
72
|
+
modules?: ModuleLoader | Record<string, ModuleRegistryEntry> | Array<ModuleLoader | Record<string, ModuleRegistryEntry>>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type Server = {
|
|
76
|
+
listen(options?: { port?: number; hostname?: string }): Promise<void>;
|
|
77
|
+
close(): Promise<void>;
|
|
78
|
+
readonly url: string;
|
|
79
|
+
readonly port: number;
|
|
80
|
+
};
|
|
81
|
+
```
|