All files / src/utils getStore.ts

83.33% Statements 10/12
100% Branches 0/0
75% Functions 3/4
83.33% Lines 10/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            40x 40x 40x 40x 40x   40x             20x 20x       20x 20x              
import { env } from 'fastly:env'
import { ConfigStore } from 'fastly:config-store'
import { SecretStore } from 'fastly:secret-store'
import { KVStore } from 'fastly:kv-store'
 
export function getNamesForStores() {
  const serviceId = env('FASTLY_SERVICE_ID')
  const storeNamePrefix = process.env.STORE_NAME_PREFIX
  const configStoreName = `${storeNamePrefix}_Config_Store_${serviceId}`
  const secretStoreName = `${storeNamePrefix}_Secret_Store_${serviceId}`
  const kvStoreName = `Fingerprint_Results_${serviceId}`
 
  return {
    configStoreName,
    secretStoreName,
    kvStoreName,
  }
}
export function getConfigStore() {
  const { configStoreName } = getNamesForStores()
  return new ConfigStore(configStoreName)
}
 
export function getSecretStore() {
  const { secretStoreName } = getNamesForStores()
  return new SecretStore(secretStoreName)
}
 
export function getBuiltinKVStore() {
  const { kvStoreName } = getNamesForStores()
  return new KVStore(kvStoreName)
}