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

nodeshift / faas-js-runtime / 16341850588

17 Jul 2025 09:48AM UTC coverage: 55.699% (-31.8%) from 87.527%
16341850588

Pull #421

github

web-flow
Merge c3bb8e82a into eb6047b08
Pull Request #421: [Snyk] Upgrade fastify from 4.21.0 to 5.4.0

64 of 146 branches covered (43.84%)

Branch coverage included in aggregate %.

195 of 319 relevant lines covered (61.13%)

13.86 hits per line

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

76.92
/lib/invocation-handler.js
1
const invoker = require('./invoker');
6✔
2

3
// Sets the HTTP endpoints for the function invocation
4
module.exports = function use(fastify, opts, done) {
6✔
5
  fastify.get('/', doGet);
30✔
6
  fastify.post('/', doPost);
30✔
7
  fastify.options('/', doOptions);
30✔
8
  const invokeFunction = invoker(opts);
30✔
9

10
  // TODO: if we know this is a CloudEvent function, should
11
  // we allow GET requests?
12
  async function doGet(request, reply) {
13
    sendReply(reply, await invokeFunction(request.fcontext, reply.log));
×
14
  }
15

16
  async function doPost(request, reply) {
17
    sendReply(reply, await invokeFunction(request.fcontext, reply.log));
30✔
18
  }
19

20
  async function doOptions(_request, reply) {
21
    reply.code(204).headers({
×
22
      'content-type': 'application/json; charset=utf-8',
23
      'access-control-allow-methods': 'OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH',
24
      'access-control-allow-origin': '*',
25
      'access-control-allow-headers': '*'
26
    }).send();
27
  }
28
  done();
30✔
29
};
30

31
function sendReply(reply, payload) {
32
  const contentType = payload.headers?.['content-type'];
30✔
33
  if (contentType?.startsWith('text/plain') && (typeof payload.response !== 'string')) {
30!
34
    payload.response = JSON.stringify(payload.response);
×
35
  }
36
  if (payload.code) {
30!
37
    reply = reply.code(payload.code);
30✔
38
  }
39
  if (payload.headers) {
30!
40
    reply = reply.headers(payload.headers);
30✔
41
  }
42
  return reply.send(payload.response);
30✔
43
}
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