@bbki.ng/backend 0.3.20 → 0.3.21
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bbki.ng/backend",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@simplewebauthn/server": "13.2.2",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prettier": "^3.2.0",
|
|
23
23
|
"typescript": "^5.3.0",
|
|
24
24
|
"wrangler": "^4.58.0",
|
|
25
|
-
"@bbki.ng/config": "
|
|
25
|
+
"@bbki.ng/config": "2.0.1"
|
|
26
26
|
},
|
|
27
27
|
"prettier": "@bbki.ng/config/prettier",
|
|
28
28
|
"scripts": {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
2
|
|
|
3
|
+
import { safeParseJSON } from '../../utils';
|
|
4
|
+
|
|
3
5
|
export const listPlugins = async (c: Context) => {
|
|
4
6
|
try {
|
|
5
7
|
const { results } = await c.env.DB.prepare(
|
|
@@ -9,7 +11,12 @@ export const listPlugins = async (c: Context) => {
|
|
|
9
11
|
|
|
10
12
|
return c.json({
|
|
11
13
|
status: 'success',
|
|
12
|
-
data: results
|
|
14
|
+
data: results.map((p: { dependencies: string }) => ({
|
|
15
|
+
...p,
|
|
16
|
+
dependencies:
|
|
17
|
+
safeParseJSON<{ dependencies: string[] }>(p.dependencies, { dependencies: [] })
|
|
18
|
+
?.dependencies || [],
|
|
19
|
+
})),
|
|
13
20
|
});
|
|
14
21
|
} catch (error: Error | unknown) {
|
|
15
22
|
return c.json(
|
|
@@ -6,9 +6,11 @@ export const listStreaming = async (c: Context) => {
|
|
|
6
6
|
// 'before' - fetch records older than this ID (for pagination / next page)
|
|
7
7
|
// 'after' - fetch records newer than this ID (for polling / new messages)
|
|
8
8
|
// 'offset' - number of records to fetch (default: 8, max: 100)
|
|
9
|
+
// 'type' - optional filter by type (note, article, link, image, ci)
|
|
9
10
|
const before = c.req.query('before');
|
|
10
11
|
const after = c.req.query('after');
|
|
11
12
|
const offset = Math.min(parseInt(c.req.query('offset') || '8', 10), 100);
|
|
13
|
+
const type = c.req.query('type');
|
|
12
14
|
|
|
13
15
|
let results;
|
|
14
16
|
|
|
@@ -18,6 +20,7 @@ export const listStreaming = async (c: Context) => {
|
|
|
18
20
|
`SELECT id, author, content, type, created_at as createdAt
|
|
19
21
|
FROM streaming
|
|
20
22
|
WHERE created_at < (SELECT created_at FROM streaming WHERE id = ?)
|
|
23
|
+
${type ? 'AND type = ?' : ''}
|
|
21
24
|
ORDER BY created_at DESC
|
|
22
25
|
LIMIT ?`
|
|
23
26
|
)
|
|
@@ -31,6 +34,7 @@ export const listStreaming = async (c: Context) => {
|
|
|
31
34
|
`SELECT id, author, content, type, created_at as createdAt
|
|
32
35
|
FROM streaming
|
|
33
36
|
WHERE created_at > (SELECT created_at FROM streaming WHERE id = ?)
|
|
37
|
+
${type ? 'AND type = ?' : ''}
|
|
34
38
|
ORDER BY created_at ASC
|
|
35
39
|
LIMIT ?`
|
|
36
40
|
)
|
|
@@ -42,6 +46,7 @@ export const listStreaming = async (c: Context) => {
|
|
|
42
46
|
const { results: recentResults } = await c.env.DB.prepare(
|
|
43
47
|
`SELECT id, author, content, type, created_at as createdAt
|
|
44
48
|
FROM streaming
|
|
49
|
+
${type ? 'WHERE type = ?' : ''}
|
|
45
50
|
ORDER BY created_at DESC
|
|
46
51
|
LIMIT ?`
|
|
47
52
|
)
|
package/src/index.ts
CHANGED