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:
parent
aa1e4d028a
commit
667b2bd199
2 changed files with 1 additions and 7 deletions
4
app.js
4
app.js
|
@ -17,10 +17,6 @@ const turnTTL = 86400;
|
|||
app.set("view engine", "ejs");
|
||||
app.use(express.static(path.join(__dirname, "public")));
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.render("index", { trackerUrl });
|
||||
});
|
||||
|
||||
app.get("/generate-mnemonic/:infoHash", (req, res) => {
|
||||
const infoHash = req.params.infoHash;
|
||||
const mnemonic = bip39.entropyToMnemonic(infoHash);
|
||||
|
|
|
@ -65,9 +65,7 @@
|
|||
</div>
|
||||
<script>
|
||||
const trackerUrl = "<%= trackerUrl %>";
|
||||
<% if (typeof mnemonic !== 'undefined') { %>
|
||||
const mnemonic = "<%= mnemonic %>";
|
||||
<% } %>
|
||||
const mnemonic = "<%= mnemonic %>";
|
||||
</script>
|
||||
<script src="/js/index.js"></script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue