initial push
This commit is contained in:
Generated
+1067
-1680
File diff suppressed because it is too large
Load Diff
+14
-12
@@ -13,22 +13,24 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "^6.17.1",
|
"@prisma/adapter-pg": "^7.8.0",
|
||||||
"@types/bcrypt": "^5.0.2",
|
"@prisma/client": "^7.8.0",
|
||||||
|
"@types/bcrypt": "^6.0.0",
|
||||||
"@types/cors": "^2.8.19",
|
"@types/cors": "^2.8.19",
|
||||||
"bcrypt": "^6.0.0",
|
"bcrypt": "^6.0.0",
|
||||||
"bcryptjs": "^3.0.2",
|
"bcryptjs": "^3.0.3",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.6",
|
||||||
"express": "^5.1.0",
|
"dotenv": "^17.4.2",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"express": "^5.2.1",
|
||||||
"nodemailer": "^7.0.9",
|
"jsonwebtoken": "^9.0.3",
|
||||||
"pg": "^8.16.3"
|
"nodemailer": "^8.0.7",
|
||||||
|
"pg": "^8.20.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^5.0.3",
|
"@types/express": "^5.0.6",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/nodemailer": "^6.4.17",
|
"@types/nodemailer": "^8.0.0",
|
||||||
"prisma": "^6.17.1",
|
"prisma": "^7.8.0",
|
||||||
"tsx": "^4.20.3"
|
"tsx": "^4.22.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import "dotenv/config";
|
||||||
|
import { defineConfig, env } from "prisma/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
schema: "prisma/schema.prisma",
|
||||||
|
datasource: {
|
||||||
|
url: env("DATABASE_URL"),
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -18,7 +18,6 @@ model LoginActivity {
|
|||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "postgresql"
|
provider = "postgresql"
|
||||||
url = env("DATABASE_URL")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
|
|||||||
+10
-4
@@ -6,6 +6,8 @@ import {
|
|||||||
PriorityStatus,
|
PriorityStatus,
|
||||||
SecurityType,
|
SecurityType,
|
||||||
} from "@prisma/client";
|
} from "@prisma/client";
|
||||||
|
import { PrismaPg } from "@prisma/adapter-pg";
|
||||||
|
import pg from "pg";
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcryptjs";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -46,7 +48,11 @@ const uniqueTask = (idx: number) => {
|
|||||||
return `${sentenceFrom(idx)}\n\nContext: ${hint} [T${idx + 1}]`;
|
return `${sentenceFrom(idx)}\n\nContext: ${hint} [T${idx + 1}]`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const pool = new pg.Pool({
|
||||||
|
connectionString: process.env.DATABASE_URL,
|
||||||
|
});
|
||||||
|
const adapter = new PrismaPg(pool, { schema: "Athena" });
|
||||||
|
const prisma = new PrismaClient({ adapter });
|
||||||
|
|
||||||
const getRandom = <T>(arr: T[]): T =>
|
const getRandom = <T>(arr: T[]): T =>
|
||||||
arr[Math.floor(Math.random() * arr.length)];
|
arr[Math.floor(Math.random() * arr.length)];
|
||||||
@@ -199,19 +205,19 @@ async function main() {
|
|||||||
let todoIndex = 0;
|
let todoIndex = 0;
|
||||||
|
|
||||||
const createTeamTodo = async (
|
const createTeamTodo = async (
|
||||||
team: Array<Awaited<ReturnType<typeof prisma.user.create>>>
|
team: Array<Awaited<ReturnType<typeof prisma.user.create>>>,
|
||||||
) => {
|
) => {
|
||||||
const createdByUser = getRandom(team);
|
const createdByUser = getRandom(team);
|
||||||
// 1-3 assignees from the same team (ensure createdBy is included)
|
// 1-3 assignees from the same team (ensure createdBy is included)
|
||||||
const baseAssignees = pickSubset(
|
const baseAssignees = pickSubset(
|
||||||
team,
|
team,
|
||||||
1 + Math.floor(Math.random() * Math.min(3, team.length))
|
1 + Math.floor(Math.random() * Math.min(3, team.length)),
|
||||||
);
|
);
|
||||||
const ensureCreatedBy = baseAssignees.some((u) => u.id === createdByUser.id)
|
const ensureCreatedBy = baseAssignees.some((u) => u.id === createdByUser.id)
|
||||||
? baseAssignees
|
? baseAssignees
|
||||||
: [...baseAssignees, createdByUser];
|
: [...baseAssignees, createdByUser];
|
||||||
const uniqueAssignees = Array.from(
|
const uniqueAssignees = Array.from(
|
||||||
new Map(ensureCreatedBy.map((u) => [u.id, u])).values()
|
new Map(ensureCreatedBy.map((u) => [u.id, u])).values(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const dueDate = new Date();
|
const dueDate = new Date();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import prisma from "../prismaClient";
|
import prisma from "../prismaClient";
|
||||||
import { randomBytes, createHash } from "crypto";
|
import { randomBytes, createHash } from "crypto";
|
||||||
|
|
||||||
const APP_BASE_URL = process.env.APP_BASE_URL || "http://localhost:8081";
|
const APP_BASE_URL = process.env.APP_BASE_URL || "http://localhost:5000";
|
||||||
const RESET_TOKEN_TTL = Number(process.env.RESET_TOKEN_TTL || 3600);
|
const RESET_TOKEN_TTL = Number(process.env.RESET_TOKEN_TTL || 3600);
|
||||||
|
|
||||||
export const generateRawToken = (bytes = 32) => {
|
export const generateRawToken = (bytes = 32) => {
|
||||||
@@ -30,7 +30,7 @@ export const createPasswordResetToken = async (userId: string) => {
|
|||||||
|
|
||||||
const link = `${APP_BASE_URL.replace(
|
const link = `${APP_BASE_URL.replace(
|
||||||
/\/$/,
|
/\/$/,
|
||||||
""
|
"",
|
||||||
)}/reset-password?token=${rawToken}`;
|
)}/reset-password?token=${rawToken}`;
|
||||||
return { rawToken, link, expiresAt };
|
return { rawToken, link, expiresAt };
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-1
@@ -1,5 +1,10 @@
|
|||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
import { PrismaPg } from "@prisma/adapter-pg";
|
||||||
|
import pg from "pg";
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
|
||||||
|
const adapter = new PrismaPg(pool, { schema: "Athena" });
|
||||||
|
|
||||||
|
const prisma = new PrismaClient({ adapter });
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
|||||||
Reference in New Issue
Block a user