turbo-remote-cache-construct
Version:
A Turborepo Remote Cache implementation using AWS API Gateway, Lambda, S3, and DynamoDB.
2 lines (1 loc) • 709 B
JavaScript
import{S3Client as t,HeadBucketCommand as r}from"@aws-sdk/client-s3";var n=new t({region:process.env.AWS_REGION}),i=async o=>{try{let e=process.env.BUCKET_NAME;if(!e)throw new Error("BUCKET_NAME environment variable is not set");return await n.send(new r({Bucket:e})),{statusCode:200,body:JSON.stringify({status:"enabled"}),headers:{"Content-Type":"application/json"}}}catch(e){return console.error("Error checking status:",e),e.code==="NotFound"||e.code==="Forbidden"?{statusCode:200,body:JSON.stringify({status:"disabled"}),headers:{"Content-Type":"application/json"}}:{statusCode:500,body:JSON.stringify({error:"Internal server error"}),headers:{"Content-Type":"application/json"}}}};export{i as handler};