first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-05-06 10:14:26 -04:00
commit 2692a07db8
10 changed files with 1553 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import User from "../model/userModel.js";
export const create = async (req,res)=>{
try {
const userData = new User(req.body);
const { email } = userData;
const userExist = await User.findOne({email});
if (userExist) {
return res.status(400).json({message: "User already exixt"});
}
const saveUser = await userData.save();
res.status(200).json(saveUser);
} catch (error) {
res.status(500).json({error: `Internal Server error 002 ${error} ` });
}
}
export const fetch = async (req, res)=>{
try{
return res.json("Hello Worlds");
}catch(error){
res.status(500).json({error: "Internal Server error"});
}
}
+38
View File
@@ -0,0 +1,38 @@
import axios from "axios";
import dotenv from "dotenv"
export const fetch = async (req, res)=>{
try{
let config = {
headers: {
'Authorization': 'Bearer ' + `${process.env.VERIFY_ME_PUBLIC_TEST_SECRET}`,
'Content-Type': 'application/json'
}
};
const bodyParameters = {
"firstname":"John",
"lastname":"Doe",
"dob":"04-04-1944"
};
axios.post(
`${process.env.VERIFY_ME_ENDPOINT}/10000000001`,
bodyParameters
,
config
)
.then( ( response ) => {
return res.json({res : response.data});
//console.log( response )
} )
.catch()
}catch(error){
res.status(500).json({error: "Internal Server error"});
}
}