Added docker compose, fixed all file paths, updated readme, fixed Async function bcrypt compare

This commit is contained in:
Alex Holliday committed 2024-06-14 12:07:34 -07:00
1 parent 51315bb8ed
commit c8bcc59b52
10 files changed
+101 -36

No files matched your search

+1
View File
@@ -0,0 +1 @@
./docker
+2 -1
View File
@@ -3,4 +3,5 @@ node_modules
*.log
*.sh
docker/mongo/data/*
docker/redis/data/*
docker/redis/data/*
!docker/build_images.sh
+1
View File
@@ -88,6 +88,7 @@ const loginController = async (req, res, next) => {
const user = await req.db.getUserByEmail(req, res);
// Compare password
const match = await user.comparePassword(req.body.password);
if (match !== true) {
throw new Error("Incorrect password");
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# Change directory to root Server directory for correct Docker Context
cd ..
# MongoDB
mongoDB="./docker/mongoDB.Dockerfile"
# Redis
redis="./docker/redis.Dockerfile"
# Server
server="./docker/server.Dockerfile"
docker build -f $mongoDB -t uptime_database_mongo .
docker build -f $redis -t uptime_redis .
docker build -f $server -t uptime_server .
echo "All images built"
+12 -3
View File
@@ -1,4 +1,4 @@
version: '3'
version: "3"
services:
server:
image: uptime_server:latest
@@ -10,6 +10,15 @@ services:
- redis
- mongodb
redis:
image: uptime_redis
image: uptime_redis:latest
ports:
- "6379:6379"
volumes:
- ./redis/data:/data
mongodb:
image: uptime_database_mongo
image: uptime_database_mongo:latest
command: ["mongod", "--quiet"]
ports:
- "27017:27017"
volumes:
- ./mongo/data:/data/db
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
FROM node:20-alpine
FROM node:20
WORKDIR /app
+3 -2
View File
@@ -46,8 +46,9 @@ UserSchema.pre("save", async function (next) {
next();
});
UserSchema.methods.comparePassword = function (submittedPassword) {
return bcrypt.compare(submittedPassword, this.password);
UserSchema.methods.comparePassword = async function (submittedPassword) {
res = await bcrypt.compare(submittedPassword, this.password);
return res;
};
module.exports = mongoose.model("User", UserSchema);