added all

This commit is contained in:
CHIEFSOFT\ameye
2025-01-13 21:20:24 -05:00
parent 088bb7a0fe
commit 7a60550a5b
5 changed files with 33 additions and 5 deletions
+25 -2
View File
@@ -1,5 +1,5 @@
import User from "../model/userModel.js";
import twilio from "twilio"; // Or, for ESM: import twilio from "twilio";
export const create = async (req,res)=>{
try {
const userData = new User(req.body);
@@ -7,7 +7,7 @@ export const create = async (req,res)=>{
const userExist = await User.findOne({email});
if (userExist) {
return res.status(400).json({message: "User already exixt"});
return res.status(400).json({message: "User Already Exist"});
}
const saveUser = await userData.save();
res.status(200).json(saveUser);
@@ -17,6 +17,29 @@ export const create = async (req,res)=>{
}
}
export const smsmessage = async (req,res)=>{
try {
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const fromNumber = process.env.TWILIO_FROM_NUMBER;
const client = twilio(accountSid, authToken);
const message = await client.messages.create({
body: "TWILLO TEST PIn number is 23579",
from: fromNumber,
to: "+16784574356",
});
console.log(message.body);
res.status(200).json(message);
} catch (error) {
res.status(500).json({error: `Internal Server error 002 ${error} ` });
}
}
export const fetch = async (req, res)=>{
try{