Skip to content

Commit

Permalink
front end and backend connected V0.0
Browse files Browse the repository at this point in the history
amman to do some changes
  • Loading branch information
Maxwel-mon committed Nov 30, 2022
1 parent 51b8f9b commit f9409e4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
16 changes: 14 additions & 2 deletions controller/User.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ exports.User_Findone=( req, res ) =>
{


User.find(req.body).then( user => res.json(' user found' + user)).catch( err => res.status(400).json('Error : ' + err));
User.findOne(req.body).then( user => res.json(' user found' + user)).catch( err => res.status(400).json('Error : ' + err));



}


/*
exports.User_FindStudents=( req, res ) =>
{
User.find(req.body).then( user => res.json(' user found' + user)).catch( err => res.status(400).json('Error : ' + err));
}
}*/
4 changes: 2 additions & 2 deletions models/User.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const mongoose = require('mongoose');
const User_Schema = new Schema({

name : {type : String, required : true , index:{unique : true }},
password: { type : String, required : true}

password: { type : String, required : true},
role : {type : String , required : true}

})

Expand Down
9 changes: 8 additions & 1 deletion nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ var massege = ' hello world';
console.log(massege);

const cors = require('cors');
const corsOptions ={

origin : '*',
credentials :true,
optionSuccessStatus:200,
}

const { MongoClient, HostAddress } = require("mongodb");
const { default: test } = require("node:test");
Expand All @@ -18,6 +24,7 @@ const client = new MongoClient(uri);
const app = express();
//app.use(bodyparser.json());
app.use(express.json());
app.use(cors(corsOptions));
app.use(express.urlencoded({ extended: false }));
const port = 5000;

Expand All @@ -35,7 +42,7 @@ app.use('/module', moduleRouter);
app.use ('/tutorial', tutorialrouter);
app.use ('/user', userrouter);

app.use(cors());



/////
Expand Down

0 comments on commit f9409e4

Please sign in to comment.