diff --git a/src/examples/basic.ts b/src/examples/basic.ts index cce01db..e7ddc41 100644 --- a/src/examples/basic.ts +++ b/src/examples/basic.ts @@ -41,7 +41,7 @@ to Express.js api.use(toJson) api.use(hydrateDates) -function sampleMiddleware(data: ApiResponse) { +async function sampleMiddleware(data: ApiResponse) { return data } diff --git a/src/lib/auth.service.ts b/src/lib/auth.service.ts index 81be33f..a49e5a4 100644 --- a/src/lib/auth.service.ts +++ b/src/lib/auth.service.ts @@ -12,7 +12,7 @@ class OzzzyAuth implements AuthProvider { this.header = header } - getHeaders(): Array> { + getHeaders(): [string, string][] { switch (this.type) { case AuthTypes.Bearer: return [[this.header!, `${this.type} ${this.token}`]] diff --git a/src/lib/http-api.service.ts b/src/lib/http-api.service.ts index 2b3517f..ad657fc 100644 --- a/src/lib/http-api.service.ts +++ b/src/lib/http-api.service.ts @@ -68,10 +68,7 @@ export class HttpApi { * @returns The response, after all middleware has been applied * @example await api.get('/users/all') */ - get( - url: URL, - ...middleware: Middleware[] - ): Promise { + get(url: URL, ...middleware: Middleware[]): Promise { const requestMiddleware = [...this.middleware, ...middleware] const options = { method: RestMethods.GET } return this._fetch(url, options, requestMiddleware) @@ -88,7 +85,7 @@ export class HttpApi { put( url: URL, payload: object, - ...middleware: Middleware[] + ...middleware: Middleware[] ): Promise { const requestMiddleware = [...this.middleware, ...middleware] const options = { @@ -109,7 +106,7 @@ export class HttpApi { post( url: URL, payload: object, - ...middleware: Middleware[] + ...middleware: Middleware[] ): Promise { const requestMiddleware = [...this.middleware, ...middleware] const options = { @@ -130,7 +127,7 @@ export class HttpApi { delete( url: URL, payload: object, - ...middleware: Middleware[] + ...middleware: Middleware[] ): Promise { const requestMiddleware = [...this.middleware, ...middleware] const options = { @@ -171,7 +168,7 @@ export class HttpApi { private async _fetch( url: URL, options: object, - middleware: Middleware[], + middleware: Middleware[], ): Promise { let combinedHeaders = [...this.headers] if (this.auth !== undefined) { diff --git a/src/middleware/dates.middleware.ts b/src/middleware/dates.middleware.ts index 451ed8c..e83b0a9 100644 --- a/src/middleware/dates.middleware.ts +++ b/src/middleware/dates.middleware.ts @@ -15,7 +15,7 @@ const dateFormat = /^-?\d+-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/ * If there is a match, it returns the value as a date, * if not, it returns the value as is */ -function dateReviver(_key: string, value: any) { +function dateReviver(_key: string, value: unknown) { if (typeof value === 'string' && dateFormat.test(value)) { return new Date(value) } @@ -29,7 +29,7 @@ function dateReviver(_key: string, value: any) { * Note that this data is expected to be a Javascript object * @returns Hydrated data object */ -export function hydrateDates(data: object): Promise { +export function hydrateDates(data: object): Promise { const dataAsString = JSON.stringify(data) const hydratedData = JSON.parse(dataAsString, dateReviver) diff --git a/src/middleware/json.middleware.ts b/src/middleware/json.middleware.ts index 9ce1792..3d7379a 100644 --- a/src/middleware/json.middleware.ts +++ b/src/middleware/json.middleware.ts @@ -6,6 +6,6 @@ * @param next Next middleware handler function * @returns Call to next middleware handler */ -export function toJson(response: Response): Promise { +export function toJson(response: Response): Promise { return response.json() } diff --git a/src/shared-types/middleware.type.ts b/src/shared-types/middleware.type.ts index e6506ab..0dbc37e 100644 --- a/src/shared-types/middleware.type.ts +++ b/src/shared-types/middleware.type.ts @@ -1 +1,2 @@ -export type Middleware = (data: K) => Promise +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type Middleware = (data: K) => Promise