Consolidate to single server with unified package.json

- Merge client and server dependencies into root package.json
- Remove separate client/package.json and server/package.json
- Update server/index.js to serve built client static files
- Simplify Dockerfile to single build + production stage
- Update dev scripts for unified development workflow
- SPA routing serves index.html for non-API routes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Khalid A
2026-04-21 22:24:20 -05:00
parent 009557c249
commit 66bd69efe7
6 changed files with 70 additions and 68 deletions

View File

@@ -30,6 +30,21 @@ app.use(express.urlencoded({ extended: true, limit: '50mb' }));
app.use('/uploads', express.static(uploadsDir));
app.use('/exports', express.static(exportsDir));
// Serve built client static files
const clientDistDir = join(__dirname, 'dist');
if (existsSync(clientDistDir)) {
app.use(express.static(clientDistDir));
// Serve index.html for all non-API routes (SPA routing)
app.get('*', (req, res, next) => {
if (!req.path.startsWith('/api') && !req.path.startsWith('/uploads') && !req.path.startsWith('/exports')) {
res.sendFile(join(clientDistDir, 'index.html'));
} else {
next();
}
});
}
// Configure multer for image uploads
const storage = multer.diskStorage({
destination: (req, file, cb) => {

View File

@@ -1,18 +0,0 @@
{
"name": "apparel-designer-server",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"scripts": {
"dev": "DYLD_INSERT_LIBRARIES='' node --watch index.js",
"start": "node index.js"
},
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5",
"multer": "^1.4.5-lts.1",
"sharp": "^0.33.2",
"uuid": "^9.0.1",
"canvas": "^2.11.2"
}
}