feat: wire build/test infra, trips API, and enriched journey stops

- Add tsconfig.json (server) + client/tsconfig.{json,app.json,node.json}
  so typecheck and tsc -b actually work.
- Fix npm test to run Playwright (was running vitest on Playwright specs);
  typecheck now covers both server and client.
- Mount routes before app.listen, add error handler, mount optional
  @tonycodes/auth-express middleware when AUTH_SECRET is set.
- Add /api/trips (GET/POST/PATCH/DELETE) backed by an in-memory store
  that gracefully degrades when DATABASE_URL is unset.
- Add prisma/seed.ts skeleton and server/types/express.d.ts for req.auth.
- Rewrite Grok prompt for combo-aware planning: charge+eat,
  stay+destination-charging, eat+viewpoint, etc., with amenities,
  cuisine, priceLevel, duration, day titles and trip highlights.
- Extend Stop schema + normalization to preserve all enrichment fields.
- New StopCard component renders combo pill, description, meta row
  (charge / stop / battery / cuisine / £-level) and amenity icons;
  map popups show the same enriched detail; timeline gains day titles
  and a HIGHLIGHTS sidebar.
- Fix server TS errors (vehicle accepted as string | {name,rangeKm},
  JSON parse results typed).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 10:32:53 +01:00
parent d516e93323
commit 89b24d4c34
24 changed files with 1263 additions and 243 deletions
+19 -6
View File
@@ -5,6 +5,9 @@ import helmet from 'helmet';
import cookieParser from 'cookie-parser';
import { env } from './config/env.js';
import { logger } from './lib/logger.js';
import chatRoutes from './routes/chat.js';
import tripsRoutes from './routes/trips.js';
import { createOptionalAuth } from './lib/auth.js';
const app = express();
@@ -22,13 +25,23 @@ app.get('/health', (_req, res) => {
res.json({ status: 'ok', service: 'tesla-roadtrip', time: new Date().toISOString() });
});
// TODO: Mount auth middleware + routes here once client is registered
// TODO: Mount /api/trips and chat routes
const auth = createOptionalAuth();
if (auth) {
app.use(auth.middleware());
app.use(auth.routes());
logger.info('Auth middleware mounted (AUTH_SECRET present)');
} else {
logger.info('Auth disabled — set AUTH_SECRET to enable user accounts');
}
app.use('/api', chatRoutes);
app.use('/api/trips', tripsRoutes);
app.use((err: Error, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
logger.error({ err }, 'Unhandled error');
res.status(500).json({ error: 'Internal server error' });
});
app.listen(env.port, () => {
logger.info(`Tesla Roadtrip server running on port ${env.port}`);
});
// Chat routes (real Grok integration)
import chatRoutes from './routes/chat.js';
app.use('/api', chatRoutes);