@hamak/smart-data-dico 1.0.0 → 1.0.3

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.
@@ -13,11 +13,11 @@
13
13
  "test:coverage": "jest --coverage"
14
14
  },
15
15
  "dependencies": {
16
- "@hamak/filesystem-server-api": "^0.5.1",
17
- "@hamak/filesystem-server-impl": "^0.5.1",
18
- "@hamak/filesystem-server-spi": "^0.5.1",
19
- "@hamak/shared-utils": "^0.5.1",
20
- "@hamak/ui-remote-git-fs-backend": "file:../../app-framework/packages/ui-remote-git-fs/backend/ui-remote-git-fs-backend",
16
+ "@hamak/filesystem-server-api": "^0.5.2",
17
+ "@hamak/filesystem-server-impl": "^0.5.2",
18
+ "@hamak/filesystem-server-spi": "^0.5.2",
19
+ "@hamak/shared-utils": "^0.5.2",
20
+ "@hamak/ui-remote-git-fs-backend": "^0.5.2",
21
21
  "@types/jsonwebtoken": "^9.0.9",
22
22
  "cors": "^2.8.5",
23
23
  "dotenv": "^16.3.1",
@@ -1,4 +1,5 @@
1
1
  import express, { Request, Response } from 'express';
2
+ import fs from 'fs';
2
3
  import path from 'path';
3
4
  import cors from 'cors';
4
5
  import dotenv from 'dotenv';
@@ -36,10 +37,12 @@ app.use((req: Request, res: Response, next) => {
36
37
 
37
38
  app.use(express.json());
38
39
 
39
- // Basic route
40
- app.get('/', (req: Request, res: Response) => {
41
- res.json({ message: 'Welcome to the Data Dictionary Management System API' });
42
- });
40
+ // API welcome route (only in dev — production serves frontend at /)
41
+ if (!config.isProduction) {
42
+ app.get('/', (req: Request, res: Response) => {
43
+ res.json({ message: 'Welcome to the Data Dictionary Management System API' });
44
+ });
45
+ }
43
46
 
44
47
  // Health check endpoint
45
48
  app.get('/health', (req: Request, res: Response) => {
@@ -104,8 +107,35 @@ mountFrameworkRoutes().catch((err) => {
104
107
  });
105
108
 
106
109
 
107
- // Error handling middleware
108
- app.use((err: any, req: Request, res: Response, next: any) => {
110
+ // Serve frontend static files in production (BEFORE error handler)
111
+ if (config.isProduction) {
112
+ // Check multiple possible frontend dist locations
113
+ const candidates = [
114
+ path.join(process.cwd(), 'public'), // Docker (copied to public/)
115
+ path.join(process.cwd(), '..', 'frontend', 'dist'), // npm package / monorepo
116
+ path.join(process.cwd(), 'frontend', 'dist'), // alt layout
117
+ ];
118
+ const publicDir = candidates.find(d => {
119
+ try { return fs.statSync(d).isDirectory(); } catch { return false; }
120
+ });
121
+
122
+ if (publicDir) {
123
+ app.use(express.static(publicDir));
124
+ // SPA fallback — only for navigation requests, not assets/API
125
+ app.get('*', (req, res, next) => {
126
+ if (req.path.startsWith('/api') || req.path.startsWith('/fs') || req.path.startsWith('/api-docs') || req.path.includes('.')) {
127
+ return next();
128
+ }
129
+ res.sendFile(path.join(publicDir, 'index.html'));
130
+ });
131
+ logger.info(`Serving frontend from ${publicDir}`);
132
+ } else {
133
+ logger.warn('Frontend dist not found. API-only mode.');
134
+ }
135
+ }
136
+
137
+ // Error handling middleware (after static files)
138
+ app.use((err: any, req: Request, res: Response, _next: any) => {
109
139
  logger.error(`Unhandled error: ${err.message}`);
110
140
  res.status(500).json({
111
141
  message: 'Internal server error',
@@ -113,18 +143,6 @@ app.use((err: any, req: Request, res: Response, next: any) => {
113
143
  });
114
144
  });
115
145
 
116
- // Serve frontend static files in production
117
- if (config.isProduction) {
118
- const publicDir = path.join(process.cwd(), 'public');
119
- app.use(express.static(publicDir));
120
- app.get('*', (req, res) => {
121
- if (!req.path.startsWith('/api') && !req.path.startsWith('/fs') && !req.path.startsWith('/api-docs')) {
122
- res.sendFile(path.join(publicDir, 'index.html'));
123
- }
124
- });
125
- logger.info(`Serving frontend from ${publicDir}`);
126
- }
127
-
128
146
  // Start server only when run directly (not when imported by tests)
129
147
  const isMainModule = process.argv[1] && (
130
148
  process.argv[1].endsWith('server.ts') || process.argv[1].endsWith('server.js')
package/bin/cli.js CHANGED
@@ -89,7 +89,7 @@ const child = spawn(tsxBin, tsxArgs, {
89
89
  env: {
90
90
  ...process.env,
91
91
  PORT: port,
92
- NODE_ENV: existsSync(frontendDist) ? 'production' : 'development',
92
+ NODE_ENV: 'production',
93
93
  PROFILE: process.env.PROFILE || 'local',
94
94
  DATA_DIR: dataDir,
95
95
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamak/smart-data-dico",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Collaborative data dictionary management system — model, document, and govern your data landscape",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,26 @@
20
20
  "data-dictionaries/stereotypes.yaml"
21
21
  ],
22
22
  "dependencies": {
23
- "tsx": "^4.0.0"
23
+ "tsx": "^4.0.0",
24
+ "cors": "^2.8.5",
25
+ "dotenv": "^16.3.1",
26
+ "express": "^4.18.2",
27
+ "jsonschema": "^1.4.1",
28
+ "jsonwebtoken": "^9.0.2",
29
+ "swagger-jsdoc": "^6.2.8",
30
+ "swagger-ui-express": "^5.0.1",
31
+ "yaml": "^2.3.1",
32
+ "@hamak/filesystem-server-api": "^0.5.2",
33
+ "@hamak/filesystem-server-impl": "^0.5.2",
34
+ "@hamak/filesystem-server-spi": "^0.5.2",
35
+ "@hamak/shared-utils": "^0.5.2",
36
+ "@hamak/ui-remote-git-fs-backend": "^0.5.2",
37
+ "@types/jsonwebtoken": "^9.0.9",
38
+ "@types/cors": "^2.8.13",
39
+ "@types/express": "^4.17.17",
40
+ "@types/node": "^20.17.50",
41
+ "@types/swagger-jsdoc": "^6.0.4",
42
+ "@types/swagger-ui-express": "^4.1.8"
24
43
  },
25
44
  "keywords": [
26
45
  "data-dictionary",