diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..d470e66 --- /dev/null +++ b/.env-example @@ -0,0 +1 @@ +REACT_APP_BACKEND_URL=http://localhost:4000 diff --git a/Backend/Services/userService.js b/Backend/Services/userService.js index c3cc576..7e14181 100644 --- a/Backend/Services/userService.js +++ b/Backend/Services/userService.js @@ -3,7 +3,8 @@ const bcrypt = require("bcryptjs"); const jwt = require("jsonwebtoken"); const securityKey = "12345@Ra"; -const tableName = "user_information_80001_7788"; // This is your specific table name +const tableName = ""; // This is your specific table name +//user_information_80001_7788 const userLogin = async (req, res) => { const { email, password } = req.body; diff --git a/Backend/tableCreation.js b/Backend/tableCreation.js new file mode 100644 index 0000000..91c8a97 --- /dev/null +++ b/Backend/tableCreation.js @@ -0,0 +1,31 @@ +const env = require("dotenv").config(); +require("dotenv").config(); + +const ethers = require("ethers"); +const tableland = require("@tableland/sdk"); + +// Set up the provider and wallet using your private key. +let provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL); +let privateKey = process.env.PRIVATE_KEY; // Your private key +let wallet = new ethers.Wallet(privateKey, provider); + +// Connect the wallet to the provider. +let signer = wallet.connect(provider); + +// Create the Tableland database instance using the signer. +const db = new tableland.Database({ signer }); + +// This is the table's `prefix`--a custom table value prefixed as part of the table's name +async function tableCreaetionFunction(){ + const prefix = "my_table_new"; +const { meta: create } = await db + .prepare(`CREATE TABLE ${prefix} (id INTEGER PRIMARY KEY, username TEXT, email TEXT, password TEXT);`) + .run(); + +// The table's `name` is in the format `{prefix}_{chainId}_{tableId}` +const tableName = create.txn?.name ?? ""; // e.g., my_table_31337_2 +console.log(tableName) +await create.txn?.wait(); +} + +tableCreaetionFunction(); \ No newline at end of file diff --git a/src/Pages/LoginPage.jsx b/src/Pages/LoginPage.jsx index beb45fc..60a2170 100644 --- a/src/Pages/LoginPage.jsx +++ b/src/Pages/LoginPage.jsx @@ -17,7 +17,7 @@ const LoginPage = () => { const navigate = useNavigate(); const loginHandle = () => { axios - .post("http://localhost:4000/user/login", { + .post(`${process.env.REACT_APP_BACKEND_URL}/user/login`, { email: values.email, password: values.password, }) @@ -31,6 +31,7 @@ const LoginPage = () => { } }); }; + console.log(process.env.REACT_APP_BACKEND_URL) return (
{errors.email}
) : null} diff --git a/src/Pages/SignupPage.jsx b/src/Pages/SignupPage.jsx index 726a52f..974aa65 100644 --- a/src/Pages/SignupPage.jsx +++ b/src/Pages/SignupPage.jsx @@ -21,7 +21,7 @@ const SignupPage = () => { const signupHandle = async () => { setLoading(true); try { - const res = await axios.post("http://localhost:4000/user/", { + const res = await axios.post(`${process.env.REACT_APP_BACKEND_URL}/user/`, { username: values.username, email: values.email, password: values.password,