0.8.2 • Published 25 days ago

wingman-be v0.8.2

Weekly downloads
19
License
MIT
Repository
github
Last release
25 days ago

🛩 Wingman B.E.

npm package

Disclaimer

While we publish Wingman components as packages on the public npm registry, they are not considered part of the public SEEK API and we don’t recommend their use in third-party production systems. We recommend its use for inspiration only. Read more.

Example API

/browser-token

Provide a hirer-scoped browser token to the Wingman F.E.

POST http://localhost:9090/browser-token HTTP/1.1
Authorization: ...
Content-Type: application/json

{
  "hirerId": "seekAnzPublicTest:organization:seek:93WyyF1h",
  "scope": "query:locations"
}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "authorization": "Bearer ey...",
  "expiry": "1970-01-01T00:00:00.000Z"
}

/seek-graphql

Proxy requests from the Wingman F.E. to the SEEK API’s GraphQL endpoint.

POST http://localhost:9090/seek-graphql HTTP/1.1
Authorization: ...
Content-Type: application/json

{
  "query": "{ version }"
}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "version": "123"
  }
}

/webhook

Handle incoming webhooks from the SEEK API.

POST http://localhost:9090/webhook/abc HTTP/1.1
Content-Type: application/json
Seek-Signature: ...

{
  "events": [
    {
      "createDateTime": "foo",
      "id": "foo",
      "type": "CandidateApplicationCreated",
      "candidateApplicationProfileId": "foo",
      "candidateId": "foo"
    }
  ],
  "subscriptionId": "foo"
}
HTTP/1.1 204 OK

Node.js API

createBrowserTokenMiddleware

import { GetPartnerToken, createBrowserTokenMiddleware } from 'wingman-be';

const getPartnerToken: GetPartnerToken<{
  hirerId: string;
  partnerToken: string;
}> = async (request) => {
  if (request.authorization !== 'SUPER_SECRET') {
    throw new Error('oh no!');
  }

  const partnerToken = await getPartnerTokenFromSecretStore();

  return {
    hirerId: 'seekAnzPublicTest:organization:seek:93WyyF1h',
    partnerToken,
  };
};

const createApp = () => {
  const middleware = createBrowserTokenMiddleware({
    getPartnerToken,
    userAgent: 'my-service/1.2.3',
  });

  return new Koa().use(middleware);
};

createPartnerWebhookMiddleware

import { GetSigningSecret, createPartnerWebhookMiddleware } from 'wingman-be';

const getSigningSecret: GetSigningSecret = (subscriptionId) => {
  switch (subscriptionId) {
    case 'fully seekret':
      return getSigningSecretFromSecretStore();
    case 'risky business':
      return null;
    default:
      throw new Error('Invalid request');
  }
};

const createApp = () => {
  const middleware = createPartnerWebhookMiddleware({
    getSigningSecret,
  });

  return new Koa().use(middleware);
};

createSeekGraphMiddleware

import {
  AuthenticationError,
  GetPartnerToken,
  createSeekGraphMiddleware,
} from 'wingman-be';

const getPartnerToken: GetPartnerToken = (request) => {
  if (request.authorization !== 'SUPER_SECRET') {
    throw new AuthenticationError('oh no!');
  }

  return getPartnerTokenFromSecretStore();
};

const createApp = async () => {
  const middleware = await createSeekGraphMiddleware({
    debug: false,
    getPartnerToken,
    path: '/seek-graphql',
    userAgent: 'my-service/1.2.3',
  });

  return new Koa().use(middleware);
};
0.8.2

25 days ago

0.8.1

4 months ago

0.8.0

4 months ago

0.6.2

8 months ago

0.5.3

11 months ago

0.7.0

8 months ago

0.6.1

10 months ago

0.6.0

10 months ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0-beta.0

1 year ago

0.4.5

1 year ago

0.4.4

2 years ago

0.5.0

1 year ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago