• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmcelhaney / counterfact / 10645385797

31 Aug 2024 12:51PM UTC coverage: 82.599%. Remained the same
10645385797

push

github

web-flow
chore(deps): update dependency @swc/core to v1.7.21

1001 of 1114 branches covered (89.86%)

Branch coverage included in aggregate %.

3233 of 4012 relevant lines covered (80.58%)

42.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/server/openapi-middleware.ts
1
import yaml from "js-yaml";
×
2
import type Koa from "koa";
×
3

×
4
import { readFile } from "../util/read-file.js";
×
5

×
6
export function openapiMiddleware(openApiPath: string, url: string) {
×
7
  return async (ctx: Koa.ExtendableContext, next: Koa.Next) => {
×
8
    if (ctx.URL.pathname === "/counterfact/openapi") {
×
9
      const openApiDocument = (await yaml.load(
×
10
        await readFile(openApiPath),
×
11
      )) as {
×
12
        host?: string;
×
13
        servers?: { description: string; url: string }[];
×
14
      };
×
15

×
16
      openApiDocument.servers ??= [];
×
17

×
18
      openApiDocument.servers.unshift({
×
19
        description: "Counterfact",
×
20
        url,
×
21
      });
×
22

×
23
      // OpenApi 2 support:
×
24
      openApiDocument.host = url;
×
25

×
26
      ctx.body = yaml.dump(openApiDocument);
×
27

×
28
      return;
×
29
    }
×
30

×
31
    await next();
×
32
  };
×
33
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc