-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
8 changed files
with
11,943 additions
and
9,641 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,16 @@ | ||
const express =require('express') | ||
const router=express.Router() | ||
|
||
router.post('/meetinfo',(req,res)=> | ||
{ | ||
try { | ||
console.log('Meet Data:', global.meetdata); | ||
|
||
res.send([global.meetdata]); | ||
|
||
} catch (error) { | ||
console.error(error.message); | ||
res.send("Sever Error") | ||
} | ||
}) | ||
module.exports=router; |
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,51 @@ | ||
// const mongoose =require('mongoose'); | ||
// const mongoURI="mongodb+srv://kaloa2025:[email protected]/hackhive?retryWrites=true&w=majority&appName=Cluster0"; | ||
// const mongoDB = async () => { | ||
// try { | ||
// await mongoose.connect(mongoURI); | ||
// console.log('Connected!'); | ||
|
||
// const fetched_data = mongoose.connection.db.collection("meetdata"); | ||
// const data = await fetched_data.find({}).toArray(); | ||
// global.meet = data; | ||
// console.log('Data fetched and stored successfully.'); | ||
// } catch (error) { | ||
// console.log('err: ', error); | ||
// } | ||
// }; | ||
// module.exports=mongoDB; | ||
|
||
// const mongoose = require('mongoose'); | ||
// const mongoURI = "mongodb+srv://kaloa2025:[email protected]/hackhive?retryWrites=true&w=majority&appName=Cluster0"; | ||
|
||
// const connectDB = async () => { | ||
// try { | ||
// await mongoose.connect(mongoURI, { | ||
// useNewUrlParser: true, | ||
// useUnifiedTopology: true | ||
// }); | ||
// console.log('Connected to MongoDB'); | ||
// } catch (error) { | ||
// console.error('MongoDB connection error:', error); | ||
// process.exit(1); // Exit process with failure | ||
// } | ||
// }; | ||
|
||
console.log("starting") | ||
const mongoose =require('mongoose'); | ||
const mongoURI='mongodb://localhost:27017/hackhive'; | ||
// const mongoURI='mongodb+srv://kaloa2025:[email protected]/hackhive?retryWrites=true&w=majority&appName=Cluster0'; | ||
const mongoDB = () => { | ||
try { | ||
mongoose.connect(mongoURI); | ||
console.log('Connected!'); | ||
const meet=require('./models/Meet'); | ||
const fetched_data = mongoose.connection.db.collection('meets'); | ||
const mdata = fetched_data.find({}).toArray(); | ||
global.meetdata = mdata; | ||
console.log('Data fetched and stored successfully.'); | ||
}catch(error){ | ||
console.log('err: ', error); | ||
} | ||
}; | ||
module.exports=mongoDB; |
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,95 @@ | ||
// const express=require('express') | ||
// const app = express() | ||
// var cors=require('cors'); | ||
|
||
// const port =5000 | ||
// const mongoDB=require('./db') | ||
// mongoDB(); | ||
// app.use((req,res,next)=>{ | ||
// res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000'); | ||
// res.setHeader('Access-Control-Allow-Methods', 'POST'); | ||
// res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); | ||
// next(); | ||
// }) | ||
// app.get('/',(req,res)=> | ||
// { | ||
// res.send("Hello") | ||
// }) | ||
// app.use(cors()); | ||
// app.use(express.json()) | ||
// app.use('/api', require('./Routes/MeetInfo')); | ||
// app.listen(port,()=> | ||
// { | ||
// console.log(`Example listening on ${port}`) | ||
// }) | ||
|
||
// const express = require('express'); | ||
// const cors = require('cors'); | ||
// const mongoose=require('mongoose') | ||
// const connectDB = require('./db'); | ||
// const meetInfoRoutes = require('./Routes/MeetData'); | ||
|
||
// const app = express(); | ||
// const port = 5000; | ||
|
||
// // Connect to MongoDB | ||
// connectDB(); | ||
|
||
// // Middleware | ||
// app.use(cors()); | ||
// app.use(express.json()); | ||
|
||
// // Routes | ||
// app.use('/api', meetInfoRoutes); | ||
|
||
// // Start server | ||
// app.listen(port, () => { | ||
// console.log(`Server is running on port ${port}`); | ||
// // }); | ||
|
||
// const express=require('express') | ||
// const mongoose=require('mongoose') | ||
// const cors=require('cors') | ||
// const MeetModel =require('./models/Meet') | ||
// const app=express() | ||
// app.use(cors()); | ||
// app.use(express.json()); | ||
|
||
// mongoose.connect("mongodb+srv://kaloa2025:[email protected]/hackhive?retryWrites=true&w=majority&appName=Cluster0") | ||
|
||
// app.get('/getMeet',(req,res)=>{ | ||
// MeetModel.find().then(meetData=>res.json(meetData)).catch(err=>res.json(err)) | ||
// }) | ||
|
||
// app.listen(3000,()=>{ | ||
// console.log("Sever listening"); | ||
// }) | ||
|
||
|
||
|
||
|
||
const express=require('express') | ||
const app = express() | ||
var cors=require('cors'); | ||
|
||
const port =5000 | ||
const mongoDB=require('./dbmeet') | ||
mongoDB(); | ||
app.use((req,res,next)=>{ | ||
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000'); | ||
res.setHeader('Access-Control-Allow-Methods', 'GET'); | ||
res.setHeader('Access-Control-Allow-Methods', 'POST'); | ||
res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); | ||
next(); | ||
}) | ||
app.get('/',(req,res)=> | ||
{ | ||
res.send("Hello") | ||
}) | ||
app.use(cors()); | ||
app.use(express.json()) | ||
app.use('/api',require('./Routes/MeetData')); | ||
app.listen(port,()=> | ||
{ | ||
console.log(`Example listening on ${port}`) | ||
}) |
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,9 @@ | ||
const mongoose=require('mongoose') | ||
const{ Schema }=mongoose; | ||
|
||
const MeetSchema = new mongoose.Schema({ | ||
id: String, | ||
title: String, | ||
date: String | ||
}); | ||
module.exports=mongoose.model('Meet',MeetSchema) |
Oops, something went wrong.