Add LINK_LENGTH variable (#254)

This commit is contained in:
Mikhail Golovanov 2019-12-27 16:31:07 +03:00 committed by Pouria Ezzati
parent 94094505fb
commit 7be595c3cc
3 changed files with 8 additions and 2 deletions

View File

@ -4,6 +4,9 @@ PORT=3000
# The domain that this website is on
DEFAULT_DOMAIN="localhost:3000"
# Generated link length
LINK_LENGTH=6
# Postgres database credential details
DB_HOST=localhost
DB_PORT=5432

View File

@ -4,6 +4,9 @@ PORT={{PORT}}
# The domain that this website is on
DEFAULT_DOMAIN={{DEFAULT_DOMAIN}}
# Generated link length
LINK_LENGTH={{LINK_LENGTH}}
# Neo4j database credential details
DB_URI={{DB_URI}}
DB_USERNAME={{DB_USERNAME}}
@ -57,4 +60,4 @@ MAIL_PASSWORD={{MAIL_PASSWORD}}
REPORT_MAIL={{REPORT_MAIL}}
# Support email to show on the app
CONTACT_EMAIL={{CONTACT_EMAIL}}
CONTACT_EMAIL={{CONTACT_EMAIL}}

View File

@ -36,7 +36,7 @@ const dnsLookup = promisify(dns.lookup);
const generateId = async () => {
const address = generate(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
6
Number(process.env.LINK_LENGTH) || 6
);
const link = await findLink({ address });
if (!link) return address;