1
0
Fork 0
mirror of synced 2024-09-28 23:31:43 +12:00
This commit is contained in:
mike12345567 2020-12-18 12:55:01 +00:00
parent 31bc45985f
commit cce92f5ab3
3 changed files with 21 additions and 18 deletions

View file

@ -13,8 +13,8 @@ const PUBLIC_READ_POLICY = {
Principal: "*",
Action: "s3:GetObject",
Resource: `arn:aws:s3:::${APP_BUCKET}/*`,
}
]
},
],
}
async function getCouchSession() {
@ -25,7 +25,7 @@ async function getCouchSession() {
json: {
username: env.COUCH_DB_USERNAME,
password: env.COUCH_DB_PASSWORD,
}
},
})
const cookie = session.headers["set-cookie"][0]
@ -50,19 +50,25 @@ async function getMinioSession() {
})
// make sure the bucket exists
try {
await objClient.headBucket({
Bucket: APP_BUCKET
}).promise()
await objClient.putBucketPolicy({
Bucket: APP_BUCKET,
Policy: JSON.stringify(PUBLIC_READ_POLICY),
}).promise()
await objClient
.headBucket({
Bucket: APP_BUCKET,
})
.promise()
await objClient
.putBucketPolicy({
Bucket: APP_BUCKET,
Policy: JSON.stringify(PUBLIC_READ_POLICY),
})
.promise()
} catch (err) {
// bucket doesn't exist create it
if (err.statusCode === 404) {
await objClient.createBucket({
Bucket: APP_BUCKET,
}).promise()
await objClient
.createBucket({
Bucket: APP_BUCKET,
})
.promise()
} else {
throw err
}

View file

@ -4,7 +4,6 @@ const checkKey = require("../../middleware/check-key")
const router = Router()
router
.post("/api/deploy", checkKey, controller.deploy)
router.post("/api/deploy", checkKey, controller.deploy)
module.exports = router

View file

@ -1,5 +1,3 @@
const deployRoutes = require("./deploy")
exports.routes = [
deployRoutes,
]
exports.routes = [deployRoutes]