All files / src/utils getStore.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 4/4
100% Lines 12/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            60x 60x 60x 60x 60x   60x             29x 29x       29x 29x       1x 1x    
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)
}