-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29ffb85
commit 79589af
Showing
5 changed files
with
73 additions
and
36 deletions.
There are no files selected for viewing
File renamed without changes.
Empty file.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import user from "./user" | ||
|
||
export { user } | ||
|
||
// import express, { Request, Response, Application } from "express" | ||
// import cors from "cors" | ||
// import dbConnect from "./config/dbConnect" | ||
// import mongoose from "mongoose" | ||
|
||
// import { Group, IGroup } from "./model/Group" | ||
// import { User, IUser } from "./model/User" | ||
// import { Expense } from "./model/Expense" | ||
// import { populate } from "dotenv" | ||
|
||
// dbConnect() | ||
|
||
// const app: Application = express() | ||
// app.use(cors()) | ||
// app.use(express.json()) // To parse JSON bodies | ||
// const port = process.env.PORT || 8000 | ||
|
||
// // Test POST endpoint | ||
// app.post("/test", (req: Request, res: Response) => { | ||
// console.log(req.body) // Log the request body to check what you are receiving | ||
|
||
// const { key } = req.body // Extract "key" from the request body | ||
// if (!key) { | ||
// return res.status(400).json({ message: "No key provided" }) | ||
// } | ||
|
||
// return res.status(200).json({ | ||
// message: "Data received successfully", | ||
// receivedKey: key, | ||
// }) | ||
// }) | ||
|
||
// // Start the server | ||
// app.listen(port, () => { | ||
// console.log(`Server running at http://localhost:${port}`) | ||
// }) |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import express from "express" | ||
|
||
const router = express.Router() | ||
const axios = require("axios").default | ||
|
||
router.post("/create-group", async (req, res) => { | ||
const { groupName, groupMembers } = req.body | ||
|
||
console.log("Received group data:", req.body) | ||
|
||
// Validate request body | ||
if (!groupName || !groupMembers) { | ||
return res.status(400).json({ | ||
message: "Invalid data. Please provide group name and group members.", | ||
}) | ||
} | ||
|
||
// Log the received data for debugging | ||
console.log("Received group data:", { | ||
groupName, | ||
groupMembers, | ||
}) | ||
|
||
// Create a new group | ||
const response = await axios.post("http://localhost:3001/api/group", { | ||
groupName, | ||
groupMembers, | ||
}) | ||
|
||
return res.status(response.status).json(response.data) | ||
}) | ||
|
||
export default router |