mirror of
				https://github.com/tormachris/cf-workers-status-page.git
				synced 2025-11-04 12:56:24 +01:00 
			
		
		
		
	refactor: switch css framework to tailwind
This commit is contained in:
		@@ -9,7 +9,9 @@ const apiToken = process.env.CF_API_TOKEN
 | 
			
		||||
const kvPrefix = 's_'
 | 
			
		||||
 | 
			
		||||
if (!accountId || !namespaceId || !apiToken) {
 | 
			
		||||
  console.error("Missing required environment variables: CF_ACCOUNT_ID, KV_NAMESPACE_ID, CF_API_TOKEN")
 | 
			
		||||
  console.error(
 | 
			
		||||
    'Missing required environment variables: CF_ACCOUNT_ID, KV_NAMESPACE_ID, CF_API_TOKEN',
 | 
			
		||||
  )
 | 
			
		||||
  process.exit(0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -51,24 +53,26 @@ function loadConfig() {
 | 
			
		||||
  return JSON.parse(config)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
getKvMonitors(kvPrefix).then(async kvMonitors => {
 | 
			
		||||
  const config = loadConfig()
 | 
			
		||||
  const monitors = config.monitors.map(key => {
 | 
			
		||||
    return key.id
 | 
			
		||||
  })
 | 
			
		||||
  const kvState = kvMonitors.map(key => {
 | 
			
		||||
    return key.name
 | 
			
		||||
  })
 | 
			
		||||
  const keysForRemoval = kvState.filter(
 | 
			
		||||
    x => !monitors.includes(x.replace(kvPrefix, '')),
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  if (keysForRemoval.length > 0) {
 | 
			
		||||
    console.log(
 | 
			
		||||
      `Removing following keys from KV storage as they are no longer in the config: ${keysForRemoval.join(
 | 
			
		||||
        ', ',
 | 
			
		||||
      )}`,
 | 
			
		||||
getKvMonitors(kvPrefix)
 | 
			
		||||
  .then(async (kvMonitors) => {
 | 
			
		||||
    const config = loadConfig()
 | 
			
		||||
    const monitors = config.monitors.map((key) => {
 | 
			
		||||
      return key.id
 | 
			
		||||
    })
 | 
			
		||||
    const kvState = kvMonitors.map((key) => {
 | 
			
		||||
      return key.name
 | 
			
		||||
    })
 | 
			
		||||
    const keysForRemoval = kvState.filter(
 | 
			
		||||
      (x) => !monitors.includes(x.replace(kvPrefix, '')),
 | 
			
		||||
    )
 | 
			
		||||
    await deleteKvBulk(keysForRemoval)
 | 
			
		||||
  }
 | 
			
		||||
}).catch(e => console.log(e))
 | 
			
		||||
 | 
			
		||||
    if (keysForRemoval.length > 0) {
 | 
			
		||||
      console.log(
 | 
			
		||||
        `Removing following keys from KV storage as they are no longer in the config: ${keysForRemoval.join(
 | 
			
		||||
          ', ',
 | 
			
		||||
        )}`,
 | 
			
		||||
      )
 | 
			
		||||
      await deleteKvBulk(keysForRemoval)
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
  .catch((e) => console.log(e))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user