parameterize the download-image server
This commit is contained in:
24
.env.sample
Normal file
24
.env.sample
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#AWS_ACCESS_KEY=???
|
||||
#AWS_BUCKET_NAME=image
|
||||
#AWS_REGION=US
|
||||
#AWS_SECRET_KEY=???
|
||||
AWS_ACCESS_KEY=???
|
||||
AWS_BUCKET_NAME=gifts-image-test
|
||||
AWS_REGION=us-west-1
|
||||
AWS_SECRET_KEY=???
|
||||
|
||||
#ENDORSER_API_URL=http://localhost:3000
|
||||
#ENDORSER_API_URL=https://test-api.endorser.ch
|
||||
#ENDORSER_API_URL=https://api.endorser.ch
|
||||
|
||||
INFURA_PROJECT_ID=???
|
||||
|
||||
#DOWNLOAD_IMAGE_SERVER=test-image.timesafari.app
|
||||
|
||||
# default is 3000
|
||||
#PORT=3000
|
||||
|
||||
# default is jdbc:sqlite:./sqlite-db.sqlite
|
||||
# file name also referenced in flyway.conf and in code
|
||||
#SQLITE_FILE=./image-db.sqlite
|
||||
@@ -20,6 +20,7 @@ const port = process.env.PORT || 3001;
|
||||
// file name also referenced in flyway.conf and potentially in .env files or in environment variables
|
||||
const dbFile = process.env.SQLITE_FILE || './image-db.sqlite';
|
||||
const bucketName = process.env.AWS_BUCKET_NAME || 'gifts-image-test';
|
||||
const imageServer = process.env.DOWNLOAD_IMAGE_SERVER || 'test-image.timesafari.app';
|
||||
|
||||
const ethrDidResolver = getResolver;
|
||||
const resolver =
|
||||
@@ -36,7 +37,7 @@ const db = new sqlite3.Database(dbFile, (err) => {
|
||||
}
|
||||
});
|
||||
|
||||
const endorserApiUrl = process.env.ENDORSER_API_URL || 'http://localhost:3000';
|
||||
const endorserApiUrl = process.env.ENDORSER_API_URL || 'https://test-api.endorser.ch';
|
||||
|
||||
// Configure AWS
|
||||
const s3Client = new S3Client({
|
||||
@@ -173,7 +174,7 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => {
|
||||
// record the upload in the database
|
||||
const currentDate = new Date().toISOString();
|
||||
const localFile = reqFile.path.startsWith(uploadDir + '/') ? reqFile.path.substring(uploadDir.length + 1) : reqFile.path;
|
||||
const finalUrl = `https://${bucketName}.s3.amazonaws.com/${fileName}`;
|
||||
const finalUrl = `https://${imageServer}/${fileName}`;
|
||||
await new Promise((resolve, reject) => {
|
||||
db.run(
|
||||
'INSERT INTO image (time, did, local_file, size, final_file, url) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
|
||||
Reference in New Issue
Block a user