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

pmcelhaney / counterfact / 6619608899

23 Oct 2023 10:11PM UTC coverage: 85.276% (-2.5%) from 87.815%
6619608899

Pull #599

github

pmcelhaney
the option to not start the http server was not actually doing anything
Pull Request #599: don't expose moduleLoader

729 of 811 branches covered (0.0%)

Branch coverage included in aggregate %.

214 of 214 new or added lines in 6 files covered. (100.0%)

2358 of 2809 relevant lines covered (83.94%)

38.56 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
      // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
×
10
      const openApiDocument = (await yaml.load(
×
11
        await readFile(openApiPath),
×
12
      )) as {
×
13
        host?: string;
×
14
        servers?: { description: string; url: string }[];
×
15
      };
×
16

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

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

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

×
27
      // eslint-disable-next-line require-atomic-updates
×
28
      ctx.body = yaml.dump(openApiDocument);
×
29

×
30
      return;
×
31
    }
×
32

×
33
    // eslint-disable-next-line  n/callback-return
×
34
    await next();
×
35
  };
×
36
}
×
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