feat(#1): Set up monorepo scaffold with pnpm workspaces + TurboRepo

Implements the foundational project structure including:
- pnpm workspaces configuration
- TurboRepo for build orchestration
- NestJS 11.1.12 API (apps/api)
- Next.js 16.1.6 web app (apps/web)
- Shared packages (config, shared, ui)
- TypeScript strict mode configuration
- ESLint + Prettier setup
- Vitest for unit testing (19 passing tests)

Fixes #1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-01-28 13:31:33 -06:00
commit 92e20b1686
109 changed files with 8320 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
{
"name": "@mosaic/shared",
"version": "0.0.1",
"private": true,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.js"
},
"./types": {
"types": "./dist/types/index.d.ts",
"require": "./dist/types/index.js",
"import": "./dist/types/index.js"
},
"./utils": {
"types": "./dist/utils/index.d.ts",
"require": "./dist/utils/index.js",
"import": "./dist/utils/index.js"
}
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"lint": "eslint src/",
"lint:fix": "eslint src/ --fix",
"typecheck": "tsc --noEmit",
"clean": "rm -rf dist",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"@mosaic/config": "workspace:*",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
}
}

View File

@@ -0,0 +1,2 @@
export * from "./types/index";
export * from "./utils/index";

View File

@@ -0,0 +1,38 @@
/**
* Base entity type with common fields
*/
export interface BaseEntity {
id: string;
createdAt: Date;
updatedAt: Date;
}
/**
* API response wrapper
*/
export interface ApiResponse<T> {
data: T;
success: boolean;
message?: string;
}
/**
* Pagination parameters
*/
export interface PaginationParams {
page: number;
limit: number;
sortBy?: string;
sortOrder?: "asc" | "desc";
}
/**
* Paginated response
*/
export interface PaginatedResponse<T> {
data: T[];
total: number;
page: number;
limit: number;
totalPages: number;
}

View File

@@ -0,0 +1,61 @@
import { describe, expect, it } from "vitest";
import { isDefined, parseDate, sleep, slugify } from "./index.js";
describe("parseDate", () => {
it("should return undefined for null or undefined", () => {
expect(parseDate(null)).toBeUndefined();
expect(parseDate(undefined)).toBeUndefined();
});
it("should return the same Date object if passed a Date", () => {
const date = new Date("2024-01-15");
expect(parseDate(date)).toBe(date);
});
it("should parse valid date strings", () => {
const result = parseDate("2024-01-15");
expect(result).toBeInstanceOf(Date);
expect(result?.toISOString()).toContain("2024-01-15");
});
it("should return undefined for invalid date strings", () => {
expect(parseDate("not-a-date")).toBeUndefined();
});
});
describe("slugify", () => {
it("should convert text to lowercase slug", () => {
expect(slugify("Hello World")).toBe("hello-world");
});
it("should handle special characters", () => {
expect(slugify("Hello, World!")).toBe("hello-world");
});
it("should trim leading and trailing hyphens", () => {
expect(slugify(" Hello World ")).toBe("hello-world");
});
});
describe("sleep", () => {
it("should resolve after the specified time", async () => {
const start = Date.now();
await sleep(50);
const elapsed = Date.now() - start;
expect(elapsed).toBeGreaterThanOrEqual(45);
});
});
describe("isDefined", () => {
it("should return false for null and undefined", () => {
expect(isDefined(null)).toBe(false);
expect(isDefined(undefined)).toBe(false);
});
it("should return true for defined values", () => {
expect(isDefined(0)).toBe(true);
expect(isDefined("")).toBe(true);
expect(isDefined(false)).toBe(true);
expect(isDefined({})).toBe(true);
});
});

View File

@@ -0,0 +1,35 @@
/**
* Safely parse a date string or return undefined
*/
export function parseDate(value: string | Date | undefined | null): Date | undefined {
if (!value) return undefined;
if (value instanceof Date) return value;
const parsed = new Date(value);
return isNaN(parsed.getTime()) ? undefined : parsed;
}
/**
* Generate a simple slug from a string
*/
export function slugify(text: string): string {
return text
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, "")
.replace(/[\s_-]+/g, "-")
.replace(/^-+|-+$/g, "");
}
/**
* Sleep for a given number of milliseconds
*/
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
/**
* Check if a value is defined (not null or undefined)
*/
export function isDefined<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined;
}

View File

@@ -0,0 +1,12 @@
{
"extends": "@mosaic/config/typescript/library",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"module": "CommonJS",
"moduleResolution": "node",
"lib": ["ES2022", "DOM"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}

View File

@@ -0,0 +1,14 @@
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: false,
environment: "node",
include: ["src/**/*.test.ts"],
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
exclude: ["node_modules/", "dist/"],
},
},
});