Skip to content

Commit 5540f1c

Browse files
committed
Add @objectql/admin package and integrate admin UI
Introduced a new @objectql/admin package with its own build setup and static admin UI. Updated the express app to use createObjectQLAdmin middleware for serving the admin interface, and moved the admin HTML to the new package.
1 parent aa1770c commit 5540f1c

6 files changed

Lines changed: 44 additions & 4 deletions

File tree

examples/apps/express/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@objectql/driver-knex": "^0.1.0",
1313
"@objectql/driver-mongo": "^0.1.0",
1414
"@objectql/express": "^0.1.0",
15+
"@objectql/admin": "*",
1516
"@example/project-management": "*",
1617
"cors": "^2.8.5",
1718
"express": "^4.18.2"

examples/apps/express/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ObjectQL, ObjectConfig, UnifiedQuery } from '@objectql/core';
22
import { createObjectQLRouter } from '@objectql/express';
3+
import { createObjectQLAdmin } from '@objectql/admin';
34
import express from 'express';
45
import cors from 'cors';
56
import * as path from 'path';
@@ -25,8 +26,8 @@ console.log(`ObjectQL Server started with ${config.packages.length} packages.`);
2526
server.use(cors());
2627
server.use(express.json());
2728

28-
// Serve static files
29-
server.use(express.static(path.join(__dirname, '../public')));
29+
// Serve Admin UI
30+
server.use(createObjectQLAdmin());
3031

3132
// Mount ObjectQL API
3233
// Example: /api/projects

packages/admin/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@objectql/admin",
3+
"version": "0.1.0",
4+
"main": "dist/index.js",
5+
"types": "dist/index.d.ts",
6+
"files": [
7+
"dist"
8+
],
9+
"scripts": {
10+
"build": "tsc && cp -r public dist/"
11+
},
12+
"dependencies": {
13+
"express": "^4.18.2"
14+
},
15+
"devDependencies": {
16+
"@types/express": "^4.17.17",
17+
"typescript": "^5.3.0"
18+
}
19+
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
66
<title>ObjectQL Admin</title>
77

8-
<!-- SF Pro Font look-alike -->
9-
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
108
<link href="https://cdn.jsdelivr.net/npm/remixicon@4.1.0/fonts/remixicon.css" rel="stylesheet">
119
<script src="https://cdn.tailwindcss.com"></script>
1210
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.8/dist/cdn.min.js"></script>

packages/admin/src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import express, { Router } from 'express';
2+
import * as path from 'path';
3+
4+
export function createObjectQLAdmin(): Router {
5+
const router = express.Router();
6+
// Assuming 'public' is copied to 'dist/public' during build
7+
// And this file is compiled to 'dist/index.js'
8+
const publicPath = path.join(__dirname, 'public');
9+
10+
router.use(express.static(publicPath));
11+
12+
return router;
13+
}

packages/admin/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"rootDir": "./src"
6+
},
7+
"include": ["src/**/*"]
8+
}

0 commit comments

Comments
 (0)