Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize generated link length #254

Merged
merged 1 commit into from Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .example.env
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .template.env
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
2 changes: 1 addition & 1 deletion server/controllers/linkController.ts
Expand Up @@ -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;
Expand Down