Initial scaffold: full-stack RackMapper application
Complete project scaffold with working auth, REST API, Prisma/SQLite schema, Docker config, and React frontend for both Rack Planner and Service Mapper modules. Both server and client pass TypeScript strict mode with zero errors. Initial migration applied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
37
server/types/index.ts
Normal file
37
server/types/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Request } from 'express';
|
||||
|
||||
// ---- Error handling ----
|
||||
|
||||
export class AppError extends Error {
|
||||
statusCode: number;
|
||||
code?: string;
|
||||
|
||||
constructor(message: string, statusCode: number, code?: string) {
|
||||
super(message);
|
||||
this.name = 'AppError';
|
||||
this.statusCode = statusCode;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- API response shape ----
|
||||
|
||||
export interface ApiResponse<T = unknown> {
|
||||
data: T | null;
|
||||
error: string | null;
|
||||
meta?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export function ok<T>(data: T, meta?: Record<string, unknown>): ApiResponse<T> {
|
||||
return { data, error: null, ...(meta ? { meta } : {}) };
|
||||
}
|
||||
|
||||
export function err(message: string, meta?: Record<string, unknown>): ApiResponse<null> {
|
||||
return { data: null, error: message, ...(meta ? { meta } : {}) };
|
||||
}
|
||||
|
||||
// ---- Augmented request ----
|
||||
|
||||
export interface AuthenticatedRequest extends Request {
|
||||
user: { sub: string };
|
||||
}
|
||||
Reference in New Issue
Block a user