Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RamakrushnaBiswal authored Oct 5, 2024
2 parents e89064b + e5492ae commit 6bf5fa0
Show file tree
Hide file tree
Showing 21 changed files with 369 additions and 149 deletions.
22 changes: 22 additions & 0 deletions .all-contributorsrc
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"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
frontend/.env
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 🎲 PlayCafe Website
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

<!-- ALL-CONTRIBUTORS-BADGE:END -->

Welcome to the **[PlayCafe]** website repository! This project is part of **GirlScript Summer of Code (GSSoC) Extended** 🚀. Our cafe offers a warm and exciting environment for board game enthusiasts to gather, relax, and enjoy great food. This repository contains the code for the cafe's official website, which aims to create a fun and immersive online presence.
if you have any doubt about the project join [discord](https://discord.gg/Jh3bWQ7FRN)
Expand Down Expand Up @@ -81,16 +84,18 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
- Make sure you show some love by giving ⭐ to our repository

<br>
<center>
<div>

[![All Contributors](https://img.shields.io/github/all-contributors/projectOwner/projectName?color=ee8449&style=flat-square)](#contributors)
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->


<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->


## ⭐Support

- 💰 Become our [Sponsor](https://github.com/sponsors/RamakrushnaBiswal)!
- ⭐ Star our Repo



1 change: 0 additions & 1 deletion backend/.env

This file was deleted.

2 changes: 2 additions & 0 deletions backend/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
4 changes: 1 addition & 3 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
Expand All @@ -23,5 +22,4 @@ dist-ssr
*.sln
*.sw?
.env


package-lock.json
16 changes: 16 additions & 0 deletions backend/config/api.info.js
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",
};
49 changes: 49 additions & 0 deletions backend/controller/feedback.controller.js
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"
// }
2 changes: 2 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ mongoose
app.use("/api", require("./routes/index"));

app.listen(port, () => console.log(`Server is running on port ${port}!`));

module.exports = app;
51 changes: 51 additions & 0 deletions backend/models/feedback.model.js
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,
};
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dotenv": "^16.4.5",
"express": "^4.21.0",
"mongoose": "^8.7.0",
"validator": "^13.12.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
19 changes: 19 additions & 0 deletions backend/routes/feedbackRouter.js
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;
12 changes: 12 additions & 0 deletions backend/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ const Reservation = require("../models/reservation.model");

const router = express.Router();

let feedbackRouter;
try {
feedbackRouter = require("./feedbackRouter");
} catch (error) {
console.error("Error loading feedbackRouter:", error);
feedbackRouter = (req, res, next) => {
res
.status(500)
.json({ error: "Feedback functionality is currently unavailable" });
};
}
router.use("/feedback", feedbackRouter);
router.use("/reservation", require("./reservationRouter"));
router.get("/", (req, res) => {
res.json({
Expand Down
15 changes: 15 additions & 0 deletions backend/vercel.json
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"
}
]
}
5 changes: 5 additions & 0 deletions frontend/.env.example
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
9 changes: 8 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ node_modules
dist
dist-ssr
*.local

.env
# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand All @@ -22,3 +22,10 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Frontend build
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"preview": "vite preview"
},
"dependencies": {
"@kinde-oss/kinde-auth-react": "^4.0.4",
"@splidejs/splide": "^4.1.4",
"@splidejs/splide-extension-auto-scroll": "^0.5.3",
"autoprefixer": "^10.4.19",
"axios": "^1.7.7",
"clsx": "^2.1.1",
"dotenv": "^16.4.5",
"framer-motion": "^11.5.6",
"gsap": "^3.12.5",
"react": "^18.3.1",
Expand Down
21 changes: 15 additions & 6 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
// src/App.js
import React from 'react';

import './App.css';
import Navbar from '../src/components/Shared/Navbar';
import Footer from "../src/components/Shared/Footer"
import { Outlet } from 'react-router-dom';

import {KindeProvider} from "@kinde-oss/kinde-auth-react";

function App() {
return (
<div>
<Navbar />
<Outlet />
<Footer />
</div>
<KindeProvider
clientId={import.meta.env.VITE_KINDE_CLIENT_ID}
domain={import.meta.env.VITE_KINDE_DOMAIN}
redirectUri={import.meta.env.VITE_KINDE_REDIRECT_URI}
logoutUri={import.meta.env.VITE_KINDE_LOGOUT_REDIRECT_URI}
>
<Navbar />
<Outlet />
<Footer />
</KindeProvider>


);
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Pages/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export default function Register() {
console.log(guests);
console.log(time);
console.log(date);
// console.log(import.meta.env.VITE_BACKEND_URL);
e.preventDefault();
fetch("http://localhost:3000/api/reservation/create", {
fetch(`${import.meta.env.VITE_BACKEND_URL}/api/reservation/create`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
Loading

0 comments on commit 6bf5fa0

Please sign in to comment.