refactor: remove redundant root route and streamline mnemonic rendering

Eliminated the redundant root route definition to avoid unnecessary rendering of the index page from the server side. Streamlined the client-side rendering of the mnemonic variable in the index.ejs file to always define the mnemonic constant. Enhances maintainability and reduces potential errors related to undefined variables.
This commit is contained in:
Kumi 2024-06-15 15:03:33 +02:00
parent aa1e4d028a
commit 667b2bd199
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 1 additions and 7 deletions

4
app.js
View file

@ -17,10 +17,6 @@ const turnTTL = 86400;
app.set("view engine", "ejs"); app.set("view engine", "ejs");
app.use(express.static(path.join(__dirname, "public"))); app.use(express.static(path.join(__dirname, "public")));
app.get("/", (req, res) => {
res.render("index", { trackerUrl });
});
app.get("/generate-mnemonic/:infoHash", (req, res) => { app.get("/generate-mnemonic/:infoHash", (req, res) => {
const infoHash = req.params.infoHash; const infoHash = req.params.infoHash;
const mnemonic = bip39.entropyToMnemonic(infoHash); const mnemonic = bip39.entropyToMnemonic(infoHash);

View file

@ -65,9 +65,7 @@
</div> </div>
<script> <script>
const trackerUrl = "<%= trackerUrl %>"; const trackerUrl = "<%= trackerUrl %>";
<% if (typeof mnemonic !== 'undefined') { %> const mnemonic = "<%= mnemonic %>";
const mnemonic = "<%= mnemonic %>";
<% } %>
</script> </script>
<script src="/js/index.js"></script> <script src="/js/index.js"></script>
</body> </body>