-
-
Notifications
You must be signed in to change notification settings - Fork 0
Codex-generated pull request #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,40 +1,66 @@ | ||
| require("dotenv").config(); | ||
| const express = require("express"); | ||
| const cors = require("cors"); | ||
| const helmet = require("helmet"); | ||
| const morgan = require("morgan"); | ||
| const rateLimit = require("express-rate-limit"); | ||
| const http = require("http"); | ||
| require('dotenv').config(); | ||
| const express = require('express'); | ||
| const cors = require('cors'); | ||
| const helmet = require('helmet'); | ||
| const morgan = require('morgan'); | ||
| const rateLimit = require('express-rate-limit'); | ||
| const http = require('http'); | ||
| const path = require('path'); | ||
|
|
||
| const app = express(); | ||
| const port = process.env.PORT || 3000; | ||
| // Middleware for parsing JSON and urlencoded data | ||
|
|
||
| app.use(express.json()); | ||
| app.use(express.urlencoded({ extended: true })); | ||
|
|
||
| app.use(helmet()); // Security Headers | ||
| app.use(morgan("short")); | ||
| // Rate Limit for brute force attacks | ||
| app.use(cors()); | ||
| app.use(helmet()); | ||
| app.use(morgan('short')); | ||
| app.use( | ||
| rateLimit({ | ||
| windowMs: 60 * 60 * 1000, // 1 hour | ||
| windowMs: 60 * 60 * 1000, | ||
| max: 100, | ||
| }), | ||
| ); | ||
|
|
||
| app.use(express.static(path.join(__dirname))); | ||
|
|
||
| app.post('/api/discovery-contact', (req, res) => { | ||
| const { name, email, goal, timeline, message } = req.body; | ||
|
|
||
| if (!name || !email || !goal || !timeline || !message) { | ||
| return res.status(400).json({ error: 'All discovery contact fields are required.' }); | ||
| } | ||
|
|
||
| return res.status(201).json({ message: 'Discovery contact submitted successfully.' }); | ||
| }); | ||
|
|
||
| app.post('/api/subscribe', (req, res) => { | ||
| const { email } = req.body; | ||
|
|
||
| if (!email) { | ||
| return res.status(400).json({ error: 'Email is required.' }); | ||
| } | ||
|
|
||
| return res.status(201).json({ message: 'Subscription successful.' }); | ||
| }); | ||
|
|
||
| app.get('*', (req, res) => { | ||
| res.sendFile(path.join(__dirname, 'index.html')); | ||
| }); | ||
|
|
||
| const server = http.createServer(app); | ||
|
|
||
| process.on("uncaughtException", (error) => { | ||
| console.error("Uncaught exception:", error); | ||
| process.on('uncaughtException', (error) => { | ||
| console.error('Uncaught exception:', error); | ||
| server.close(() => process.exit(1)); | ||
| }); | ||
|
|
||
| server.listen(port, () => { | ||
| console.log("Server is started on port " + port); | ||
| process.on('unhandledRejection', (error) => { | ||
| console.error('Unhandled rejection:', error); | ||
| }); | ||
| process.on("unhandledRejection", (error) => { | ||
| console.error("Unhandled Rejection:", error); | ||
| }); | ||
| process.on("rejectionHandled", (error) => { | ||
| console.error("Rejection handled:", error); | ||
|
|
||
| server.listen(port, () => { | ||
| console.log(`Server is started on port ${port}`); | ||
| }); | ||
|
|
||
| module.exports = app; | ||
This file contains hidden or 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,240 +1,88 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Study Planner</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>Study Planner</h1> | ||
| </header> | ||
| <main> | ||
| <section id="schedule"> | ||
| <h2>Your Schedule</h2> | ||
| <!-- Schedule content goes here --> | ||
| </section> | ||
| <section id="tasks"> | ||
| <h2>Your Tasks</h2> | ||
| <!-- Task list and management interface goes here --> | ||
| <div id="taskForm"> | ||
| <form> | ||
| <!-- Form content for adding tasks --> | ||
| </form> | ||
| </div> | ||
| <div id="taskList"> | ||
| <!-- Dynamic task list will be rendered here --> | ||
| <ul id="tasksList"></ul> | ||
| </div> | ||
| </section> | ||
| </main> | ||
| <footer> | ||
| <p>© 2023 Study Planner</p> | ||
| </footer> | ||
| <script src="main.js"></script> | ||
| <script> | ||
| // Example fetch request to an API endpoint | ||
| fetch('/api/tasks') | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| // Handle data (tasks) here | ||
| console.log(data); | ||
| }) | ||
| .catch(error => { | ||
| console.error('Error fetching tasks:', error); | ||
| }); | ||
| </script> | ||
| <script> | ||
| // Function to fetch and display tasks | ||
| function fetchAndDisplayTasks() { | ||
| fetch('/api/tasks') | ||
| .then(response => response.json()) | ||
| .then(tasks => { | ||
| const tasksList = document.getElementById('tasksList'); | ||
| tasksList.innerHTML = ''; // Clear existing tasks | ||
| tasks.forEach(task => { | ||
| const taskItem = document.createElement('li'); | ||
| taskItem.textContent = task.title; | ||
| tasksList.appendChild(taskItem); | ||
| }); | ||
| }) | ||
| .catch(error => { | ||
| console.error('Error fetching tasks:', error); | ||
| }); | ||
| } | ||
| // Call the function on page load | ||
| document.addEventListener('DOMContentLoaded', fetchAndDisplayTasks); | ||
| </script> | ||
| </body> | ||
| </html> | ||
| ======= | ||
|
|
||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Study Planner</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Add viewport meta element --> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>Study Planner</h1> | ||
| </header> | ||
| <main> | ||
| <section id="schedule"> | ||
| <h2>Your Schedule</h2> | ||
| <!-- Schedule content goes here --> | ||
| </section> | ||
| <section id="tasks"> | ||
| <h2>Your Tasks</h2> | ||
| <!-- Task list and management interface goes here --> | ||
| <div id="taskForm"> | ||
| <form> | ||
| <!-- Form content for adding tasks --> | ||
| </form> | ||
| </div> | ||
| <div id="taskList"> | ||
| <!-- Dynamic task list will be rendered here --> | ||
| </div> | ||
| </section> | ||
| </main> | ||
| <footer> | ||
| <p>© 2023 Study Planner</p> | ||
| </footer> | ||
| <script src="main.js"></script> | ||
|
|
||
| </body> | ||
| </html> | ||
|
|
||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Added viewport meta element --> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| </body> | ||
| </html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Document</title> | ||
|
|
||
| </head> | ||
| <body> | ||
|
|
||
| </body> | ||
| </html> | ||
| <body> | ||
|
|
||
| </body> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Add viewport meta element --> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| </body> | ||
|
|
||
| </html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Added viewport meta element --> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| </body> | ||
| </html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Document</title> | ||
|
|
||
| </head> | ||
| <body> | ||
|
|
||
| </html> | ||
|
|
||
| <script> | ||
| // Example fetch request to an API endpoint | ||
| fetch('/api/tasks') | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| // Handle data (tasks) here | ||
| console.log(data); | ||
| }) | ||
| .catch(error => { | ||
| console.error('Error fetching tasks:', error); | ||
| }); | ||
| </script> | ||
|
|
||
| <script> | ||
| // Function to fetch and display tasks | ||
| function fetchAndDisplayTasks() { | ||
| fetch('/api/tasks') | ||
| .then(response => response.json()) | ||
| .then(tasks => { | ||
| const tasksList = document.getElementById('tasksList'); | ||
| tasksList.innerHTML = ''; // Clear existing tasks | ||
| tasks.forEach(task => { | ||
| const taskItem = document.createElement('li'); | ||
| taskItem.textContent = task.title; | ||
| tasksList.appendChild(taskItem); | ||
| }); | ||
| }) | ||
| .catch(error => { | ||
| console.error('Error fetching tasks:', error); | ||
| }); | ||
| } | ||
|
|
||
| // Call the function on page load | ||
| document.addEventListener('DOMContentLoaded', fetchAndDisplayTasks); | ||
| </script> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Study Planner</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>Study Planner</h1> | ||
| </header> | ||
|
|
||
| <main> | ||
| <section id="schedule"> | ||
| <h2>Your Schedule</h2> | ||
| <p>Plan your upcoming sessions and keep your progress on track.</p> | ||
| </section> | ||
|
|
||
| <section id="tasks"> | ||
| <h2>Your Tasks</h2> | ||
| <div id="taskForm"> | ||
| <form id="taskFormElement"> | ||
| <input type="text" id="taskTitle" placeholder="Title" required /> | ||
| <input type="text" id="taskDescription" placeholder="Description" required /> | ||
| <input type="date" id="taskDueDate" required /> | ||
| <label for="taskTitle">Title</label> | ||
| <input type="text" id="taskTitle" name="title" placeholder="Task title" required /> | ||
|
|
||
| <label for="taskDescription">Description</label> | ||
| <input type="text" id="taskDescription" name="description" placeholder="Task description" required /> | ||
|
|
||
| <label for="taskDueDate">Due date</label> | ||
| <input type="date" id="taskDueDate" name="dueDate" required /> | ||
|
|
||
| <button type="submit">Add Task</button> | ||
| </form> | ||
| </div> | ||
| <div id="taskList"></div> | ||
| </section> | ||
|
|
||
| <section id="discovery-contact"> | ||
| <h2>Discovery Contact Form</h2> | ||
| <form id="discoveryContactForm" novalidate> | ||
| <label for="contactName">Full name</label> | ||
| <input type="text" id="contactName" name="name" required /> | ||
|
|
||
| <label for="contactEmail">Email</label> | ||
| <input type="email" id="contactEmail" name="email" required /> | ||
|
|
||
| <label for="contactGoal">Primary goal</label> | ||
| <select id="contactGoal" name="goal" required> | ||
| <option value="" disabled selected>Select your goal</option> | ||
| <option value="time-management">Improve time management</option> | ||
| <option value="exam-prep">Exam preparation</option> | ||
| <option value="course-planning">Course planning</option> | ||
| <option value="accountability">Accountability coaching</option> | ||
| </select> | ||
|
|
||
| <label for="contactTimeline">Timeline</label> | ||
| <select id="contactTimeline" name="timeline" required> | ||
| <option value="" disabled selected>Select a timeline</option> | ||
| <option value="asap">As soon as possible</option> | ||
| <option value="2-weeks">Within 2 weeks</option> | ||
| <option value="1-month">Within a month</option> | ||
| </select> | ||
|
|
||
| <label for="contactMessage">Message</label> | ||
| <textarea id="contactMessage" name="message" rows="4" required></textarea> | ||
|
|
||
| <button type="submit">Send Discovery Request</button> | ||
| <p id="discoveryContactStatus" class="form-status" aria-live="polite"></p> | ||
| </form> | ||
| </section> | ||
| </main> | ||
|
|
||
| <footer> | ||
| <p>© Study Planner</p> | ||
| <form id="footerSubscribeForm" class="subscribe-form" novalidate> | ||
| <label for="subscribeEmail">Subscribe for study tips</label> | ||
| <div class="subscribe-row"> | ||
| <input type="email" id="subscribeEmail" name="email" placeholder="you@example.com" required /> | ||
| <button type="submit">Subscribe</button> | ||
| </div> | ||
| <p id="subscribeStatus" class="form-status" aria-live="polite"></p> | ||
| </form> | ||
| </footer> | ||
|
|
||
| <script src="main.js"></script> | ||
| </body> | ||
| </html> | ||
| </html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
express.static(path.join(__dirname))exposes the entire repository tree as web-accessible static files (for example source files and backup scripts under the project root), which unnecessarily leaks implementation details and increases attack surface in production. Static hosting should be limited to a specific client-assets directory instead of the repo root.Useful? React with 👍 / 👎.