This commit is contained in:
2025-09-15 14:07:53 +08:00
parent 10bc7c6acf
commit cfbb219740
9 changed files with 78 additions and 59 deletions

View File

@@ -13,6 +13,7 @@
"packageManager": "pnpm@9.8.0+sha512.8e4c3550fb500e808dbc30bb0ce4dd1eb614e30b1c55245f211591ec2cdf9c611cabd34e1364b42f564bd54b3945ed0f49d61d1bbf2ec9bd74b866fcdc723276", "packageManager": "pnpm@9.8.0+sha512.8e4c3550fb500e808dbc30bb0ce4dd1eb614e30b1c55245f211591ec2cdf9c611cabd34e1364b42f564bd54b3945ed0f49d61d1bbf2ec9bd74b866fcdc723276",
"dependencies": { "dependencies": {
"@supabase/supabase-js": "^2.45.4", "@supabase/supabase-js": "^2.45.4",
"dotenv": "^17.2.2",
"jsonwebtoken": "^9.0.2", "jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.15", "nodemailer": "^6.9.15",
"pg": "^8.13.0" "pg": "^8.13.0"

9
pnpm-lock.yaml generated
View File

@@ -11,6 +11,9 @@ importers:
'@supabase/supabase-js': '@supabase/supabase-js':
specifier: ^2.45.4 specifier: ^2.45.4
version: 2.45.4 version: 2.45.4
dotenv:
specifier: ^17.2.2
version: 17.2.2
jsonwebtoken: jsonwebtoken:
specifier: ^9.0.2 specifier: ^9.0.2
version: 9.0.2 version: 9.0.2
@@ -70,6 +73,10 @@ packages:
buffer-equal-constant-time@1.0.1: buffer-equal-constant-time@1.0.1:
resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==} resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==}
dotenv@17.2.2:
resolution: {integrity: sha512-Sf2LSQP+bOlhKWWyhFsn0UsfdK/kCWRv1iuA2gXAwt3dyNabr6QSj00I2V10pidqz69soatm9ZwZvpQMTIOd5Q==}
engines: {node: '>=12'}
ecdsa-sig-formatter@1.0.11: ecdsa-sig-formatter@1.0.11:
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
@@ -297,6 +304,8 @@ snapshots:
buffer-equal-constant-time@1.0.1: {} buffer-equal-constant-time@1.0.1: {}
dotenv@17.2.2: {}
ecdsa-sig-formatter@1.0.11: ecdsa-sig-formatter@1.0.11:
dependencies: dependencies:
safe-buffer: 5.2.1 safe-buffer: 5.2.1

View File

@@ -3,27 +3,15 @@ import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js';
import { createClient, AuthClient } from '@supabase/supabase-js'; import { createClient, AuthClient } from '@supabase/supabase-js';
// const url = 'http://192.168.31.220:8000' // const url = 'http://192.168.31.220:8000'
// const url = 'http://supabase.xiongxiao.me' // const url = 'http://supabase.xiongxiao.me'
const url = 'http://supabase.xiongxiao.me' const url = 'http://supabase.xiongxiao.me';
// const authClient = new AuthClient({ url: url });
// // const auth = await authClient.signInWithPassword({ email: 'xiongxiao1012@outlook.com', password:'123456xx' });
// // const auth = await authClient.signInWithPassword({ email: 'admin@zxj.im', password:'123456xx' });
// const auth = await authClient.signInAnonymously();
// console.log('auth', auth);
// Create a single supabase client for interacting with your database // Create a single supabase client for interacting with your database
const publicAnonKey = const publicAnonKey = process.env.PUBLIC_ANON_KEY!;
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzI4NTc2MDAwLAogICJleHAiOiAxODg2MzQyNDAwCn0._O6nSz8km61C76qGnRMa44e4sou1qCRBhy8O0riHQmM'; const serverKEY = process.env.SERVER_KEY!;
const supabase = createClient(url, publicAnonKey); const supabase = createClient(url, publicAnonKey);
// const anony = await supabase.auth.signInAnonymously();
// console.log('anony', anony); supabase.auth.signInWithSSO;
// const u = await supabase.auth.signInWithPassword({
// email: 'xiongxiao1012@outlook.com',
// password: '123456xx',
// });
// console.log('u', u);
supabase.auth.signInWithSSO
const countriesWithCitiesQuery = supabase.from('public_test').select(` const countriesWithCitiesQuery = supabase.from('public_test').select(`
id, id,
title title

19
src/login-admin.ts Normal file
View File

@@ -0,0 +1,19 @@
import { supabase, supabaseServer } from './module/supabase';
const u = await supabaseServer.auth.signInWithPassword({
email: 'xiongxiao@xiongxiao.me',
password: process.env.PASSWORD!,
});
// console.log('u', u);
// const { data: test, error } = await supabase.from('test').select('*');
// console.log('test', test, error);
const res = await supabase.auth.admin.createUser({
user_metadata: { full_name: 'Xiongxiao' },
phone: '+8615202829140',
phone_confirm: true,
});
console.log('res', res);

View File

@@ -1,15 +1,12 @@
import { supabaseServer, supabase } from './module/supabase'; import { supabaseServer, supabase } from './module/supabase';
// const u = await supabase.auth.signInWithPassword({
// email: 'admin@zxj.im',
// password: '123456xx',
// });
const token = const token =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIzZjgyZTNhZS1iN2MyLTQyNDQtODQ5Zi1kNDUzZjMwNGIyZjIiLCJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzI5NDE1NDQwLCJpYXQiOjE3Mjk0MTE4NDAsImVtYWlsIjoiYWRtaW5AenhqLmltIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6e30sInJvbGUiOiJhdXRoZW50aWNhdGVkIiwiYWFsIjoiYWFsMSIsImFtciI6W3sibWV0aG9kIjoicGFzc3dvcmQiLCJ0aW1lc3RhbXAiOjE3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.eyJzdWIiOiIzZjgyZTNhZS1iN2MyLTQyNDQtODQ5Zi1kNDUzZjMwNGIyZjIiLCJhdWQiOiJhdXRoZW50aWNhdGVkIiwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJpYXQiOjE3Mjk0MTIzNzksImV4cCI6MTcyOTQzNzU3OX0.ZiLSxOJ-iy6YtuhXzWokHMLswsFu4u3716qEJmEkdJc';
const simpleToken2 = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjE0MjA2MzA1LThiNWMtNDRjYy1iMTc3LTc2NmNmZTJlNDUyZiIsInVzZXJuYW1lIjoicm9vdCIsInR5cGUiOiJ1c2VyIiwiYXVkIjoiYXV0aGVudGljYXRlZCIsInJvbGUiOiJhdXRoZW50aWNhdGVkIiwic3ViIjoiM2Y4MmUzYWUtYjdjMi00MjQ0LTg0OWYtZDQ1M2YzMDRiMmYyIiwiaWF0IjoxNzI5NDE3OTc1LCJleHAiOjE3MzAwMjI3NzV9.niMsxSGuj-iHOY6SUskZwHWXIB9xfhRvpLw1GrqOJLg' const simpleToken2 =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjE0MjA2MzA1LThiNWMtNDRjYy1iMTc3LTc2NmNmZTJlNDUyZiIsInVzZXJuYW1lIjoicm9vdCIsInR5cGUiOiJ1c2VyIiwiYXVkIjoiYXV0aGVudGljYXRlZCIsInJvbGUiOiJhdXRoZW50aWNhdGVkIiwic3ViIjoiM2Y4MmUzYWUtYjdjMi00MjQ0LTg0OWYtZDQ1M2YzMDRiMmYyIiwiaWF0IjoxNzI5NDE3OTc1LCJleHAiOjE3MzAwMjI3NzV9.niMsxSGuj-iHOY6SUskZwHWXIB9xfhRvpLw1GrqOJLg';
const client = await supabase.auth.setSession({ const client = await supabase.auth.setSession({
access_token: simpleToken2, access_token: simpleToken2,
refresh_token: simpleToken2, refresh_token: simpleToken2,

View File

@@ -1,7 +1,33 @@
import { supabase } from './module/supabase'; import { supabase, supabaseServer } from './module/supabase';
const u = await supabase.auth.signInWithPassword({ const u = await supabase.auth.signInWithPassword({
email: 'admin@zxj.im', // email: 'xiongxiao@xiongxiao.me',
password: '123456xx', phone: '15202829140',
password: process.env.PASSWORD!,
}); });
console.log('u', u); console.log('u', u);
await supabaseServer.auth.signInWithPassword
// const isAdmin = await supabaseServer.auth.admin.listUsers();
// console.log('isAdmin', isAdmin);
// const admin = await supabase.auth.signInWithPassword({
// email: 'admin@example.com',
// password: process.env.ADMIN_PASSWORD!,
// })
// console.log('admin', admin);
// const { data: test, error } = await supabase.from('test').select('*');
// console.log('test', test, error);
// const res = await supabaseServer.auth.admin.createUser({
// user_metadata: { full_name: 'Xiongxiao' },
// phone: '15202829140',
// password: process.env.PASSWORD!,
// phone_confirm: true,
// });
// await supabaseServer.auth.admin.updateUserById('fac6fbbd-e8e4-42d9-adbf-b7b2bd008892', {
// phone_confirm: true,
// });
// console.log('res', res);

View File

@@ -1,21 +1,20 @@
import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js'; import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js';
import dotenv from 'dotenv';
dotenv.config();
import { createClient, AuthClient } from '@supabase/supabase-js'; import { createClient, AuthClient } from '@supabase/supabase-js';
// const url = 'http://192.168.31.220:8000' // const url = 'http://192.168.31.220:8000'
// const url = 'http://supabase.xiongxiao.me' // const url = 'http://supabase.xiongxiao.me'
const url = 'http://supabase.xiongxiao.me'; // const url = 'http://supabase.xiongxiao.me';
const url = 'https://base.kevisual.cn';
// const authClient = new AuthClient({ url: url }); // const authClient = new AuthClient({ url: url });
// // const auth = await authClient.signInWithPassword({ email: 'xiongxiao1012@outlook.com', password:'123456xx' });
// // const auth = await authClient.signInWithPassword({ email: 'admin@zxj.im', password:'123456xx' });
// const auth = await authClient.signInAnonymously(); // const auth = await authClient.signInAnonymously();
// console.log('auth', auth); // console.log('auth', auth);
// Create a single supabase client for interacting with your database // Create a single supabase client for interacting with your database
const publicAnonKey = const publicAnonKey = process.env.PUBLIC_ANON_KEY!;
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzI4NTc2MDAwLAogICJleHAiOiAxODg2MzQyNDAwCn0._O6nSz8km61C76qGnRMa44e4sou1qCRBhy8O0riHQmM'; const serverKey = process.env.SERVER_KEY!;
const serverKey =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogInNlcnZpY2Vfcm9sZSIsCiAgImlzcyI6ICJzdXBhYmFzZSIsCiAgImlhdCI6IDE3Mjg1NzYwMDAsCiAgImV4cCI6IDE4ODYzNDI0MDAKfQ.J9TQ7GUTbh7bKOXCyC1FWiJMrAEzGuJaMGHZZSiIG58';
export const supabase = createClient(url, publicAnonKey); export const supabase = createClient(url, publicAnonKey);
export const supabaseServer = createClient(url, serverKey); export const supabaseServer = createClient(url, serverKey);

View File

@@ -4,8 +4,8 @@ import pg from 'pg';
// postgres: { // postgres: {
// username: 'root', // username: 'root',
// host: 'light.xiongxiao.me', // host: 'light.xiongxiao.me',
// database: 'xpostgres', // database: 'postgres',
// password: 'abearxiong', // password: '',
// port: 5432, // port: 5432,
// }, // },
@@ -13,31 +13,10 @@ const pool = new pg.Pool({
user: 'postgres', user: 'postgres',
host: '124.222.140.199', host: '124.222.140.199',
database: 'postgres', database: 'postgres',
password: '123456xx', password: process.env.PASSWORD!,
port: 5434, port: 5434,
}); });
pool.query('SELECT NOW()', (err, res) => { pool.query('SELECT NOW()', (err, res) => {
console.log(err, res); console.log(err, res);
pool.end(); pool.end();
}); });
// 配置数据库连接信息
// const client = new pg.Client({
// connectionString: 'postgresql://postgres:123456xx@light.xiongxiao.me:5434/postgres',
// });
// // 连接到数据库
// client.connect()
// .then(() => {
// console.log('Connected to the PostgreSQL database successfully!');
// return client.query('SELECT NOW()'); // 示例查询
// })
// .then((res) => {
// console.log('Server time:', res.rows[0]);
// })
// .catch((err) => {
// console.error('Database connection error:', err.stack);
// })
// .finally(() => {
// client.end(); // 关闭数据库连接
// });

View File

@@ -1,5 +1,6 @@
import nodemailer from 'nodemailer'; import nodemailer from 'nodemailer';
import dotenv from 'dotenv';
dotenv.config();
// 创建传输器transporter对象 // 创建传输器transporter对象
const transporter = nodemailer.createTransport({ const transporter = nodemailer.createTransport({
host: 'smtp.feishu.cn', // 替换为你的SMTP服务器地址 host: 'smtp.feishu.cn', // 替换为你的SMTP服务器地址
@@ -7,7 +8,7 @@ const transporter = nodemailer.createTransport({
secure: false, // 使用TLS协议false表示不强制加密连接可根据需求调整 secure: false, // 使用TLS协议false表示不强制加密连接可根据需求调整
auth: { auth: {
user: 'root@xiongxiao.me', // 替换为你的邮箱账号 user: 'root@xiongxiao.me', // 替换为你的邮箱账号
pass: 'K4fyaHkXTiVZGanV', // 替换为你的邮箱密码 pass: process.env.EMAIL_PASSWORD, // 替换为你的邮箱密码
}, },
}); });