Skip to content

Commit

Permalink
Update server.js
Browse files Browse the repository at this point in the history
changed .env file and made attempt at contact endpoint
  • Loading branch information
yzFrankli committed Oct 28, 2024
1 parent 3b3bfe2 commit e4be9e8
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ const User = mongoose.model("users", UserSchema)

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

const Contact = mongoose.model("contact", ContactSchema)
const Contact = mongoose.model('Contact', ContactSchema);
// export default Contact;

// Class Schema

Expand All @@ -71,6 +72,23 @@ const Contact = mongoose.model("contact", ContactSchema)
// Contact

// TODO (Frank & Madeline): Create an endpoint to receive and upload contact inquiries to the database
// async function uploadContact () {
// const article = new Contact({
// name: 'test user',
// email: '[email protected]',
// subject: 'Test Inquiry',
// message: 'Test message'

// });

// await article.save();
// const firstContact = await Contact.findOne({});
// console.log(firstContact);
// }
// uploadContact().catch(console.error);

// const firstArticle = await Contact.findOne({});
// console.log(firstArticle);
app.post('/api/contact', async (req, res) => {
const{ name, email, subject, message } = req.body
try {
Expand Down

0 comments on commit e4be9e8

Please sign in to comment.