generated from nholtware/service-template-express
feat: hot-reloaded runtime config (src/lib/runtime-config.ts), greeting on GET /, GET /admin/runtime-config
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f0596d1fd3
commit
43f10810d3
13 changed files with 511 additions and 10 deletions
18
src/app.ts
18
src/app.ts
|
|
@ -6,6 +6,11 @@ import type { Config } from "./lib/config.js";
|
|||
import type { Db } from "./lib/db.js";
|
||||
import type { Flags } from "./lib/flags.js";
|
||||
import type { Cache } from "./lib/redis.js";
|
||||
import {
|
||||
staticRuntimeConfig,
|
||||
type RuntimeConfig,
|
||||
} from "./lib/runtime-config.js";
|
||||
import { adminRouter } from "./routes/admin.js";
|
||||
import { healthRouter } from "./routes/health.js";
|
||||
import { logDemoRouter } from "./routes/log-demo.js";
|
||||
import { rootRouter } from "./routes/root.js";
|
||||
|
|
@ -16,9 +21,17 @@ export interface Deps {
|
|||
db?: Db;
|
||||
cache?: Cache;
|
||||
flags?: Flags;
|
||||
runtimeConfig?: RuntimeConfig;
|
||||
}
|
||||
|
||||
export function createApp({ config, logger, db, cache, flags }: Deps) {
|
||||
export function createApp({
|
||||
config,
|
||||
logger,
|
||||
db,
|
||||
cache,
|
||||
flags,
|
||||
runtimeConfig = staticRuntimeConfig(),
|
||||
}: Deps) {
|
||||
const app = express();
|
||||
app.disable("x-powered-by");
|
||||
|
||||
|
|
@ -45,7 +58,8 @@ export function createApp({ config, logger, db, cache, flags }: Deps) {
|
|||
);
|
||||
|
||||
app.use(healthRouter({ db, cache }));
|
||||
app.use(rootRouter({ config, db, cache, flags }));
|
||||
app.use(rootRouter({ config, db, cache, flags, runtimeConfig }));
|
||||
app.use(adminRouter({ runtimeConfig }));
|
||||
app.use(logDemoRouter());
|
||||
|
||||
// Express identifies error handlers by arity; keep all four args.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue