-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from Karol-2/backend-fixes
Backend fixes
- Loading branch information
Showing
82 changed files
with
2,584 additions
and
1,435 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
node_modules/ | ||
coverage/ | ||
coverage/ | ||
frontend/.vite/ | ||
keycloak/ | ||
db/ |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
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,17 +1,38 @@ | ||
import dotenv from "dotenv"; | ||
import servers from "./server.js"; | ||
import usersRouter from "./routes/usersRoute.js"; | ||
import { createServer } from "node:http"; | ||
|
||
import cookieParser from "cookie-parser"; | ||
import cors from "cors"; | ||
import express from "express"; | ||
|
||
import authRouter from "./routes/authRoute.js"; | ||
import chatRouter from "./routes/chatRoute.js"; | ||
import { cleanUpData, importInitialData } from "./db.js"; | ||
import usersRouter from "./routes/usersRoute.js"; | ||
|
||
const { app } = servers; | ||
const app = express(); | ||
const port: number = 5000; | ||
|
||
dotenv.config(); | ||
const corsOptions = { | ||
origin: ["http://localhost:5000", "http://localhost:5173"], | ||
optionsSuccessStatus: 200, | ||
}; | ||
|
||
cleanUpData(); | ||
importInitialData().then((res) => console.log(res)); | ||
app.use(cors(corsOptions)); | ||
app.use((_req, res, next) => { | ||
res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE"); | ||
res.header("Access-Control-Allow-Headers", "Content-Type"); | ||
next(); | ||
}); | ||
app.use(cookieParser()); | ||
app.use(express.json({ limit: "10mb" })); | ||
|
||
const expressServer = createServer(app); | ||
|
||
expressServer.listen(port, () => { | ||
console.log(`HTTP server running on port ${port}`); | ||
}); | ||
|
||
app.use("/users", usersRouter); | ||
app.use("/auth", authRouter); | ||
app.use("/chat", chatRouter); | ||
|
||
export { expressServer }; |
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,19 @@ | ||
import "dotenv/config"; | ||
import "./httpServer.js"; | ||
import "./socketServer.js"; | ||
import "./kcAdminClient.js"; | ||
|
||
import { connect } from "mongoose"; | ||
|
||
import { cleanUpData, importInitialData } from "./importDb.js"; | ||
|
||
cleanUpData(); | ||
importInitialData().then((res) => console.log(res)); | ||
|
||
try { | ||
const uri = process.env.MONGODB_URI || "mongodb://localhost:27017"; | ||
await connect(`${uri}/chats`); | ||
console.log("Chat database started"); | ||
} catch (err) { | ||
console.error(err); | ||
} |
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
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,4 +1,5 @@ | ||
import { z } from "zod"; | ||
|
||
import { userPasswordSchema } from "./User.js"; | ||
|
||
type ChangePasswordReq = | ||
|
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,4 +1,4 @@ | ||
import { ZodType, z } from "zod"; | ||
import { z, ZodType } from "zod"; | ||
|
||
type NativeUser = { | ||
password: string; | ||
|
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,4 +1,4 @@ | ||
import { ZodType, z } from "zod"; | ||
import { z, ZodType } from "zod"; | ||
|
||
export default interface User { | ||
id: string; | ||
|
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,4 +1,4 @@ | ||
import { ZodType, z } from "zod"; | ||
import { z, ZodType } from "zod"; | ||
|
||
interface Page { | ||
page: string | number; | ||
|
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
Oops, something went wrong.