Skip to content

Commit

Permalink
worked on it
Browse files Browse the repository at this point in the history
  • Loading branch information
yzFrankli committed Oct 25, 2024
1 parent 4db5e12 commit 0d5f8e8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ const User = mongoose.model("users", UserSchema)
// Contact Schema

// TODO (Frank & Madeline): Create a ContactSchema
const ContactSchema = new Schema ({
name: { type: String, required: true},
email: { type: String, required: true},
subject: { type: String, required: true},
message: { type: String, required: true}
})

const Contact = mongoose.model("contact", ContactSchema)

// Class Schema

Expand All @@ -64,7 +71,21 @@ const User = mongoose.model("users", UserSchema)
// Contact

// TODO (Frank & Madeline): Create an endpoint to receive and upload contact inquiries to the database

app.post('/contact', async (req, res) => {
try {
const newContact = new Contact ({
name,
email,
subject,
message
})
await newContact.save()
}
catch (err) {
console.error('Error saving contact data:', err);
process.exit(1);
}
})

// Classes

Expand Down

0 comments on commit 0d5f8e8

Please sign in to comment.