@devmoods/postgres-admin 0.2.0 → 0.3.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.
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { createPostgres } from '@devmoods/express-extras';
|
|
|
3
3
|
|
|
4
4
|
interface AdminRouterOptions {
|
|
5
5
|
postgres: ReturnType<typeof createPostgres>;
|
|
6
|
+
basename?: string;
|
|
6
7
|
}
|
|
7
|
-
declare function createRouter({ postgres }: AdminRouterOptions): express_serve_static_core.Router;
|
|
8
|
+
declare function createRouter({ postgres, basename, }: AdminRouterOptions): express_serve_static_core.Router;
|
|
8
9
|
|
|
9
10
|
declare const admin: typeof createRouter;
|
|
10
11
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/api/app.ts
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
2
3
|
import * as path from "node:path";
|
|
3
4
|
import {
|
|
4
5
|
BadRequest,
|
|
6
|
+
generateCsrfToken,
|
|
5
7
|
joinStatements,
|
|
6
8
|
route,
|
|
7
9
|
sql,
|
|
@@ -10,7 +12,6 @@ import {
|
|
|
10
12
|
import express from "express";
|
|
11
13
|
|
|
12
14
|
// src/api/structure.ts
|
|
13
|
-
import "@bitiforms/react";
|
|
14
15
|
import { NotFound, readEnv } from "@devmoods/express-extras";
|
|
15
16
|
import "pg-structure";
|
|
16
17
|
import { pgStructure } from "pg-structure/dist/main.js";
|
|
@@ -210,7 +211,10 @@ function queryParamToArray(queryParam) {
|
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
// src/api/app.ts
|
|
213
|
-
function createRouter({
|
|
214
|
+
function createRouter({
|
|
215
|
+
postgres,
|
|
216
|
+
basename = "/admin"
|
|
217
|
+
}) {
|
|
214
218
|
const app = express.Router();
|
|
215
219
|
app.get(
|
|
216
220
|
"/api/tables",
|
|
@@ -425,13 +429,16 @@ function createRouter({ postgres }) {
|
|
|
425
429
|
path.resolve("node_modules/@devmoods/postgres-admin/dist/client")
|
|
426
430
|
)
|
|
427
431
|
);
|
|
428
|
-
app.get(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
432
|
+
app.get(
|
|
433
|
+
"*",
|
|
434
|
+
route(async (req, res) => {
|
|
435
|
+
const content = await fs.readFile(
|
|
436
|
+
"node_modules/@devmoods/postgres-admin/dist/client/_index.html",
|
|
437
|
+
"utf-8"
|
|
438
|
+
);
|
|
439
|
+
return content.replace("{{ csrf_token }}", generateCsrfToken(req, res)).replace(/{{ basename }}/g, basename.slice(1));
|
|
440
|
+
})
|
|
441
|
+
);
|
|
435
442
|
return app;
|
|
436
443
|
}
|
|
437
444
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devmoods/postgres-admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"build:server": "tsup-node src/index.ts --format esm --dts",
|
|
13
|
+
"build:client": "tsc --noEmit && vite build",
|
|
14
|
+
"build": "pnpm run build:server && pnpm run build:client",
|
|
15
|
+
"test": "vitest"
|
|
16
|
+
},
|
|
10
17
|
"dependencies": {
|
|
11
|
-
"@devmoods/express-extras": "^0.42.
|
|
18
|
+
"@devmoods/express-extras": "^0.42.1",
|
|
12
19
|
"pg-structure": "^7.15.3"
|
|
13
20
|
},
|
|
14
21
|
"devDependencies": {
|
|
@@ -32,15 +39,9 @@
|
|
|
32
39
|
"sass": "^1.82.0",
|
|
33
40
|
"sql-formatter": "^15.4.6",
|
|
34
41
|
"tsup": "^8.3.5",
|
|
35
|
-
"vite": "^6.0.
|
|
42
|
+
"vite": "^6.0.3",
|
|
36
43
|
"vitest": "^2.1.8",
|
|
37
44
|
"zustand": "^5.0.2"
|
|
38
45
|
},
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"build:server": "tsup-node src/index.ts --format esm --dts",
|
|
42
|
-
"build:client": "tsc --noEmit && vite build",
|
|
43
|
-
"build": "pnpm run build:server && pnpm run build:client",
|
|
44
|
-
"test": "vitest"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
46
|
+
"gitHead": "dcfce4481869d3b86b21fed59c66f4e6a75c60b1"
|
|
47
|
+
}
|