mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
pushing it broke
This commit is contained in:
18
src/app/auth.ts
Normal file
18
src/app/auth.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import NextAuth from "next-auth"
|
||||
import Google from "next-auth/providers/google"
|
||||
import { DrizzleAdapter } from "@auth/drizzle-adapter"
|
||||
import { db } from "../db";
|
||||
import { users } from "@schemas/User"
|
||||
import { accounts } from "@schemas/Accounts";
|
||||
import { sessions } from "@schemas/Sessions";
|
||||
import { verificationTokens } from "@schemas/VerificationTokens";
|
||||
|
||||
export const { handlers, auth } = NextAuth({
|
||||
adapter: DrizzleAdapter(db, {
|
||||
usersTable: users,
|
||||
accountsTable: accounts,
|
||||
sessionsTable: sessions,
|
||||
verificationTokensTable: verificationTokens,
|
||||
}),
|
||||
providers: []
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
import React, { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import constants from '@src/lib/constants';
|
||||
import constants from '@lib/constants';
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function SignInPage() {
|
||||
|
||||
26
src/db/schema/Accounts.ts
Normal file
26
src/db/schema/Accounts.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { users } from "@schemas/User";
|
||||
import { integer, pgTable, primaryKey, text } from "drizzle-orm/pg-core";
|
||||
import type { AdapterAccountType } from "next-auth/adapters"
|
||||
export const accounts = pgTable(
|
||||
"account",
|
||||
{
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
type: text("type").$type<AdapterAccountType>().notNull(),
|
||||
provider: text("provider").notNull(),
|
||||
providerAccountId: text("providerAccountId").notNull(),
|
||||
refresh_token: text("refresh_token"),
|
||||
access_token: text("access_token"),
|
||||
expires_at: integer("expires_at"),
|
||||
token_type: text("token_type"),
|
||||
scope: text("scope"),
|
||||
id_token: text("id_token"),
|
||||
session_state: text("session_state"),
|
||||
},
|
||||
(account) => ({
|
||||
compoundKey: primaryKey({
|
||||
columns: [account.provider, account.providerAccountId],
|
||||
}),
|
||||
})
|
||||
)
|
||||
29
src/db/schema/AeroPrecision.ts
Normal file
29
src/db/schema/AeroPrecision.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { numeric, pgTable, text, uuid } from "drizzle-orm/pg-core";
|
||||
|
||||
export const aeroPrecision = pgTable("aero_precision", {
|
||||
sku: text().primaryKey().notNull(),
|
||||
manufacturerId: text("manufacturer_id"),
|
||||
brandName: text("brand_name"),
|
||||
productName: text("product_name"),
|
||||
longDescription: text("long_description"),
|
||||
shortDescription: text("short_description"),
|
||||
department: text(),
|
||||
category: text(),
|
||||
subcategory: text(),
|
||||
thumbUrl: text("thumb_url"),
|
||||
imageUrl: text("image_url"),
|
||||
buyLink: text("buy_link"),
|
||||
keywords: text(),
|
||||
reviews: text(),
|
||||
retailPrice: numeric("retail_price"),
|
||||
salePrice: numeric("sale_price"),
|
||||
brandPageLink: text("brand_page_link"),
|
||||
brandLogoImage: text("brand_logo_image"),
|
||||
productPageViewTracking: text("product_page_view_tracking"),
|
||||
variantsXml: text("variants_xml"),
|
||||
mediumImageUrl: text("medium_image_url"),
|
||||
productContentWidget: text("product_content_widget"),
|
||||
googleCategorization: text("google_categorization"),
|
||||
itemBasedCommission: text("item_based_commission"),
|
||||
uuid: uuid().defaultRandom(),
|
||||
});
|
||||
22
src/db/schema/Authenticators.ts
Normal file
22
src/db/schema/Authenticators.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { boolean, integer, pgTable, primaryKey, text } from "drizzle-orm/pg-core";
|
||||
import { users } from '@schemas/User'
|
||||
export const authenticators = pgTable(
|
||||
"authenticator",
|
||||
{
|
||||
credentialID: text("credentialID").notNull().unique(),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
providerAccountId: text("providerAccountId").notNull(),
|
||||
credentialPublicKey: text("credentialPublicKey").notNull(),
|
||||
counter: integer("counter").notNull(),
|
||||
credentialDeviceType: text("credentialDeviceType").notNull(),
|
||||
credentialBackedUp: boolean("credentialBackedUp").notNull(),
|
||||
transports: text("transports"),
|
||||
},
|
||||
(authenticator) => ({
|
||||
compositePK: primaryKey({
|
||||
columns: [authenticator.userId, authenticator.credentialID],
|
||||
}),
|
||||
})
|
||||
)
|
||||
10
src/db/schema/Sessions.ts
Normal file
10
src/db/schema/Sessions.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||
import {User} from '@schemas/User';
|
||||
export const sessions = pgTable("session", {
|
||||
sessionToken: text("sessionToken").primaryKey(),
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => User.id, { onDelete: "cascade" }),
|
||||
expires: timestamp("expires", { mode: "date" }).notNull(),
|
||||
})
|
||||
|
||||
@@ -24,4 +24,14 @@ export const User = pgTable("users", {
|
||||
usersEmailKey: unique("users_email_key").on(table.email),
|
||||
usersBuildPrivacySettingCheck: check("users_build_privacy_setting_check", sql`build_privacy_setting = ANY (ARRAY['private'::text, 'public'::text])`),
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const users = pgTable("user", {
|
||||
id: text("id")
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
name: text("name"),
|
||||
email: text("email").unique(),
|
||||
emailVerified: timestamp("emailVerified", { mode: "date" }),
|
||||
image: text("image"),
|
||||
})
|
||||
@@ -1,8 +1,9 @@
|
||||
import { bigint, bigserial, foreignKey, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { users } from "./User";
|
||||
|
||||
export const userActivityLog = pgTable("user_activity_log", {
|
||||
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
||||
id: bigint({ mode: "bigint" }).primaryKey().generatedAlwaysAsIdentity({ name: "user_activity_id_seq", startWith: 1, increment: 1, minValue: 1, maxValue: 2147483647, cache: 1 }).notNull(),
|
||||
// You can use { mode: "bigint" } if numbers are exceeding js number limitations
|
||||
userId: bigint("user_id", { mode: "number" }).notNull(),
|
||||
activity: text().notNull(),
|
||||
|
||||
16
src/db/schema/VerificationTokens.ts
Normal file
16
src/db/schema/VerificationTokens.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
|
||||
|
||||
export const verificationTokens = pgTable(
|
||||
"verificationToken",
|
||||
{
|
||||
identifier: text("identifier").notNull(),
|
||||
token: text("token").notNull(),
|
||||
expires: timestamp("expires", { mode: "date" }).notNull(),
|
||||
},
|
||||
(verificationToken) => ({
|
||||
compositePk: primaryKey({
|
||||
columns: [verificationToken.identifier, verificationToken.token],
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { relations } from "drizzle-orm/relations";
|
||||
import { users, userBuilds, userFavorites, userActivityLog } from "./schema";
|
||||
import { usersKeep, userBuilds, userFavorites, userActivityLog } from "./schema";
|
||||
|
||||
export const userBuildsRelations = relations(userBuilds, ({one}) => ({
|
||||
user: one(users, {
|
||||
usersKeep: one(usersKeep, {
|
||||
fields: [userBuilds.userId],
|
||||
references: [users.id]
|
||||
references: [usersKeep.id]
|
||||
}),
|
||||
}));
|
||||
|
||||
export const usersRelations = relations(users, ({many}) => ({
|
||||
export const usersKeepRelations = relations(usersKeep, ({many}) => ({
|
||||
userBuilds: many(userBuilds),
|
||||
userFavorites: many(userFavorites),
|
||||
userActivityLogs: many(userActivityLog),
|
||||
}));
|
||||
|
||||
export const userFavoritesRelations = relations(userFavorites, ({one}) => ({
|
||||
user: one(users, {
|
||||
usersKeep: one(usersKeep, {
|
||||
fields: [userFavorites.userId],
|
||||
references: [users.id]
|
||||
references: [usersKeep.id]
|
||||
}),
|
||||
}));
|
||||
|
||||
export const userActivityLogRelations = relations(userActivityLog, ({one}) => ({
|
||||
user: one(users, {
|
||||
usersKeep: one(usersKeep, {
|
||||
fields: [userActivityLog.userId],
|
||||
references: [users.id]
|
||||
references: [usersKeep.id]
|
||||
}),
|
||||
}));
|
||||
@@ -54,7 +54,7 @@ export const userBuilds = pgTable("user_builds", {
|
||||
return {
|
||||
userBuildsUserIdFkey: foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [users.id],
|
||||
foreignColumns: [usersKeep.id],
|
||||
name: "user_builds_user_id_fkey"
|
||||
}).onDelete("cascade"),
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export const userFavorites = pgTable("user_favorites", {
|
||||
return {
|
||||
userFavoritesUserIdFkey: foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [users.id],
|
||||
foreignColumns: [usersKeep.id],
|
||||
name: "user_favorites_user_id_fkey"
|
||||
}).onDelete("cascade"),
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export const userActivityLog = pgTable("user_activity_log", {
|
||||
return {
|
||||
userActivityLogUserIdFkey: foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [users.id],
|
||||
foreignColumns: [usersKeep.id],
|
||||
name: "user_activity_log_user_id_fkey"
|
||||
}).onDelete("cascade"),
|
||||
}
|
||||
@@ -285,7 +285,7 @@ export const psa = pgTable("psa", {
|
||||
uuid: uuid().defaultRandom(),
|
||||
});
|
||||
|
||||
export const users = pgTable("users", {
|
||||
export const usersKeep = pgTable("users_keep", {
|
||||
id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
|
||||
username: varchar({ length: 50 }).notNull(),
|
||||
email: varchar({ length: 255 }).notNull(),
|
||||
|
||||
Reference in New Issue
Block a user