Skip to content

Commit

Permalink
Remove shortid package
Browse files Browse the repository at this point in the history
  • Loading branch information
stanlemon committed Sep 16, 2023
1 parent da2a418 commit bff89f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/server-with-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"lowdb-node": "^3.0.2",
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"shortid": "^2.2.16",
"uuid": "^9.0.0"
},
"devDependencies": {
Expand All @@ -36,4 +35,4 @@
"nodemon": "^3.0.1",
"supertest": "^6.3.3"
}
}
}
8 changes: 6 additions & 2 deletions packages/server-with-auth/src/createAppServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from "@stanlemon/server";
import passport from "passport";
import { Strategy as JwtStrategy, ExtractJwt } from "passport-jwt";
import shortid from "shortid";
import defaultUserSchema from "./schema/user.js";
import checkAuth from "./checkAuth.js";
import auth from "./routes/auth.js";
Expand Down Expand Up @@ -50,7 +49,12 @@ export default function createAppServer(options) {
console.warn("You need to specify a secret.");
}

const secret = process.env.JWT_SECRET || shortid.generate();
const badSecret = "YOU_NEED_TO_SPECIFY_A_JWT_SECRET";
const secret = process.env.JWT_SECRET || badSecret;

if (secret === badSecret) {
console.warn("You need to specify a JWT secret.");
}

passport.use(
"jwt",
Expand Down
3 changes: 1 addition & 2 deletions packages/server-with-auth/src/data/simple-users-dao.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LowSync, MemorySync } from "lowdb";
import { JSONFileSync } from "lowdb-node";
import { v4 as uuidv4 } from "uuid";
import shortid from "shortid";
import bcrypt from "bcryptjs";

const DEFAULT_ADAPTER =
Expand Down Expand Up @@ -29,7 +28,7 @@ export default class SimpleUsersDao {
}

generateVerificationToken() {
return shortid.generate();
return uuidv4();
}

getUserById = (userId) => {
Expand Down

0 comments on commit bff89f3

Please sign in to comment.