All files / src/utils getStore.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9

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          74x 74x 74x 74x   74x           37x 37x       37x 37x    
import { env } from 'fastly:env'
import { ConfigStore } from 'fastly:config-store'
import { SecretStore } from 'fastly:secret-store'
 
export function getNamesForStores() {
  const serviceId = env('FASTLY_SERVICE_ID')
  const storeNamePrefix = String(process.env.STORE_NAME_PREFIX)
  const configStoreName = `${storeNamePrefix}_Config_Store_${serviceId}`
  const secretStoreName = `${storeNamePrefix}_Secret_Store_${serviceId}`
 
  return {
    configStoreName,
    secretStoreName,
  }
}
export function getConfigStore() {
  const { configStoreName } = getNamesForStores()
  return new ConfigStore(configStoreName)
}
 
export function getSecretStore() {
  const { secretStoreName } = getNamesForStores()
  return new SecretStore(secretStoreName)
}