Skip to content

Commit

Permalink
removed nullable operator from env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
devout-coder committed Mar 29, 2023
1 parent 287cb05 commit fce4974
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/controllers/todo.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class TodoController {
user: user.id,
});
await todo.save();

socket
.to(user.id)
.emit("todo_operation", { operation: "create", data: todo });
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ const mongooseOptions = {
serverSelectionTimeoutMS: 5000,
};

const MONGODB_URI = process.env.MONGODB_URI || "";
const MONGODB_URI = process.env.MONGODB_URI;

mongoose
.set("strictQuery", true)
.connect(MONGODB_URI, mongooseOptions)
.connect(MONGODB_URI!, mongooseOptions)
.then(() => {
server.listen(PORT, () => {
console.log(`Server is running on ${PORT}`);

io.use((socket, next) => {
const token = socket.handshake.auth.auth_token;
// console.log("token is " + token);
jwt.verify(token, JWT_KEY, (err: any, user: any) => {
jwt.verify(token, JWT_KEY!, (err: any, user: any) => {
if (err) {
console.log("Error", err);
}
Expand Down
7 changes: 4 additions & 3 deletions src/services/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class JWT {
const authHeader = req.headers.authorization;
if (authHeader && authHeader !== "null") {
// const token = authHeader.split(" ")[1];
log("auth Header", JWT_KEY);
jwt.verify(authHeader, JWT_KEY, (err: any, user: any) => {
// log("auth Header", JWT_KEY);
jwt.verify(authHeader, JWT_KEY!, (err: any, user: any) => {
if (err) {
log("Error", err);
console.log("in jwt service");
console.log("Error", err);
return res
.status(403)
.send({ success: false, message: "Token Expired" });
Expand Down

0 comments on commit fce4974

Please sign in to comment.