Skip to content

Commit

Permalink
Add generics in createSeekGraphMiddleware (#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronMoat authored Jan 1, 2024
1 parent 277f3fd commit d496231
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-elephants-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wingman-be': patch
---

Add generic types to createSeekGraphMiddleware
13 changes: 10 additions & 3 deletions be/src/seekGraph/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/dis
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
import { koaMiddleware } from '@as-integrations/koa';
import Router from '@koa/router';
import type { DefaultContext, DefaultState } from 'koa';
import bodyParser from 'koa-bodyparser';

import { createContext } from './context';
Expand All @@ -18,13 +19,19 @@ import type { SeekGraphMiddlewareOptions } from './types';
* authorised to act on behalf of a partner and retrieve a partner token. The
* request is then forwarded to the SEEK API.
*/
export const createSeekGraphMiddleware = async ({
export const createSeekGraphMiddleware = async <
StateT = DefaultState,
ContextT = DefaultContext,
BodyT = unknown,
>({
getPartnerToken,
debug,
path,
userAgent,
seekApiUrlOverride,
}: SeekGraphMiddlewareOptions): Promise<Router.Middleware> => {
}: SeekGraphMiddlewareOptions): Promise<
Router.Middleware<StateT, ContextT, BodyT>
> => {
const schema = await createSchema({
getPartnerToken,
userAgent,
Expand All @@ -45,7 +52,7 @@ export const createSeekGraphMiddleware = async ({

await server.start();

const router = new Router().post(
const router = new Router<StateT, ContextT>().post(
path,
bodyParser({ enableTypes: ['json'] }),
koaMiddleware(server, {
Expand Down

0 comments on commit d496231

Please sign in to comment.