Skip to content

Commit 7f02795

Browse files
chore: migrate to nanoid 3 (freeCodeCamp#44893)
1 parent dd0a073 commit 7f02795

File tree

3 files changed

+18
-83
lines changed

3 files changed

+18
-83
lines changed

api-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"moment-timezone": "^0.5.33",
6161
"mongodb": "^3.6.9",
6262
"morgan": "^1.10.0",
63-
"nanoid": "^1.3.4",
63+
"nanoid": "^3.2.0",
6464
"nodemailer-ses-transport": "^1.5.1",
6565
"passport": "^0.4.1",
6666
"passport-auth0": "^1.4.1",

api-server/src/common/models/user.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import debugFactory from 'debug';
1010
import dedent from 'dedent';
1111
import _ from 'lodash';
1212
import moment from 'moment';
13-
import generate from 'nanoid/generate';
13+
import { customAlphabet } from 'nanoid';
1414
import { Observable } from 'rx';
1515
import uuid from 'uuid/v4';
1616
import { isEmail } from 'validator';
@@ -43,6 +43,7 @@ const log = debugFactory('fcc:models:user');
4343
const BROWNIEPOINTS_TIMEOUT = [1, 'hour'];
4444
const nanoidCharSet =
4545
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
46+
const nanoid = customAlphabet(nanoidCharSet, 21);
4647

4748
const createEmailError = redirectTo =>
4849
wrapHandledError(new Error('email format is invalid'), {
@@ -148,7 +149,7 @@ function populateRequiredFields(user) {
148149
}
149150

150151
if (!user.unsubscribeId) {
151-
user.unsubscribeId = generate(nanoidCharSet, 20);
152+
user.unsubscribeId = nanoid();
152153
}
153154
return;
154155
}

package-lock.json

Lines changed: 14 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)