Creating a better env strategy.

This commit is contained in:
Dessalines 2019-02-20 18:35:27 -08:00
parent c460c958dd
commit 8678f92c5d
4 changed files with 9 additions and 14 deletions

View File

@ -25,7 +25,7 @@ fn main() {
// .index_file("index.html"), // .index_file("index.html"),
) )
.finish() .finish()
}).bind("0.0.0.0:8080") }).bind("localhost:8080")
.unwrap() .unwrap()
.run(); .run();
} }

View File

@ -27,3 +27,5 @@ test/data/result.json
package-lock.json package-lock.json
*.orig *.orig
src/env.ts

View File

@ -2,16 +2,10 @@ require('dotenv').config();
const fs = require('fs'); const fs = require('fs');
exports.setEnv = function() { exports.setEnv = function() {
if (process.env.TORRENTS_CSV_ENDPOINT) { let endpoint = (process.env.TORRENTS_CSV_ENDPOINT) ? process.env.TORRENTS_CSV_ENDPOINT : "http://localhost:8080";
let env_line = `export const endpoint = '${process.env.TORRENTS_CSV_ENDPOINT}';`; let env_line = `export const endpoint = '${endpoint}';`;
fs.writeFile("src/env.ts", env_line, function (err) { fs.writeFile("src/env.ts", env_line, function (err) {
if (err) { console.log("Wrote src/env.ts:");
return console.log(err); console.log("\t" + env_line);
} });
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
console.log("\t" + env_line);
});
} else {
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
}
} }

View File

@ -1 +0,0 @@
export const endpoint = 'http://0.0.0.0:8080';