-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (22 loc) · 859 Bytes
/
server.js
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
import express from 'express'
import dotenv from 'dotenv'
import { getSignedUrl } from '@aws-sdk/cloudfront-signer'
dotenv.config()
const app = express()
const s3ImageName = "22W15-blog-SecurityZines-Compromising_CICD_pipelinesnal.jpg"
const cloudFrontDomain = "https://dsqo0tpjgjpw0.cloudfront.net"
app.get('/imageFile',async(req,res)=>{
try{
let imageUrl = getSignedUrl({
url:`${cloudFrontDomain}/${s3ImageName}`,
dateLessThan:new Date(Date.now() + 5 * 60000),
keyPairId:process.env.CLOUDFRONT_KEY_PAIR_ID,
privateKey:process.env.CLOUDFRONT_PRIVATE_KEY,
})
console.log(imageUrl)
res.send(imageUrl)
}catch(Err){
console.log(Err)
}
})
app.listen(process.env.PORT,()=>console.log(`SERVER RUNNING IN PORT ${process.env.PORT}`))