@respectify/astro 1.0.0 → 1.0.1
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.
- package/README.md +4 -2
- package/package.json +2 -1
- package/src/define-runtime.ts +23 -0
- package/src/index.ts +5 -14
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ The store, and any functions, live in a module that runs inside your server bund
|
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
72
|
// src/respectify.runtime.ts
|
|
73
|
-
import { defineRespectifyRuntime } from '@respectify/astro';
|
|
73
|
+
import { defineRespectifyRuntime } from '@respectify/astro/runtime';
|
|
74
74
|
import { createPostgresCommentStore } from '@respectify/astro/postgres';
|
|
75
75
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
76
76
|
import { Pool } from 'pg';
|
|
@@ -85,6 +85,8 @@ export default defineRespectifyRuntime({
|
|
|
85
85
|
});
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
Import `defineRespectifyRuntime` from `@respectify/astro/runtime`, not `@respectify/astro`: the main entry is the integration and imports Astro's config, which bundling adapters such as Vercel can't put in a server function.
|
|
89
|
+
|
|
88
90
|
For SQLite, use `createSqliteCommentStore(db)` from `@respectify/astro/sqlite` with your Drizzle SQLite database (for libSQL/Turso, `drizzle({ client: createClient({ url, authToken }) })` from `drizzle-orm/libsql`).
|
|
89
91
|
|
|
90
92
|
### 4. Add the integration
|
|
@@ -366,7 +368,7 @@ The SQLite store's default table is exactly the `Comment` table Astro DB created
|
|
|
366
368
|
|
|
367
369
|
```ts
|
|
368
370
|
// src/respectify.runtime.ts
|
|
369
|
-
import { defineRespectifyRuntime } from '@respectify/astro';
|
|
371
|
+
import { defineRespectifyRuntime } from '@respectify/astro/runtime';
|
|
370
372
|
import { createSqliteCommentStore } from '@respectify/astro/sqlite';
|
|
371
373
|
import { createClient } from '@libsql/client';
|
|
372
374
|
import { drizzle } from 'drizzle-orm/libsql';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@respectify/astro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Respectify-powered commenting for Astro \u2014 AI moderation, spam filtering, and beautiful UX out of the box.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"exports": {
|
|
31
31
|
".": "./src/index.ts",
|
|
32
|
+
"./runtime": "./src/define-runtime.ts",
|
|
32
33
|
"./actions": "./src/actions.ts",
|
|
33
34
|
"./credentials": "./src/credentials.ts",
|
|
34
35
|
"./routes/comments": "./src/routes/comments.ts",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RespectifyRuntime } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Define the runtime module named by `respectify({ runtime })`. Its default export must be
|
|
5
|
+
* the value this returns:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // src/respectify.runtime.ts
|
|
9
|
+
* import { defineRespectifyRuntime } from '@respectify/astro/runtime';
|
|
10
|
+
* import { createSqliteCommentStore } from '@respectify/astro/sqlite';
|
|
11
|
+
*
|
|
12
|
+
* export default defineRespectifyRuntime({ store: createSqliteCommentStore(db) });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* This entry is bundled into the server, so it must never value-import `astro`, `astro/*`
|
|
16
|
+
* or `astro:*`: bundling adapters such as Vercel cannot put Astro's compiler in a function.
|
|
17
|
+
*/
|
|
18
|
+
export function defineRespectifyRuntime(runtime: RespectifyRuntime): RespectifyRuntime {
|
|
19
|
+
return runtime;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type { RespectifyRuntime } from './types';
|
|
23
|
+
export type { ICommentStore, CommentRecord, NewComment, PublicComment } from './store/types';
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import type { AstroIntegration } from 'astro';
|
|
4
4
|
import { envField } from 'astro/config';
|
|
5
5
|
import { parseIntegrationOptions, toResolvedIntegrationOptions } from './options';
|
|
6
|
-
import type { RespectifyIntegrationOptions
|
|
6
|
+
import type { RespectifyIntegrationOptions } from './types';
|
|
7
7
|
|
|
8
8
|
const OPTIONS_MODULE_ID = 'virtual:@respectify/astro/options';
|
|
9
9
|
const RUNTIME_MODULE_ID = 'virtual:@respectify/astro/runtime';
|
|
@@ -94,20 +94,11 @@ export default function respectify(userOptions: RespectifyIntegrationOptions): A
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
* the
|
|
99
|
-
*
|
|
100
|
-
* ```ts
|
|
101
|
-
* // src/respectify.runtime.ts
|
|
102
|
-
* import { defineRespectifyRuntime } from '@respectify/astro';
|
|
103
|
-
* import { createSqliteCommentStore } from '@respectify/astro/sqlite';
|
|
104
|
-
*
|
|
105
|
-
* export default defineRespectifyRuntime({ store: createSqliteCommentStore(db) });
|
|
106
|
-
* ```
|
|
97
|
+
* Re-exported for compatibility. Runtime modules should import `defineRespectifyRuntime` from
|
|
98
|
+
* `@respectify/astro/runtime`: this entry is the integration and imports `astro/config`, which
|
|
99
|
+
* bundling adapters such as Vercel cannot put in a server function.
|
|
107
100
|
*/
|
|
108
|
-
export
|
|
109
|
-
return runtime;
|
|
110
|
-
}
|
|
101
|
+
export { defineRespectifyRuntime } from './define-runtime';
|
|
111
102
|
|
|
112
103
|
export type {
|
|
113
104
|
RespectifyIntegrationOptions,
|