mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Allow exclusion of conflicting properties #16416
This commit is contained in:
parent
dee8894855
commit
63c96d3815
23
types/hapi/index.d.ts
vendored
23
types/hapi/index.d.ts
vendored
@ -826,7 +826,7 @@ export interface RouteAuthAccessConfiguationObject {
|
||||
/**
|
||||
* For context see RouteAdditionalConfigurationOptions > cache
|
||||
*/
|
||||
export interface RouteCacheOptions {
|
||||
export type RouteCacheOptions = {
|
||||
/**
|
||||
* determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are:
|
||||
* * 'default' - no privacy flag. This is the default setting.
|
||||
@ -834,15 +834,26 @@ export interface RouteCacheOptions {
|
||||
* * 'private' - mark the response as suitable only for private caching.
|
||||
*/
|
||||
privacy?: 'default' | 'public' | 'private';
|
||||
/** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */
|
||||
expiresIn?: number;
|
||||
/** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */
|
||||
expiresAt?: string;
|
||||
/** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */
|
||||
statuses?: number[];
|
||||
/** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */
|
||||
otherwise?: string;
|
||||
}
|
||||
} & ({
|
||||
/** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */
|
||||
expiresIn?: number;
|
||||
/** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */
|
||||
expiresAt?: undefined;
|
||||
} | {
|
||||
/** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */
|
||||
expiresIn?: undefined;
|
||||
/** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */
|
||||
expiresAt?: string;
|
||||
} | {
|
||||
/** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */
|
||||
expiresIn?: undefined;
|
||||
/** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */
|
||||
expiresAt?: undefined;
|
||||
});
|
||||
|
||||
/**
|
||||
* For context see RouteAdditionalConfigurationOptions > cors
|
||||
|
||||
@ -8,31 +8,32 @@ var authConfig: Hapi.RouteAdditionalConfigurationOptions = {
|
||||
|
||||
// Handler in config
|
||||
const user: Hapi.RouteAdditionalConfigurationOptions = {
|
||||
cache: { expiresIn: 5000 },
|
||||
cache: { expiresIn: 5000, statuses: [200, 201] },
|
||||
handler: function (request, reply) {
|
||||
|
||||
return reply({ name: 'John' });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Add in addition to examples in docs
|
||||
|
||||
var cache: Hapi.RouteCacheOptions = {
|
||||
privacy: 'default',
|
||||
statuses: [200, 201],
|
||||
expiresIn: 5000,
|
||||
};
|
||||
|
||||
cache = {
|
||||
privacy: 'default',
|
||||
statuses: [200, 201],
|
||||
expiresAt: '22:44',
|
||||
};
|
||||
|
||||
// /* typings should cause this to error, but currently does not
|
||||
cache = {
|
||||
privacy: 'default',
|
||||
};
|
||||
|
||||
/* should error (as does!)
|
||||
var cache: Hapi.RouteCacheOptions = {
|
||||
expiresIn: 5000,
|
||||
expiresAt: '22:44',
|
||||
};
|
||||
// */
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user