Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/17arindam/PlayCafe into goo…
Browse files Browse the repository at this point in the history
…gle_translate
  • Loading branch information
17arindam committed Oct 12, 2024
2 parents afc5391 + ebd6e84 commit 84fec75
Show file tree
Hide file tree
Showing 39 changed files with 895 additions and 384 deletions.
20 changes: 19 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ To get started, look at the existing [**create a new issue**](https://github.com
```bash
git push origin <your_branch_name>
```

## Please run it before pushing the code
To run ESLint, use the following commands:

```bash
npm run lint
```

To automatically fix linting issues, run:
```bash
npm run lint:fix
```
To format your code with Prettier, use:
```bash
npm run format
```


- Go to your forked repository on GitHub and click on `Compare & pull request`.
- Add an appropriate title and description to your pull request explaining your changes and efforts done.
- Click on `Create pull request`.
Expand Down Expand Up @@ -145,6 +163,6 @@ git commit -m "feat(auth): Implement user signup process (#789)"

---

- If something is missing here, or you feel something is not well described, please [raise an issue](https://github.com/mdazfar2/HelpOps-Hub/issues).
- If something is missing here, or you feel something is not well described, please [raise an issue](https://github.com/RamakrushnaBiswal/PlayCafe/issues).


61 changes: 48 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Make sure you follow our contributing guidlines:- [here](https://github.com/Ram
npm run dev
4. Open your browser at `http://localhost:3000` to see the project running! 🌟

Set-up using Dockerfile:-
Set-up using Dockerfile(Male sure you installed docker in your PC):-

1. **Build Docker Image**:
```bash
Expand All @@ -73,7 +73,21 @@ Set-up using docker-compose :-
1. **Build Docker Image and Run the Application**:
```bash
docker compose up --build
## Please run it before pushing the code
To run ESLint, use the following commands:
```bash
npm run lint
```
To automatically fix linting issues, run:
```bash
npm run lint:fix
```
To format your code with Prettier, use:
```bash
npm run format
```
## 🤝 Contributing
We love contributions! 💙 Whether you're a participant in **GSSoC** or an open-source enthusiast, we welcome your input. Here's how you can contribute:

Expand Down Expand Up @@ -133,22 +147,36 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Tejas Benibagde</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Ashwinib26">
<img src="https://avatars.githubusercontent.com/u/149402720?v=4" width="100;" alt="Ashwinib26"/>
<br />
<sub><b>Ashwini_ab</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/haseebzaki-07">
<img src="https://avatars.githubusercontent.com/u/147314463?v=4" width="100;" alt="haseebzaki-07"/>
<br />
<sub><b>Haseeb Zaki</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Suhas-Koheda">
<img src="https://avatars.githubusercontent.com/u/72063139?v=4" width="100;" alt="Suhas-Koheda"/>
<br />
<sub><b>Suhas Koheda</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/vishnuprasad2004">
<img src="https://avatars.githubusercontent.com/u/116942066?v=4" width="100;" alt="vishnuprasad2004"/>
<br />
<sub><b>Vishnu Prasad Korada</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/sajalbatra">
<img src="https://avatars.githubusercontent.com/u/125984550?v=4" width="100;" alt="sajalbatra"/>
Expand All @@ -157,10 +185,10 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
</a>
</td>
<td align="center">
<a href="https://github.com/vishnuprasad2004">
<img src="https://avatars.githubusercontent.com/u/116942066?v=4" width="100;" alt="vishnuprasad2004"/>
<a href="https://github.com/Amnyadav">
<img src="https://avatars.githubusercontent.com/u/127370497?v=4" width="100;" alt="Amnyadav"/>
<br />
<sub><b>Vishnu Prasad Korada</b></sub>
<sub><b>Aman Yadav</b></sub>
</a>
</td>
<td align="center">
Expand All @@ -177,6 +205,8 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Mahera Nayan</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Navneetdadhich">
<img src="https://avatars.githubusercontent.com/u/156535853?v=4" width="100;" alt="Navneetdadhich"/>
Expand All @@ -191,8 +221,6 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Tanishi Rai</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Shiva-Bajpai">
<img src="https://avatars.githubusercontent.com/u/141490705?v=4" width="100;" alt="Shiva-Bajpai"/>
Expand All @@ -207,13 +235,22 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Sawan kushwah </b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/devxMani">
<img src="https://avatars.githubusercontent.com/u/122438942?v=4" width="100;" alt="devxMani"/>
<br />
<sub><b>MANI </b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Ayush215mb">
<img src="https://avatars.githubusercontent.com/u/154300084?v=4" width="100;" alt="Ayush215mb"/>
<br />
<sub><b>Ayush Yadav</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/AliGates915">
<img src="https://avatars.githubusercontent.com/u/128673394?v=4" width="100;" alt="AliGates915"/>
Expand All @@ -235,8 +272,6 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Jai Dhingra</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Jay-1409">
<img src="https://avatars.githubusercontent.com/u/166749819?v=4" width="100;" alt="Jay-1409"/>
Expand All @@ -258,6 +293,8 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Bashua Mutiat</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/NilanchalaPanda">
<img src="https://avatars.githubusercontent.com/u/110488337?v=4" width="100;" alt="NilanchalaPanda"/>
Expand All @@ -279,8 +316,6 @@ Special thanks to our amazing mentors who are guiding this project! 🙌
<sub><b>Stuti </b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/Syed-Farazuddin">
<img src="https://avatars.githubusercontent.com/u/119295880?v=4" width="100;" alt="Syed-Farazuddin"/>
Expand Down
20 changes: 15 additions & 5 deletions backend/config/nodemailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ exports.sendSubscriptionConfirmation = async (email) => {
subject: "Thank You for Subscribing!",
text: emailText,
});
logger.info('Newsletter subscription confirmation sent successfully via email', { email });
logger.info(
"Newsletter subscription confirmation sent successfully via email",
{ email },
);
} catch (error) {
logger.error('Failed to send newsletter subscription confirmation email', { error, email });
if (error.code === 'ECONNREFUSED') {
throw new Error('Failed to connect to email server. Please try again later.');
logger.error("Failed to send newsletter subscription confirmation email", {
error,
email,
});
if (error.code === "ECONNREFUSED") {
throw new Error(
"Failed to connect to email server. Please try again later.",
);
} else {
throw new Error(`Failed to send subscription confirmation email: ${error.message}`);
throw new Error(
`Failed to send subscription confirmation email: ${error.message}`,
);
}
}
};
Expand Down
16 changes: 3 additions & 13 deletions backend/controller/admin.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ async function createAdmin(req, res) {
if (!validation.success) {
return res.status(400).json({ error: validation.error.errors });
}
const existingAdmin = await Admin.findOne({ email: req.body.email });

const existingAdmin = await Admin.findOne({ email: req.body.email });
if (existingAdmin) {
return res.status(409).json({ error: "Email is already registered" });
return res.status(409).json({ error: "Email is already registered" });
}

try {
Expand Down Expand Up @@ -52,15 +51,6 @@ async function loginAdmin(req, res) {
if (!validation.success) {
return res.status(400).json({ error: validation.error.errors });
}
const adminLoginSchema = z.object({
email: z.string().email("Invalid email address"),
password: z.string().min(6, "Password must be at least 6 characters long"),
});
// Validate the request body
const validation = adminLoginSchema.safeParse(req.body);
if (!validation.success) {
return res.status(400).json({ error: validation.error.errors });
}

try {
const admin = await Admin.findOne({ email: req.body.email });
Expand All @@ -69,7 +59,7 @@ async function loginAdmin(req, res) {
}
const validPassword = await bcrypt.compare(
req.body.password,
admin.password
admin.password,
);
if (!validPassword) {
return res.status(401).json({ error: "Invalid email or password" });
Expand All @@ -79,7 +69,7 @@ async function loginAdmin(req, res) {
process.env.JWT_SECRET,
{
expiresIn: "1h",
}
},
);
res.json({
message: "Login successful",
Expand Down
3 changes: 2 additions & 1 deletion backend/controller/customer.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
const bcrypt = require("bcrypt");
const { z } = require("zod");
const Customer = require("../models/customer.model");
Expand Down Expand Up @@ -63,7 +64,7 @@ async function loginCustomer(req, res) {
const token = jwt.sign(
{ id: customer._id },
process.env.JWT_SECRET,
{ expiresIn: "1h" } // Expires in 1 hour
{ expiresIn: "1h" }, // Expires in 1 hour
);
res.json({
message: "Login successful",
Expand Down
24 changes: 21 additions & 3 deletions backend/controller/event.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Event = require("../models/events.model");
// Create a new event
const createEvent = async (req, res) => {
try {
const { title, description, date, time, age, image } = req.body;
const { title, description, date, time, ageRange, image } = req.body;

// Input validation
if (!title || !description || !date || !time) {
Expand All @@ -16,7 +16,7 @@ const createEvent = async (req, res) => {
description,
date,
time,
age,
ageRange,
image,
});

Expand All @@ -34,6 +34,24 @@ const createEvent = async (req, res) => {
}
};

const deleteEvent = async (req, res) => {
try {
const eventId = req.query.id; // Change to req.query.id
console.log(eventId);
const event = await Event.findById(eventId); // Remove the object wrapper

if (!event) {
return res.status(404).json({ message: "Event not found" });
}

await Event.findByIdAndDelete(eventId);
res.status(200).json({ message: "Event deleted " });
} catch (error) {
logger.error("Error deleting event:", error);
res.status(500).json({ message: "Internal server error" });
}
};

const getEvents = async (req, res) => {
try {
const events = await Event.find();
Expand All @@ -49,4 +67,4 @@ const getEvents = async (req, res) => {
}
};

module.exports = { createEvent, getEvents };
module.exports = { createEvent, getEvents, deleteEvent };
59 changes: 34 additions & 25 deletions backend/controller/newsletter.controller.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
const NewsletterEmail = require('../models/newsletter.model'); // Import the Mongoose model
const { sendSubscriptionConfirmation } = require('../config/nodemailer'); // Import the mailer function
const NewsletterEmail = require("../models/newsletter.model"); // Import the Mongoose model
const { sendSubscriptionConfirmation } = require("../config/nodemailer"); // Import the mailer function

// Controller for handling newsletter subscriptions
exports.subscribeToNewsletter = async (req, res) => {
const { email } = req.body;
const { email } = req.body;

if (!email) {
return res.status(400).json({ error: 'Email is required' });
}

try {
// Check if the email already exists in the database
const existingEmail = await NewsletterEmail.findOne({ email });
if (existingEmail) {
return res.status(400).json({ error: 'This email is already subscribed.' });
}
if (!email) {
return res.status(400).json({ error: "Email is required" });
}

// Save the email to the database
const newEmail = new NewsletterEmail({ email });
await newEmail.save();
try {
// Check if the email already exists in the database
const existingEmail = await NewsletterEmail.findOne({ email });
if (existingEmail) {
return res
.status(400)
.json({ error: "This email is already subscribed." });
}

try {
await sendSubscriptionConfirmation(email);
} catch (error) {
console.error('Error sending confirmation email:', error);
return res.status(500).json({ error: 'Subscription successful, but there was an error sending the confirmation email.' });
}
// Save the email to the database
const newEmail = new NewsletterEmail({ email });
await newEmail.save();

return res.status(201).json({ message: 'Subscription successful! A confirmation email has been sent.' });
try {
await sendSubscriptionConfirmation(email);
} catch (error) {
console.error('Error subscribing to newsletter:', error);
return res.status(500).json({ error: 'Error subscribing to the newsletter.' });
console.error("Error sending confirmation email:", error);
return res.status(500).json({
error:
"Subscription successful, but there was an error sending the confirmation email.",
});
}

return res.status(201).json({
message: "Subscription successful! A confirmation email has been sent.",
});
} catch (error) {
console.error("Error subscribing to newsletter:", error);
return res
.status(500)
.json({ error: "Error subscribing to the newsletter." });
}
};
1 change: 1 addition & 0 deletions backend/middlewares/errrorMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
// middlewares/errorMiddleware.js
const logger = require("../config/logger"); // Assuming you have a logger set up

Expand Down
Loading

0 comments on commit 84fec75

Please sign in to comment.