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

ducktors / turborepo-remote-cache / 14041536045

24 Mar 2025 05:13PM UTC coverage: 90.17%. Remained the same
14041536045

push

github

web-flow
docs: add do server

101 of 133 branches covered (75.94%)

Branch coverage included in aggregate %.

908 of 986 relevant lines covered (92.09%)

4.39 hits per line

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

81.82
/src/plugins/remote-cache/auth/static.ts
1
import { badRequest, unauthorized } from '@hapi/boom'
1✔
2
import { FastifyInstance } from 'fastify'
1✔
3
import fp from 'fastify-plugin'
1✔
4

1✔
5
export default fp(async (fastify: FastifyInstance) => {
1✔
6
  const allowedTokens = fastify.config.TURBO_TOKEN
8✔
7
  if (!(Array.isArray(allowedTokens) && allowedTokens.length)) {
8!
8
    throw new Error(
×
9
      `'allowedTokens' options must be a string[], ${typeof allowedTokens} provided instead`,
×
10
    )
×
11
  }
×
12
  const tokens = new Set(allowedTokens)
8✔
13

8✔
14
  fastify.addHook('onRequest', async function (request) {
8✔
15
    let authHeader = request.headers.authorization
47✔
16
    authHeader = Array.isArray(authHeader) ? authHeader.join() : authHeader
47!
17

47✔
18
    if (!authHeader) {
47✔
19
      throw badRequest('Missing Authorization header')
5✔
20
    }
5✔
21
    const [, token] = authHeader.split('Bearer ')
47✔
22
    if (!tokens.has(token)) {
47✔
23
      throw unauthorized('Invalid authorization token')
5✔
24
    }
5✔
25
  })
8✔
26
})
1✔
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