test
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
"busboy": "^1.6.0",
|
||||
"commander": "^14.0.2",
|
||||
"cookie": "^1.1.1",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"ioredis": "^5.8.2",
|
||||
"minio": "^8.0.6",
|
||||
"pg": "^8.16.3",
|
||||
|
||||
99
pnpm-lock.yaml
generated
99
pnpm-lock.yaml
generated
@@ -39,6 +39,9 @@ importers:
|
||||
cookie:
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1
|
||||
drizzle-orm:
|
||||
specifier: ^0.45.1
|
||||
version: 0.45.1(pg@8.16.3)
|
||||
ioredis:
|
||||
specifier: ^5.8.2
|
||||
version: 5.8.2
|
||||
@@ -753,6 +756,98 @@ packages:
|
||||
dottie@2.0.6:
|
||||
resolution: {integrity: sha512-iGCHkfUc5kFekGiqhe8B/mdaurD+lakO9txNnTvKtA6PISrw86LgqHvRzWYPyoE2Ph5aMIrCw9/uko6XHTKCwA==}
|
||||
|
||||
drizzle-orm@0.45.1:
|
||||
resolution: {integrity: sha512-Te0FOdKIistGNPMq2jscdqngBRfBpC8uMFVwqjf6gtTVJHIQ/dosgV/CLBU2N4ZJBsXL5savCba9b0YJskKdcA==}
|
||||
peerDependencies:
|
||||
'@aws-sdk/client-rds-data': '>=3'
|
||||
'@cloudflare/workers-types': '>=4'
|
||||
'@electric-sql/pglite': '>=0.2.0'
|
||||
'@libsql/client': '>=0.10.0'
|
||||
'@libsql/client-wasm': '>=0.10.0'
|
||||
'@neondatabase/serverless': '>=0.10.0'
|
||||
'@op-engineering/op-sqlite': '>=2'
|
||||
'@opentelemetry/api': ^1.4.1
|
||||
'@planetscale/database': '>=1.13'
|
||||
'@prisma/client': '*'
|
||||
'@tidbcloud/serverless': '*'
|
||||
'@types/better-sqlite3': '*'
|
||||
'@types/pg': '*'
|
||||
'@types/sql.js': '*'
|
||||
'@upstash/redis': '>=1.34.7'
|
||||
'@vercel/postgres': '>=0.8.0'
|
||||
'@xata.io/client': '*'
|
||||
better-sqlite3: '>=7'
|
||||
bun-types: '*'
|
||||
expo-sqlite: '>=14.0.0'
|
||||
gel: '>=2'
|
||||
knex: '*'
|
||||
kysely: '*'
|
||||
mysql2: '>=2'
|
||||
pg: '>=8'
|
||||
postgres: '>=3'
|
||||
prisma: '*'
|
||||
sql.js: '>=1'
|
||||
sqlite3: '>=5'
|
||||
peerDependenciesMeta:
|
||||
'@aws-sdk/client-rds-data':
|
||||
optional: true
|
||||
'@cloudflare/workers-types':
|
||||
optional: true
|
||||
'@electric-sql/pglite':
|
||||
optional: true
|
||||
'@libsql/client':
|
||||
optional: true
|
||||
'@libsql/client-wasm':
|
||||
optional: true
|
||||
'@neondatabase/serverless':
|
||||
optional: true
|
||||
'@op-engineering/op-sqlite':
|
||||
optional: true
|
||||
'@opentelemetry/api':
|
||||
optional: true
|
||||
'@planetscale/database':
|
||||
optional: true
|
||||
'@prisma/client':
|
||||
optional: true
|
||||
'@tidbcloud/serverless':
|
||||
optional: true
|
||||
'@types/better-sqlite3':
|
||||
optional: true
|
||||
'@types/pg':
|
||||
optional: true
|
||||
'@types/sql.js':
|
||||
optional: true
|
||||
'@upstash/redis':
|
||||
optional: true
|
||||
'@vercel/postgres':
|
||||
optional: true
|
||||
'@xata.io/client':
|
||||
optional: true
|
||||
better-sqlite3:
|
||||
optional: true
|
||||
bun-types:
|
||||
optional: true
|
||||
expo-sqlite:
|
||||
optional: true
|
||||
gel:
|
||||
optional: true
|
||||
knex:
|
||||
optional: true
|
||||
kysely:
|
||||
optional: true
|
||||
mysql2:
|
||||
optional: true
|
||||
pg:
|
||||
optional: true
|
||||
postgres:
|
||||
optional: true
|
||||
prisma:
|
||||
optional: true
|
||||
sql.js:
|
||||
optional: true
|
||||
sqlite3:
|
||||
optional: true
|
||||
|
||||
eastasianwidth@0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
|
||||
@@ -2616,6 +2711,10 @@ snapshots:
|
||||
|
||||
dottie@2.0.6: {}
|
||||
|
||||
drizzle-orm@0.45.1(pg@8.16.3):
|
||||
optionalDependencies:
|
||||
pg: 8.16.3
|
||||
|
||||
eastasianwidth@0.2.0: {}
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
|
||||
10
src/auth/drizzle/one.ts
Normal file
10
src/auth/drizzle/one.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import { users } from './user.ts';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
const db = drizzle(process.env.DATABASE_URL!);
|
||||
|
||||
const one = await db.select().from(users).limit(1);
|
||||
|
||||
console.log(one);
|
||||
42
src/auth/drizzle/user.ts
Normal file
42
src/auth/drizzle/user.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { pgTable, serial, text, varchar, uuid, boolean, jsonb, timestamp } from "drizzle-orm/pg-core";
|
||||
import { InferSelectModel, InferInsertModel } from "drizzle-orm";
|
||||
|
||||
export const users = pgTable('cf_user', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
username: text('username').notNull().unique(),
|
||||
nickname: text('nickname'),
|
||||
password: text('password'),
|
||||
email: text('email'),
|
||||
avatar: text('avatar'),
|
||||
salt: text('salt'),
|
||||
description: text('description'),
|
||||
type: text('type').notNull().default('user'),
|
||||
owner: uuid('owner'),
|
||||
orgId: uuid('orgId'),
|
||||
needChangePassword: boolean('needChangePassword').notNull().default(false),
|
||||
data: jsonb('data').notNull().default({}),
|
||||
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
|
||||
deletedAt: timestamp('deletedAt'),
|
||||
});
|
||||
|
||||
// 类型推断
|
||||
export type User = InferSelectModel<typeof users>;
|
||||
export type NewUser = InferInsertModel<typeof users>;
|
||||
|
||||
// 用户数据类型
|
||||
export type UserData = {
|
||||
orgs?: string[];
|
||||
wxUnionId?: string;
|
||||
phone?: string;
|
||||
};
|
||||
|
||||
// 用户类型枚举
|
||||
export enum UserTypes {
|
||||
user = 'user',
|
||||
org = 'org',
|
||||
visitor = 'visitor',
|
||||
}
|
||||
// export class User {
|
||||
|
||||
// }
|
||||
Reference in New Issue
Block a user