Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyas Shah committed Dec 8, 2022
0 parents commit 607a3f9
Show file tree
Hide file tree
Showing 5 changed files with 1,640 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
23 changes: 23 additions & 0 deletions Submission.js
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;
32 changes: 32 additions & 0 deletions index.js
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");
})
Loading

0 comments on commit 607a3f9

Please sign in to comment.