@autobe/compiler
Version:
AI backend server code generator
5 lines • 3.19 kB
text/typescript
export const AutoBeCompilerRealizeTemplateOfSQLite: Record<string, string> = {
".env.local": "API_PORT=37001\nJWT_SECRET_KEY=your_jwt_secret_key",
"src/MyGlobal.ts": "import { PrismaBetterSQLite3 } from \"@prisma/adapter-better-sqlite3\";\nimport { PrismaClient } from \"@prisma/client\";\nimport crypto from \"crypto\";\nimport dotenv from \"dotenv\";\nimport dotenvExpand from \"dotenv-expand\";\nimport { Singleton } from \"tstl\";\nimport typia from \"typia\";\n\nimport { MyConfiguration } from \"./MyConfiguration\";\n\n/* eslint-disable */\nexport class MyGlobal {\n public static testing: boolean = false;\n\n public static get env(): MyGlobal.IEnvironments {\n return environments.get();\n }\n\n public static get prisma(): PrismaClient {\n return prisma.get();\n }\n\n /**\n * Common password utilities for consistent authentication Uses native crypto\n * module for password hashing\n */\n public static readonly password = {\n // Fixed salt for password hashing (consistent across all operations)\n FIXED_SALT: \"autobe-fixed-salt-2024\",\n\n /**\n * Hash a plain password using crypto.pbkdf2 All authentication operations\n * (join, login) MUST use this method\n *\n * @param plainPassword - The plain text password to hash\n * @returns The hashed password as hex string\n */\n async hash(plainPassword: string): Promise<string> {\n return new Promise((resolve, reject) => {\n crypto.pbkdf2(\n plainPassword,\n this.FIXED_SALT,\n 10000,\n 64,\n \"sha512\",\n (err: Error | null, derivedKey: Buffer) => {\n if (err) reject(err);\n else resolve(derivedKey.toString(\"hex\"));\n },\n );\n });\n },\n\n /**\n * Verify a plain password against a hashed password Login operations MUST\n * use this method for password verification\n *\n * @param plainPassword - The plain text password to verify\n * @param hashedPassword - The hashed password from database\n * @returns True if passwords match, false otherwise\n */\n async verify(\n plainPassword: string,\n hashedPassword: string,\n ): Promise<boolean> {\n const hash = await this.hash(plainPassword);\n return hash === hashedPassword;\n },\n };\n}\nexport namespace MyGlobal {\n export interface IEnvironments {\n API_PORT: `${number}`;\n JWT_SECRET_KEY: string;\n }\n}\nconst environments = new Singleton(() => {\n const env = dotenv.config();\n dotenvExpand.expand(env);\n return typia.assert<MyGlobal.IEnvironments>(process.env);\n});\n\nconst prisma = new Singleton(\n () =>\n new PrismaClient({\n adapter: new PrismaBetterSQLite3({\n url: `${MyConfiguration.ROOT}/prisma/db.sqlite`,\n }),\n }),\n);\n",
"src/executable/schema.ts": "import { MyGlobal } from \"../MyGlobal\";\nimport { MySetupWizard } from \"../setup/MySetupWizard\";\n\nconst main = async (): Promise<void> => {\n MyGlobal.testing = true;\n await MySetupWizard.schema();\n await MySetupWizard.seed();\n};\nmain().catch((error) => {\n console.error(error);\n process.exit(-1);\n});\n"
};