Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Type definitions for cacheable-request 6.0
  2. // Project: https://github.com/lukechilds/cacheable-request#readme
  3. // Definitions by: BendingBender <https://github.com/BendingBender>
  4. // Paul Melnikow <https://github.com/paulmelnikow>
  5. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  6. // TypeScript Version: 2.3
  7. /// <reference types="node" />
  8. import { request, RequestOptions, ClientRequest, ServerResponse } from 'http';
  9. import { URL } from 'url';
  10. import { EventEmitter } from 'events';
  11. import { Store } from 'keyv';
  12. import { Options as CacheSemanticsOptions } from 'http-cache-semantics';
  13. import ResponseLike = require('responselike');
  14. export = CacheableRequest;
  15. declare const CacheableRequest: CacheableRequest;
  16. type RequestFn = typeof request;
  17. interface CacheableRequest {
  18. new (requestFn: RequestFn, storageAdapter?: string | CacheableRequest.StorageAdapter): (
  19. opts: string | URL | (RequestOptions & CacheSemanticsOptions),
  20. cb?: (response: ServerResponse | ResponseLike) => void
  21. ) => CacheableRequest.Emitter;
  22. RequestError: typeof RequestErrorCls;
  23. CacheError: typeof CacheErrorCls;
  24. }
  25. declare namespace CacheableRequest {
  26. type StorageAdapter = Store<any>;
  27. interface Options {
  28. /**
  29. * If the cache should be used. Setting this to `false` will completely bypass the cache for the current request.
  30. * @default true
  31. */
  32. cache?: boolean;
  33. /**
  34. * If set to `true` once a cached resource has expired it is deleted and will have to be re-requested.
  35. *
  36. * If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated
  37. * on the next request with `If-None-Match`/`If-Modified-Since` headers.
  38. * @default false
  39. */
  40. strictTtl?: boolean;
  41. /**
  42. * Limits TTL. The `number` represents milliseconds.
  43. * @default undefined
  44. */
  45. maxTtl?: number;
  46. /**
  47. * When set to `true`, if the DB connection fails we will automatically fallback to a network request.
  48. * DB errors will still be emitted to notify you of the problem even though the request callback may succeed.
  49. * @default false
  50. */
  51. automaticFailover?: boolean;
  52. /**
  53. * Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a
  54. * new request and override the cache instead.
  55. * @default false
  56. */
  57. forceRefresh?: boolean;
  58. }
  59. interface Emitter extends EventEmitter {
  60. addListener(event: 'request', listener: (request: ClientRequest) => void): this;
  61. addListener(
  62. event: 'response',
  63. listener: (response: ServerResponse | ResponseLike) => void
  64. ): this;
  65. addListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
  66. on(event: 'request', listener: (request: ClientRequest) => void): this;
  67. on(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
  68. on(event: 'error', listener: (error: RequestError | CacheError) => void): this;
  69. once(event: 'request', listener: (request: ClientRequest) => void): this;
  70. once(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
  71. once(event: 'error', listener: (error: RequestError | CacheError) => void): this;
  72. prependListener(event: 'request', listener: (request: ClientRequest) => void): this;
  73. prependListener(
  74. event: 'response',
  75. listener: (response: ServerResponse | ResponseLike) => void
  76. ): this;
  77. prependListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
  78. prependOnceListener(event: 'request', listener: (request: ClientRequest) => void): this;
  79. prependOnceListener(
  80. event: 'response',
  81. listener: (response: ServerResponse | ResponseLike) => void
  82. ): this;
  83. prependOnceListener(
  84. event: 'error',
  85. listener: (error: RequestError | CacheError) => void
  86. ): this;
  87. removeListener(event: 'request', listener: (request: ClientRequest) => void): this;
  88. removeListener(
  89. event: 'response',
  90. listener: (response: ServerResponse | ResponseLike) => void
  91. ): this;
  92. removeListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
  93. off(event: 'request', listener: (request: ClientRequest) => void): this;
  94. off(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
  95. off(event: 'error', listener: (error: RequestError | CacheError) => void): this;
  96. removeAllListeners(event?: 'request' | 'response' | 'error'): this;
  97. listeners(event: 'request'): Array<(request: ClientRequest) => void>;
  98. listeners(event: 'response'): Array<(response: ServerResponse | ResponseLike) => void>;
  99. listeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;
  100. rawListeners(event: 'request'): Array<(request: ClientRequest) => void>;
  101. rawListeners(event: 'response'): Array<(response: ServerResponse | ResponseLike) => void>;
  102. rawListeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;
  103. emit(event: 'request', request: ClientRequest): boolean;
  104. emit(event: 'response', response: ServerResponse | ResponseLike): boolean;
  105. emit(event: 'error', error: RequestError | CacheError): boolean;
  106. eventNames(): Array<'request' | 'response' | 'error'>;
  107. listenerCount(type: 'request' | 'response' | 'error'): number;
  108. }
  109. type RequestError = RequestErrorCls;
  110. type CacheError = CacheErrorCls;
  111. }
  112. declare class RequestErrorCls extends Error {
  113. readonly name: 'RequestError';
  114. constructor(error: Error);
  115. }
  116. declare class CacheErrorCls extends Error {
  117. readonly name: 'CacheError';
  118. constructor(error: Error);
  119. }