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

View File

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

View File

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