Skip to content

Commit

Permalink
Fix docker error
Browse files Browse the repository at this point in the history
  • Loading branch information
Somnath-Chattaraj committed Oct 10, 2024
1 parent 4be6b9c commit 566bcb8
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 22 deletions.
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY package*.json ./

# Install dependencies
RUN npm install
RUN npm install typescript

# Copy the rest of the application code
COPY . .
Expand Down
16 changes: 9 additions & 7 deletions backend/dist/controllers/routeControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ const express_async_handler_1 = __importDefault(require("express-async-handler")
const prisma_1 = __importDefault(require("../lib/prisma"));
const searchRoom = (0, express_async_handler_1.default)((req, res) => __awaiter(void 0, void 0, void 0, function* () {
// @ts-ignore
const userId = req.user.user_id;
const user_id = req.user.user_id;
const rooms = yield prisma_1.default.chatRoom.findMany({
where: {
users: {
some: { user_id: userId }
}
},
select: {
id: true,
users: {
Expand All @@ -34,6 +29,13 @@ const searchRoom = (0, express_async_handler_1.default)((req, res) => __awaiter(
}
}
});
res.status(200).json(rooms);
const updateArray = rooms.map(room => {
const otherUsers = room.users.filter(user => user.user_id != user_id);
return {
roomId: room.id,
usernames: otherUsers.map(user => user.username)
};
});
res.status(200).json(updateArray);
}));
exports.searchRoom = searchRoom;
5 changes: 5 additions & 0 deletions backend/dist/controllers/userControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const bcrypt_1 = __importDefault(require("bcrypt"));
const sendMail_1 = __importDefault(require("../mail/sendMail"));
const academic_email_verifier_1 = require("academic-email-verifier");
const checkAcademic_1 = __importDefault(require("../mail/checkAcademic"));
const registerSchema_1 = require("../validation/registerSchema");
const googleSignInOrSignUp = (0, express_async_handler_1.default)(
//@ts-ignore
(req, res) => __awaiter(void 0, void 0, void 0, function* () {
Expand Down Expand Up @@ -131,6 +132,10 @@ const registerUser = (0, express_async_handler_1.default)((req, res) => __awaite
res.status(400).json({ message: "Please provide all fields" });
return;
}
if (registerSchema_1.registerSchema.safeParse(req.body).success === false) {
res.status(400).json({ message: registerSchema_1.registerSchema.safeParse(req.body).error });
return;
}
const userExists = yield prisma_1.default.user.findFirst({
where: {
OR: [{ email: email }, { username: username }],
Expand Down
3 changes: 3 additions & 0 deletions backend/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ app.use("/api/chat", chatRoutes_1.default); // Use the chat routes
app.use("/api/post", postsRoutes_1.default);
app.use('/api/room', roomRoutes_1.default);
// app.get("/api/post/communities", getCommunities);
app.get('/api/logout', (req, res) => {
res.clearCookie('Authorization').json({ message: 'Logged out successfully' });
});
app.get("/", (req, res) => {
res.send("Backend is running");
});
Expand Down
23 changes: 23 additions & 0 deletions backend/dist/validation/registerSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerSchema = void 0;
const zod_1 = __importDefault(require("zod"));
exports.registerSchema = zod_1.default.object({
email: zod_1.default.string().email({ message: "Invalid email address " }),
username: zod_1.default
.string()
.min(3, { message: "Username must be at least 3 characters long " }),
password: zod_1.default
.string()
.min(6, { message: "Password must be at least 6 characters long. " })
.regex(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{6,}$/, {
message: "Password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character ",
}),
collegeName: zod_1.default.string().optional(),
courseName: zod_1.default.string().optional(),
isOnline: zod_1.default.boolean(),
location: zod_1.default.string().optional(),
});
14 changes: 2 additions & 12 deletions backend/package-lock.json

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

4 changes: 1 addition & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
"nodemailer": "^6.9.14",
"nodemon": "^3.1.4",
"prettier": "^3.3.3",
"tsc": "^2.0.4",
"ws": "^8.18.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/express": "^4.17.21",
"prisma": "^5.20.0",
"ts-node": "^10.9.2",
"typescript": "^5.6.3"
"ts-node": "^10.9.2"
}
}
1 change: 1 addition & 0 deletions backend/tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./src/index.ts","./src/seed.ts","./src/server.ts","./src/controllers/chatcontrollers.ts","./src/controllers/postcontroller.ts","./src/controllers/ratingcontroller.ts","./src/controllers/reviewcontrollers.ts","./src/controllers/routecontrollers.ts","./src/controllers/usercontrollers.ts","./src/lib/convertor.ts","./src/lib/prisma.ts","./src/mail/checkacademic.ts","./src/mail/sendmail.ts","./src/mail/sort.ts","./src/middleware/checkauth.ts","./src/middleware/moderation.ts","./src/routes/chatroutes.ts","./src/routes/mruote.ts","./src/routes/postsroutes.ts","./src/routes/ratingroute.ts","./src/routes/reviewroutes.ts","./src/routes/roomroutes.ts","./src/routes/userroutes.ts","./src/validation/registerschema.ts"],"version":"5.6.3"}

0 comments on commit 566bcb8

Please sign in to comment.