-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shreyas Shah
committed
Dec 8, 2022
0 parents
commit 607a3f9
Showing
5 changed files
with
1,640 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const mongoose = require("mongoose"); | ||
const Schema = mongoose.Schema; | ||
|
||
const submissionSchema = new Schema({ | ||
details: [{ | ||
name: { | ||
type: String, | ||
}, | ||
regNo: { | ||
type: Number, | ||
}, | ||
phone: { | ||
type: Number | ||
} | ||
}], | ||
link: { | ||
type: String, | ||
} | ||
}); | ||
|
||
const Submission = mongoose.model("Submission", submissionSchema); | ||
|
||
module.exports = Submission; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const mongoose = require("mongoose"); | ||
const express = require("express"); | ||
const bodyParser = require("body-parser"); | ||
const Submission = require("./Submission"); | ||
const cors = require('cors'); | ||
require('dotenv').config(); | ||
const app = express(); | ||
app.use(cors()); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
const mongoUrl = 'mongodb+srv://shreyaslshah:[email protected]/exodus22?retryWrites=true&w=majority' | ||
mongoose.connect( | ||
mongoUrl, | ||
{ useNewUrlParser: true } | ||
); | ||
|
||
app.post('/submit', async function(req,res){ | ||
const details = req.body.details; | ||
const link = req.body.link; | ||
|
||
try { | ||
const doc = await Submission.create({details, link}); | ||
res.status(200).send(doc); | ||
} catch (error) { | ||
console.log(error); | ||
throw new Error('could not submit'); | ||
} | ||
}) | ||
|
||
app.listen(3010, () => { | ||
console.log("Server runnig on port 3010"); | ||
}) |
Oops, something went wrong.