Configuration Reference
Complete specification for nooh.config.ts and group.ts configuration files.
Nooh projects are configured via TypeScript configuration files.
nooh.config.ts
The top-level configuration file defines project-wide settings, typed environment bindings, and global error handlers.
import { config } from "@nooh-ts/nooh";
export interface AppEnv {
Bindings: {
DATABASE_URL: string;
JWT_SECRET: string;
};
Variables: {
userId?: string;
};
}
export default config<AppEnv>({
routes: "src/routes",
dependencies: "src/dependencies",
onError: (error, c) => {
return c.json({ error: error.message }, 500);
},
validator: {
// Optional validator engine configuration
},
});
Options
| Option | Type | Default | Description |
|---|---|---|---|
routes |
string |
"src/routes" |
Path to the directory containing route endpoint files. |
dependencies |
string |
"src/deps" |
Path to the directory containing DI containers. |
onError |
NoohErrorHandler<Env> |
undefined |
Global error handler for uncaught exceptions across all routes. |
validator |
NoohValidatorOptions |
undefined |
Custom options and engine configuration for Standard Schema validator. |
group.ts
Each directory inside routes/ can optionally include a group.ts file to configure route groups, scoped middleware, and localized error handlers.
import { group } from "@nooh-ts/nooh";
import { adminAuthMiddleware } from "@/middleware/admin";
export default group({
middleware: [adminAuthMiddleware],
onError: (error, c) => {
return c.json({ section: "admin", error: error.message }, 500);
},
});
Options
| Option | Type | Default | Description |
|---|---|---|---|
middleware |
readonly MiddlewareHandler[] |
[] |
List of middleware functions applied to all routes in this group and sub-groups. |
onError |
NoohErrorHandler<Env> |
undefined |
Scoped error handler for all routes in this directory and sub-directories. |