export interface CartItem {
sku: string;
name: string;
unitPrice: number; // cents
qty: number;
}
export interface AnalyticsEvent {
name: string;
props?: Record<string, unknown>;
ts: number;
}
import { RequestHandler } from 'express';
import { ZodTypeAny, ZodError } from 'zod';
export class ValidationError extends Error {
status = 422;
constructor(public issues: unknown) {
import { Injectable, Scope } from '@nestjs/common';
import { DataSource, EntityManager, QueryRunner } from 'typeorm';
@Injectable({ scope: Scope.REQUEST })
export class TransactionContext {
private queryRunner?: QueryRunner;
import { z } from "zod";
const flagValueSchema = z.union([
z.boolean(),
z.object({
rollout: z.number().min(0).max(100),
export const FLAG_REGISTRY = {
newDashboard: {
default: false as boolean,
description: 'Renders the redesigned dashboard shell',
},
maxUploadMb: {
import { Knex } from 'knex';
export interface RawDailyRow {
day: string;
order_count: string;
gross_cents: string;
import { AxiosError } from 'axios';
export const RETRY_CONFIG = {
maxRetries: 4,
baseDelayMs: 200,
maxDelayMs: 5_000,
import { SetMetadata } from '@nestjs/common';
export enum Role {
User = 'user',
Editor = 'editor',
Admin = 'admin',
import { createHash } from "crypto";
import { Request, Response } from "express";
export function computeEtag(body: string): string {
const digest = createHash("sha1").update(body).digest("base64");
return `"${digest}"`;
import { z } from "zod";
export const signupSchema = z
.object({
email: z.string().min(1, "Email is required").email("Enter a valid email"),
username: z
import { Request, Response } from 'express';
import { authenticate } from './auth.service';
export async function login(req: Request, res: Response): Promise<void> {
const { email, password } = req.body ?? {};