Skip to content

Commit

Permalink
Merge pull request #4 from LifeWatcher123/rebrand
Browse files Browse the repository at this point in the history
Merge UI changes to main.
  • Loading branch information
chrsrns authored Jan 30, 2024
2 parents 5287eb0 + c2d4b14 commit a39f2e7
Show file tree
Hide file tree
Showing 78 changed files with 4,436 additions and 3,190 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JB Website
# Scheduler Project

## Installation

Expand All @@ -10,7 +10,7 @@

1. Create the MySQL server in a Podman container.

podman run -d --name=mysql1 -p 3306:3306 -v ./mysqldata:/var/lib/mysql:Z -e MYSQL_ROOT_PASSWORD=Jeybee0987 -e MYSQL_ROOT_HOST=% -e MYSQL_USER=infodb_user -e MYSQL_PASSWORD=JB123 -e MYSQL_DATABASE=infodb mysql/mysql-server
podman run -d --name=mysql1 -p 3306:3306 -v ./mysqldata:/var/lib/mysql:Z -e MYSQL_ROOT_PASSWORD=password -e MYSQL_ROOT_HOST=% -e MYSQL_USER=infodb_user -e MYSQL_PASSWORD=sqlpassword -e MYSQL_DATABASE=infodb mysql/mysql-server

2. Start the MySQL Podman container.

Expand All @@ -24,11 +24,13 @@

4. Grant access to the database and to creating [shadow databases](https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database).

GRANT CREATE, ALTER, DROP, REFERENCES ON *.* TO 'infodb_user'@'%';
GRANT CREATE, ALTER, DROP, REFERENCES, INDEX ON *.* TO 'infodb_user'@'%';

GRANT ALL PRIVILEGES ON infodb.* TO 'infodb_user'@'%';

5. Create the database structure using Prisma.

npx prisma db push
npx prisma migrate dev --name init

To update the database on deployment, run `npx prisma migrate deploy`. This will require that the migration files are included in the version control.
74 changes: 37 additions & 37 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
const cors = require("cors");
const express = require("express");
const app = express();
const fakedata = require("./prisma/fake-data")
const fakedata = require("./prisma/fake-data");
const { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();

require("dotenv").config();
const resetAll = async () => {
console.log("Resetting online status")
console.log(await prisma.user.updateMany({
where: {
isOnline: true
},
data: {
isOnline: false
}
}))
}
resetAll()
console.log("Resetting online status");
console.log(
await prisma.user.updateMany({
where: {
isOnline: true,
},
data: {
isOnline: false,
},
}),
);
};
resetAll();

app.use(express.json());
app.use(cors());

// For testing, add intentional delay
// app.use(function(req, res, next) { setTimeout(next, 500) });
app.use(function (req, res, next) {
setTimeout(next, 1500);
});

// Frontend Static
const path = __dirname + "/src-frontend-react/build/";
Expand All @@ -41,59 +45,55 @@ app.use("/backend/users", users);
const appointments = require("./routes/appointments.routes.js");
app.use("/backend/appointments", appointments);

const notifications = require('./routes/notifications.routes')
app.use("/backend/notifications", notifications)
const notifications = require("./routes/notifications.routes");
app.use("/backend/notifications", notifications);

const medrecords = require('./routes/medrecords.routes')
app.use("/backend/medrecords", medrecords)
const medrecords = require("./routes/medrecords.routes");
app.use("/backend/medrecords", medrecords);

const guidancerecords = require('./routes/guidancerecords.routes')
app.use("/backend/guidancerecords", guidancerecords)
const guidancerecords = require("./routes/guidancerecords.routes");
app.use("/backend/guidancerecords", guidancerecords);

const feedback = require('./routes/feedback.routes')
app.use("/backend/feedback", feedback)
const feedback = require("./routes/feedback.routes");
app.use("/backend/feedback", feedback);

app.post("/backend/fakestudentuser", async (req, res) => {
try {
const name = await prisma.user.create(
{
data: fakedata.fakeStudentUser()
}
);
const name = await prisma.user.create({
data: fakedata.fakeStudentUser(),
});
res.json(name);
} catch (error) {
console.error(error);
res.status(500).json({ error: "An error occurred!" });
}
})
});

app.post("/backend/fakestaffuser", async (req, res) => {
try {
const name = await prisma.user.create(
{
data: fakedata.fakeStaffUser()
}
);
const name = await prisma.user.create({
data: fakedata.fakeStaffUser(),
});
res.json(name);
} catch (error) {
console.error(error);
res.status(500).json({ error: "An error occurred!" });
}
})
});

// Define error handling middleware
app.use((err, req, res, next) => {
// Handle the error here, for example, send an error response to the client
console.error(err)
console.error(err);
if (res.statusCode !== 200) {
res.status(500);
}
res.json({ error: 'Something went wrong' });
res.json({ error: "Something went wrong" });
});

// Define a catch-all route at the end of your routes
app.all('*', (req, res) => {
res.redirect('/');
app.all("*", (req, res) => {
res.redirect("/");
});

// function print(path, layer) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jb-project",
"name": "Scheduler-System-Demo",
"version": "1.0.0",
"description": "",
"description": "A scheduler system utilizing multiple JS technologies.",
"keywords": [],
"author": "",
"private": true,
Expand Down
Loading

0 comments on commit a39f2e7

Please sign in to comment.