first commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
PORT = 6320
|
||||||
|
MONGO_URL = "mongodb://digifi:digifi@10.10.10.48:27017"
|
||||||
|
|
||||||
|
VERIFY_ME_ENDPOINT = "https://vapi.verifyme.ng/v1/verifications/identities/bvn"
|
||||||
|
VERIFY_ME_PUBLIC_KEY = "pk_live_9f4c2642862cb0190d3b72ca94579b2670fd797a124"
|
||||||
|
VERIFY_ME_PUBLIC_TEST_SECRET = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE1MjgzNywiZW52IjoidGVzdCIsImlhdCI6MTY1ODgyMzY0OH0.PszalhCuvCv6Y7kK41o3LuJh_R9kIlodbtWSi8HoFnI"
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
|
||||||
|
node_modules/*
|
||||||
|
|
||||||
@@ -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"});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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"});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import express from "express"
|
||||||
|
import mongoose from "mongoose"
|
||||||
|
import bodyParser from "body-parser"
|
||||||
|
import dotenv from "dotenv"
|
||||||
|
import route from "./routes/userRoute.js"
|
||||||
|
import verify_route from "./routes/verifyRoute.js"
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
dotenv.config();
|
||||||
|
const PORT = process.env.PORT || 5000;
|
||||||
|
const MONGOURL = process.env.MONGO_URL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mongoose.connect(MONGOURL).then(()=>{
|
||||||
|
console.log("Data connected");
|
||||||
|
app.listen(PORT,()=>{
|
||||||
|
console.log(`Server on ${PORT}`);
|
||||||
|
})
|
||||||
|
}).catch((error)=>{
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
app.use("/api/user", route);
|
||||||
|
app.use("/api/verify", verify_route);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
|
const userSchema = new mongoose.Schema({
|
||||||
|
name:{
|
||||||
|
type:String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
email:{
|
||||||
|
type:String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
address:{
|
||||||
|
type:String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default mongoose.model("users", userSchema );
|
||||||
Generated
+1385
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "digifimicro-loan",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "DigiFi Micro Loan",
|
||||||
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"start": "nodemon index.js"
|
||||||
|
},
|
||||||
|
"author": "ChiefSoft Works",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^1.6.8",
|
||||||
|
"body-parser": "^1.20.2",
|
||||||
|
"dotenv": "^16.4.5",
|
||||||
|
"express": "^4.19.2",
|
||||||
|
"mongoose": "^8.3.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^3.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import express from "express"
|
||||||
|
import { fetch,create } from "../controller/userController.js"
|
||||||
|
|
||||||
|
const route = express.Router();
|
||||||
|
route.post("/create",create);
|
||||||
|
route.get("/fetch", fetch)
|
||||||
|
|
||||||
|
export default route;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import express from "express"
|
||||||
|
import { fetch } from "../controller/verifyController.js"
|
||||||
|
|
||||||
|
|
||||||
|
const verify_route = express.Router();
|
||||||
|
verify_route.post("/bvn",fetch);
|
||||||
|
|
||||||
|
export default verify_route;
|
||||||
Reference in New Issue
Block a user