Currently, top-level config values are not required, which means that the generated config types are optional. This forces us to use fallbacks, check if values are present or cast them:
app.use(
session({
store: db.getSessionStore(),
secret: config.getCookieSecret() as string,
resave: false,
saveUninitialized: false,
cookie: {
secure: 'auto',
httpOnly: true,
maxAge: (config.getSessionMaxAgeHours() || DEFAULT_SESSION_MAX_AGE_HOURS) * 60 * 60 * 1000,
},
}),
);
Describe the solution you'd like
Adding the parameters to the "required" list will break tests that override the config entirely since it errors out if the entries aren't present. The best solution seems to be to post-process the generated config types so that the top-level properties are wrapped in Required types. This allows stronger typing as well as overriding.
We should also consider how we can set default values for the config - see the related discussion: #1202 (comment)
Additional context
#1202 (comment)
#1202 (comment)
Currently, top-level config values are not required, which means that the generated config types are optional. This forces us to use fallbacks, check if values are present or cast them:
Describe the solution you'd like
Adding the parameters to the "required" list will break tests that override the config entirely since it errors out if the entries aren't present. The best solution seems to be to post-process the generated config types so that the top-level properties are wrapped in
Requiredtypes. This allows stronger typing as well as overriding.We should also consider how we can set default values for the config - see the related discussion: #1202 (comment)
Additional context
#1202 (comment)
#1202 (comment)