Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ APP_PORT=8000 # Port number for the applicati
PINO_LOG_LEVEL=info # Log level (trace/debug/info/warn/error/fatal)

# Database Configuration
DATABASE_URI=mongodb://localhost:27017/ # MongoDB connection URL
DATABASE_URI=mongodb://localhost:27017/user-service # MongoDB connection URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's an inconsistency between the database name in DATABASE_URI (user-service) and the DB_NAME variable on the next line (users-service). While the dbName option in the Mongoose connection options will likely override the one in the URI, it's best to keep these consistent to avoid confusion. I'd recommend making them match.

DATABASE_URI=mongodb://localhost:27017/users-service          # MongoDB connection URL

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abhishek-nexgen-dev, since we have already DB_NAME in env. we don't need to update DB_URI

DB_NAME=users-service

# Redis connection
Expand Down Expand Up @@ -43,11 +43,42 @@ CLIENT_URL=http://localhost:3000 # Frontend client URL

# JWT RSA Keys (Replace with actual RSA keys)
PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCh2omMxTPcCcNk
... (rest of private key) ...
-----END PRIVATE KEY-----"
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8QMjlH9vP4foj
qu9jO/oG2s327nY/her1FjQfOX0mLHNPrEOhi3ONVa1TE1znGhxR/Fs2SPofFBp7
lG9lIV/Seh45zeIYgyQJh/WjB1Xm4ieig3LGiVCrGJEl4tvXzFBoxvK3XEL9HrHR
aC5I1uZCedk206GkbEGpthMtKuZYoAAzySz9LUi3SCEFzZ6+Qi9dbeUK2O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KPXdNilidjtpwm6timqp+vDf09Ky61cozWTi
FIwUF4BZqU33B1fFNqDUaE7WCRh7QsUdmy0PdtqQCTRT/iUYiIHxTAaX2Q4TYTse
xYv4QGQMMbzUkWMnOcbVSajeQd+SdLSXMu/0joECgYEAwTo6KsGqU+utyFPY4rx1
Fmbp/OmyRjCWGBYiaJzGj/VwxDd+HeFcSP7mCQgIyPauTWu6G3YhBk9ckEJrPSmn
/DXqfiexhDoo0oyUM4RfZs1CM980OPT25bHhr2/O6YLmlgwR8G50/tE2NObyi5mK
0+yv7vLxii7GO+XT7Fm9xOQ=
-----END PRIVATE KEY-----
"

PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0vx7agoebGcQSuuPiLJX
... (rest of public key) ...
-----END PUBLIC KEY-----"
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvEDI5R/bz+H6I6rvYzv6
BtrN9u52P4Xq9RY0Hzl9JixzT6xDoYtzjVWtUxNc5xocUfxbNkj6HxQae5RvZSFf
0noeOc3iGIMkCYf1owdV5uInooNyxolQqxiRJeLb18xQaMbyt1xC/R6x0WguSNbm
QnnZNtOhpGxBqbYTLSrmWKAAM8ks/S1It0ghBc2evkIvXW3lCtjgZQ/O1c5dIrbI
QNl5Ke3Dhkgpk7yPwPQkpPZgsVovNXQILzMkNLHffkJ8UfaUKKlXXOLwMnOGfRiO
GN8aWsQfAJQHM8BkTvb1mOkZq7irnCBFJnpfVO7l88SikbHYRmuVAj5r2e8WTFWd
WQIDAQAB
-----END PUBLIC KEY-----
"
4 changes: 2 additions & 2 deletions src/api/v1/user/user.dal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { UserModel } from "./user.model.js";

export class UserDAL {
static async createUser(userData: RegisterSchema): Promise<User> {
const newUser = new UserModel(userData);
return await newUser.save();
const userRole = await UserModel.create(userData);
return userRole;
Comment on lines +14 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable name userRole is misleading here, as this function creates a User object, not a UserRole. A more appropriate name would be user or createdUser. Additionally, these two lines can be simplified into a single return statement.

Suggested change
const userRole = await UserModel.create(userData);
return userRole;
return UserModel.create(userData);

}

static async getAllUsers(limit: number, offset: number): Promise<{ users: User[]; totalUsers: number }> {
Expand Down