-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Showing
21 changed files
with
369 additions
and
149 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,4 +1,26 @@ | ||
{ | ||
"files": [ | ||
"README.md" | ||
], | ||
"imageSize": 100, | ||
"commit": false, | ||
"commitType": "docs", | ||
"commitConvention": "angular", | ||
"contributors": [ | ||
{ | ||
"login": "mishradev1", | ||
"name": "Dev Mishra", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/118660840?v=4", | ||
"profile": "https://github.com/mishradev1", | ||
"contributions": [ | ||
"code" | ||
] | ||
} | ||
], | ||
"contributorsPerLine": 7, | ||
"skipCi": true, | ||
"repoType": "github", | ||
"repoHost": "https://github.com", | ||
"projectName": "PlayCafe", | ||
"projectOwner": "RamakrushnaBiswal" | ||
} |
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 @@ | ||
frontend/.env |
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 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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
message: "Welcome to the feedback API!", | ||
version: "1.0.0", | ||
endpoints: { | ||
createFeedback: { | ||
path: "/create", | ||
method: "POST", | ||
parameters: { | ||
name: { type: "string", required: true }, | ||
email: { type: "string", required: true }, | ||
message: { type: "string", required: true }, | ||
}, | ||
}, | ||
}, | ||
documentation: "https://api-docs-url.com", | ||
}; |
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,49 @@ | ||
const { z } = require("zod"); | ||
const { Feedback } = require("../models/feedback.model"); | ||
|
||
// Define the Zod schema for feedback validation | ||
const feedbackSchema = z.object({ | ||
name: z.string().min(2).max(100), | ||
email: z.string().email(), | ||
feedback: z.string().min(10), | ||
}); | ||
|
||
async function createFeedback(req, res) { | ||
try { | ||
const validationResult = feedbackSchema.safeParse(req.body); | ||
|
||
if (!validationResult.success) { | ||
console.error("Validation error:", validationResult.error.errors); | ||
return res.status(400).json({ | ||
success: false, | ||
message: "Validation failed", | ||
errors: validationResult.error.errors, | ||
}); | ||
} | ||
|
||
const feedback = await Feedback.create(validationResult.data); | ||
|
||
res.status(201).json({ | ||
success: true, | ||
message: "Feedback created successfully", | ||
data: feedback, | ||
}); | ||
} catch (error) { | ||
console.error("Error creating feedback:", error); | ||
res.status(500).json({ | ||
success: false, | ||
message: "An error occurred while creating the feedback", | ||
}); | ||
} | ||
} | ||
|
||
module.exports = { | ||
createFeedback, | ||
}; | ||
|
||
//dummy api call for feedback | ||
// { | ||
// "name": "John Doe", | ||
// "email": "[email protected]", | ||
// "feedback": "This is a dummy feedback" | ||
// } |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const mongoose = require("mongoose"); | ||
const Schema = mongoose.Schema; | ||
const validator = require("validator"); | ||
|
||
const feedbackSchema = new Schema( | ||
{ | ||
name: { | ||
type: String, | ||
required: true, | ||
trim: true, | ||
maxlength: [100, "Name cannot be more than 100 characters"], | ||
}, | ||
email: { | ||
type: String, | ||
required: true, | ||
trim: true, | ||
lowercase: true, | ||
maxlength: [255, "Email cannot be more than 255 characters"], | ||
match: [ | ||
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/, | ||
"Please fill a valid email address", | ||
], | ||
}, | ||
feedback: { | ||
type: String, | ||
required: true, | ||
trim: true, | ||
maxlength: [1000, "Feedback cannot be more than 1000 characters"], | ||
}, | ||
createdAt: { | ||
type: Date, | ||
default: Date.now, | ||
}, | ||
}, | ||
{ | ||
timestamps: true, | ||
} | ||
); | ||
|
||
feedbackSchema.pre("save", function (next) { | ||
const feedback = this; | ||
feedback.name = validator.escape(feedback.name); | ||
feedback.feedback = validator.escape(feedback.feedback); | ||
next(); | ||
}); | ||
|
||
const Feedback = mongoose.model("Feedback", feedbackSchema); | ||
|
||
module.exports = { | ||
Feedback, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const express = require("express"); | ||
const { Feedback } = require("../models/feedback.model"); | ||
const createFeedback = require("../controller/feedback.controller"); | ||
|
||
const router = express.Router(); | ||
|
||
router.post("/create", createFeedback); | ||
|
||
const apiInfo = require("../config/api.info"); | ||
|
||
router.get("/", (req, res) => { | ||
try { | ||
res.json(apiInfo); | ||
} catch (error) { | ||
res.status(500).json({ error: "Internal server error" }); | ||
} | ||
}); | ||
|
||
module.exports = router; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": 2, | ||
"builds": [ | ||
{ | ||
"src": "index.js", | ||
"use": "@vercel/node" | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"src": "/(.*)", | ||
"dest": "index.js" | ||
} | ||
] | ||
} |
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,5 @@ | ||
VITE_KINDE_CLIENT_ID=YOUR_CLIENT_ID | ||
VITE_KINDE_DOMAIN=YOUR_DOMAIN | ||
VITE_KINDE_REDIRECT_URI=REDIRECT_URL | ||
VITE_KINDE_LOGOUT_REDIRECT_URI=LOGOUT_REDIRECT_URI | ||
VITE_BACKEND_URL=your_backend_url |
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
Oops, something went wrong.