Skip to content

Commit

Permalink
tablecreation script add
Browse files Browse the repository at this point in the history
  • Loading branch information
Giri-Spheron committed Dec 2, 2023
1 parent 3181a1a commit 10a990b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 24 deletions.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_BACKEND_URL=http://localhost:4000
3 changes: 2 additions & 1 deletion Backend/Services/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions Backend/tableCreation.js
Original file line number Diff line number Diff line change
@@ -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();
41 changes: 19 additions & 22 deletions src/Pages/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -31,6 +31,7 @@ const LoginPage = () => {
}
});
};
console.log(process.env.REACT_APP_BACKEND_URL)

return (
<div
Expand All @@ -41,27 +42,23 @@ const LoginPage = () => {
<div className='grid justify-items-center'>
<HiUserGroup className='w-40 h-20' />
</div>
<div
className='flex gap-2 items-center bg-blue-200 shadow-lg
rounded-l-full'
>
<span className='w-10 h-10 px-2'>
<HiOutlineUser className='w-full h-full text-black ' />
<span>
<input
type='text'
placeholder='Username/Email'
name='email'
value={values.email}
autoComplete='off'
className='w-80 outline-none text-white text-xl'
onChange={handleChange}
onBlur={handleBlur}
style={{ backgroundColor: "transparent" }}
/>
</span>
</span>
</div>
<div className='flex gap-2 items-center bg-blue-200 shadow-lg rounded-l-full'>
<span className='w-10 h-10 px-2 flex items-center justify-center'>
<HiOutlineUser className='w-full h-full text-black ' />
</span>
<input
type='text'
placeholder='Username/Email'
name='email'
value={values.email}
autoComplete='off'
className='w-80 outline-none text-black text-xl'
onChange={handleChange}
onBlur={handleBlur}
style={{ backgroundColor: "transparent" }}
/>
</div>

{errors.email && touched.email ? (
<p className='text-red-800 text-xl'>{errors.email}</p>
) : null}
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/SignupPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 10a990b

Please sign in to comment.