mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 16:22:44 +00:00
Prefix loading successfully from config/local.json for both Homebrewery and Google brews.
Concats switched to string literals to make Linter happy.
This commit is contained in:
12
server.js
12
server.js
@@ -111,14 +111,15 @@ app.get('/source/:id', (req, res)=>{
|
||||
|
||||
//Download brew source page
|
||||
app.get('/download/:id', (req, res)=>{
|
||||
const prefix = config.get('filename-prefix');
|
||||
const prefix = config.get('name_prefix');
|
||||
|
||||
if(req.params.id.length > 12) {
|
||||
const googleId = req.params.id.slice(0, -12);
|
||||
const shareId = req.params.id.slice(-12);
|
||||
GoogleActions.readFileMetadata(config.get('google_api_key'), googleId, shareId, 'share')
|
||||
.then((brew)=>{
|
||||
let fileName = sanitizeFilename(prefix + title).replaceAll(' ', '-');
|
||||
if(!title || !title.length) { fileName = prefix + 'Untitled-Brew'; };
|
||||
let fileName = sanitizeFilename(`${prefix}${brew.title}`).replaceAll(' ', '');
|
||||
if(!fileName || !fileName.length) { fileName = `${prefix}-Untitled-Brew`; };
|
||||
res.set({
|
||||
'Cache-Control' : 'no-cache',
|
||||
'Content-Type' : 'text/plain',
|
||||
@@ -133,9 +134,8 @@ app.get('/download/:id', (req, res)=>{
|
||||
} else {
|
||||
HomebrewModel.get({ shareId: req.params.id })
|
||||
.then((brew)=>{
|
||||
let fileName = sanitizeFilename(prefix + title).replaceAll(' ', '-');
|
||||
console.log(title);
|
||||
if(!title || !title.length) { fileName = prefix + 'Untitled-Brew'; };
|
||||
let fileName = sanitizeFilename(`${prefix}${brew.title}`).replaceAll(' ', '');
|
||||
if(!fileName || !fileName.length) { fileName = `${prefix}-Untitled-Brew`; };
|
||||
res.set({
|
||||
'Cache-Control' : 'no-cache',
|
||||
'Content-Type' : 'text/plain',
|
||||
|
||||
@@ -258,7 +258,12 @@ GoogleActions = {
|
||||
}
|
||||
|
||||
//Access actual file with service account. Just api key is causing "automated query" errors.
|
||||
const keys = JSON.parse(config.get('service_account'));
|
||||
|
||||
const actionList = {
|
||||
'string' : function() { return JSON.parse(config.get('service_account')); },
|
||||
'object' : function() { return config.get('service_account'); }
|
||||
};
|
||||
const keys = actionList[typeof(config.get('service_account'))]();
|
||||
const serviceAuth = google.auth.fromJSON(keys);
|
||||
serviceAuth.scopes = ['https://www.googleapis.com/auth/drive'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user