-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): auth from id rather then _id
- Loading branch information
1 parent
1e06008
commit 600db61
Showing
7 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
import UserDetail from "../../models/userDetail_model.js"; | ||
import redis, { RedisClientType } from "redis"; | ||
import { RequestHandler, Request, Response, NextFunction } from "express"; | ||
import jwt from "jsonwebtoken"; | ||
|
||
const REDIS_PORT = process.env.REDIS_PORT || 6379; | ||
|
||
const redisClient = redis.createClient({ | ||
socket: { port: REDIS_PORT as number }, | ||
socket: { port: REDIS_PORT as number, host: "localhost" }, | ||
}); | ||
|
||
const connectRedis = async () => { | ||
await redisClient | ||
.connect() | ||
.then(() => { | ||
console.log("Redis Connection Successful"); | ||
return true; | ||
}) | ||
.catch((err) => { | ||
console.log("Err: Can't be able to connect with redis"); | ||
return false; | ||
}); | ||
const connectRedis = async (): Promise<boolean> => { | ||
try { | ||
await redisClient.connect(); | ||
console.log("Redis Connection Successful"); | ||
return true; | ||
} catch (err) { | ||
console.log("Err: Can't be able to connect with redis"); | ||
return false; | ||
} | ||
}; | ||
|
||
// const authenticate: RequestHandler = async ( | ||
// req: Request, | ||
// res: Response, | ||
// next: NextFunction | ||
// ) => { | ||
// const token = req.cookies.AuthToken; | ||
// const verifyToken = jwt.verify(token, process.env.SECRET_KEY); | ||
// console.log(verifyToken); | ||
// }; | ||
|
||
// export default authenticate; | ||
export { redisClient, connectRedis }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default interface ExtendJWTPayload { | ||
_id: string; | ||
id: string; | ||
} |