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

idrinth-api-bench / framework / 9822524417

06 Jul 2024 10:28PM UTC coverage: 71.942% (-3.7%) from 75.611%
9822524417

push

github

web-flow
remove unused code & adjust verification code (#47)

* remove unused code
adjust verification code

* Update src/main.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/main.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/cli/cli.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* eslint fixes

* eslint fixes

* remove impossible test

* fix code to be actually functional

fixes #0

* fix code to be actually functional

fixes #0

* fix code to be actually functional

fixes #0

* update dependency

fixes #0

* update dependency

fixes #0

* update gitignore
publish first release

fixes #0

* fix import

fixes #0

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

311 of 485 branches covered (64.12%)

Branch coverage included in aggregate %.

24 of 81 new or added lines in 5 files covered. (29.63%)

155 existing lines in 5 files now uncovered.

2412 of 3300 relevant lines covered (73.09%)

2538.08 hits per line

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

0.0
/src/validation/check-request.ts
UNCOV
1
import Request from '../routes/request.js';
×
UNCOV
2
import error from './error.js';
×
UNCOV
3
import {
×
UNCOV
4
  EMPTY,
×
UNCOV
5
} from '../constants.js';
×
UNCOV
6
import warn from './warn.js';
×
UNCOV
7

×
UNCOV
8
interface Property {
×
UNCOV
9
    name: string;
×
UNCOV
10
    type: string|string[];
×
UNCOV
11
    required: boolean;
×
UNCOV
12
}
×
UNCOV
13

×
UNCOV
14
const properties: Property[] = [
×
UNCOV
15
  {
×
UNCOV
16
    name: 'method',
×
UNCOV
17
    type: 'string',
×
UNCOV
18
    required: true,
×
UNCOV
19
  },
×
UNCOV
20
  {
×
UNCOV
21
    name: 'headers',
×
UNCOV
22
    type: 'object',
×
UNCOV
23
    required: false,
×
UNCOV
24
  },
×
UNCOV
25
  {
×
UNCOV
26
    name: 'cookies',
×
UNCOV
27
    type: 'object',
×
UNCOV
28
    required: false,
×
UNCOV
29
  },
×
UNCOV
30
  {
×
UNCOV
31
    name: 'body',
×
UNCOV
32
    type: [
×
UNCOV
33
      'string',
×
UNCOV
34
      'object',
×
UNCOV
35
    ],
×
UNCOV
36
    required: false,
×
UNCOV
37
  },
×
UNCOV
38
  {
×
UNCOV
39
    name: 'autohandle',
×
UNCOV
40
    type: 'string',
×
UNCOV
41
    required: false,
×
UNCOV
42
  },
×
UNCOV
43
  {
×
UNCOV
44
    name: 'url',
×
UNCOV
45
    type: 'string',
×
UNCOV
46
    required: true,
×
UNCOV
47
  },
×
UNCOV
48
  {
×
UNCOV
49
    name: 'maxDuration',
×
UNCOV
50
    type: 'number',
×
UNCOV
51
    required: false,
×
UNCOV
52
  },
×
UNCOV
53
];
×
UNCOV
54

×
UNCOV
55
const validateProperty = (property: Property, id: string, main: Request,) => {
×
UNCOV
56
  if (property.required && typeof main[property.name] === 'undefined') {
×
57
    error('invalid_request_property', id, property.name,);
×
58
    return false;
×
59
  }
×
UNCOV
60
  const allowedTypes: string[] = Array.isArray(property.type,)
×
UNCOV
61
    ? property.type
×
UNCOV
62
    : [ property.type, ];
×
UNCOV
63
  if (! allowedTypes.includes(typeof main[property.name],)) {
×
UNCOV
64
    error('invalid_request_property', id, property.name,);
×
UNCOV
65
    delete main[property.name];
×
UNCOV
66
    return false;
×
UNCOV
67
  }
×
UNCOV
68
  delete main[property.name];
×
UNCOV
69
  return true;
×
UNCOV
70
};
×
UNCOV
71
const checkRequest = (main: Request, id: string,): {
×
UNCOV
72
  invalid: boolean,
×
UNCOV
73
  risky: boolean,
×
UNCOV
74
} => {
×
UNCOV
75
  let valid = true;
×
UNCOV
76
  for (const property of properties) {
×
UNCOV
77
    valid = validateProperty(property, id, main,) && valid;
×
UNCOV
78
  }
×
UNCOV
79
  if (Object.keys(main,).length !== EMPTY) {
×
80
    warn('invalid_request', id,);
×
81
    return {
×
82
      invalid: ! valid,
×
83
      risky: true,
×
84
    };
×
85
  }
×
UNCOV
86
  return {
×
UNCOV
87
    invalid: ! valid,
×
UNCOV
88
    risky: false,
×
UNCOV
89
  };
×
UNCOV
90
};
×
UNCOV
91
export default checkRequest;
×
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

© 2026 Coveralls, Inc