-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (22 loc) · 1010 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
29
30
var express = require('express');
var app = express();
require('dotenv').config();
var s3BasicAuth = require('s3-basic-auth');
const health = require('@cloudnative/health-connect');
let healthcheck = new health.HealthChecker();
// Health Checks
app.use('/live', health.LivenessEndpoint(healthcheck))
app.use('/ready', health.ReadinessEndpoint(healthcheck))
var protectedProxy = s3BasicAuth({
key: process.env.AWS_ACCESS_KEY_ID,
secret: process.env.AWS_SECRET_ACCESS_KEY,
host: process.env.S3_BUCKET,
region: process.env.AWS_REGION, // if not specified, defaults to us-east-1
expires: 10, // seconds that the presigned URL is valid for
credentials: process.env.PROXY_USER + ':' + process.env.PROXY_PASS, // username:password
method: 'proxy' // 'proxy', 'redirect', 'presignedUrl' are valid options
})
app.use('/:path', protectedProxy); // Important: the `:path` param is expected by the middleware
app.listen(3000, function () {
console.log('listening on port 3000');
});