mirror of
				https://github.com/C4illin/ConvertX.git
				synced 2025-10-30 19:43:30 +00:00 
			
		
		
		
	refactor: create db types
This commit is contained in:
		
							
								
								
									
										23
									
								
								src/db/types.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/db/types.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| export class Filename { | ||||
|   id!: number; | ||||
|   job_id!: number; | ||||
|   file_name!: string; | ||||
|   output_file_name!: string; | ||||
|   status!: string; | ||||
| } | ||||
|  | ||||
| export class Jobs { | ||||
|   finished_files!: number; | ||||
|   id!: number; | ||||
|   user_id!: number; | ||||
|   date_created!: string; | ||||
|   status!: string; | ||||
|   num_files!: number; | ||||
|   files_detailed!: Filename[]; | ||||
| } | ||||
|  | ||||
| export class User { | ||||
|   id!: number; | ||||
|   email!: string; | ||||
|   password!: string; | ||||
| } | ||||
| @@ -17,33 +17,13 @@ import { deleteFile } from "./pages/deleteFile"; | ||||
| import { listConverters } from "./pages/listConverters"; | ||||
| import { chooseConverter } from "./pages/chooseConverter"; | ||||
| import db from "./db/db"; | ||||
| import { Jobs } from "./db/types"; | ||||
|  | ||||
| mkdir("./data", { recursive: true }).catch(console.error); | ||||
|  | ||||
| export const uploadsDir = "./data/uploads/"; | ||||
| export const outputDir = "./data/output/"; | ||||
|  | ||||
| // init db if not exists | ||||
|  | ||||
|  | ||||
| export class Filename { | ||||
|   id!: number; | ||||
|   job_id!: number; | ||||
|   file_name!: string; | ||||
|   output_file_name!: string; | ||||
|   status!: string; | ||||
| } | ||||
|  | ||||
| export class Jobs { | ||||
|   finished_files!: number; | ||||
|   id!: number; | ||||
|   user_id!: number; | ||||
|   date_created!: string; | ||||
|   status!: string; | ||||
|   num_files!: number; | ||||
|   files_detailed!: Filename[]; | ||||
| } | ||||
|  | ||||
| const app = new Elysia({ | ||||
|   serve: { | ||||
|     maxRequestBodySize: Number.MAX_SAFE_INTEGER, | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import { mkdir } from "node:fs/promises"; | ||||
| import { Elysia, t } from "elysia"; | ||||
| import sanitize from "sanitize-filename"; | ||||
| import { Jobs, outputDir, uploadsDir } from ".."; | ||||
| import { outputDir, uploadsDir } from ".."; | ||||
| import { mainConverter } from "../converters/main"; | ||||
| import { WEBROOT } from "../helpers/env"; | ||||
| import db from "../db/db"; | ||||
| @@ -10,6 +10,7 @@ import { | ||||
|   normalizeOutputFiletype, | ||||
| } from "../helpers/normalizeFiletype"; | ||||
| import { userService } from "./user"; | ||||
| import { Jobs } from "../db/types"; | ||||
|  | ||||
| export const convert = new Elysia().use(userService).post( | ||||
|   "/convert", | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import { Html } from "@elysiajs/html"; | ||||
| import { Header } from "../components/header"; | ||||
| import { userService } from "./user"; | ||||
| import { ALLOW_UNAUTHENTICATED, HIDE_HISTORY, WEBROOT } from "../helpers/env"; | ||||
| import { Filename, Jobs } from ".."; | ||||
| import { Filename, Jobs } from "../db/types"; | ||||
| import db from "../db/db"; | ||||
|  | ||||
| export const history = new Elysia() | ||||
|   | ||||
| @@ -2,7 +2,7 @@ import { Elysia } from "elysia"; | ||||
| import { userService } from "./user"; | ||||
| import { Html } from "@elysiajs/html"; | ||||
| import { ALLOW_UNAUTHENTICATED, WEBROOT } from "../helpers/env"; | ||||
| import { Filename, Jobs } from ".."; | ||||
| import { Filename, Jobs } from "../db/types"; | ||||
| import { Header } from "../components/header"; | ||||
| import { BaseHtml } from "../components/base"; | ||||
| import db from "../db/db"; | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import { Elysia } from "elysia"; | ||||
| import { Html } from "@elysiajs/html"; | ||||
| import { FIRST_RUN, User, userService } from "./user"; | ||||
| import { FIRST_RUN, userService } from "./user"; | ||||
| import { ACCOUNT_REGISTRATION, ALLOW_UNAUTHENTICATED, HIDE_HISTORY, HTTP_ALLOWED, WEBROOT } from "../helpers/env"; | ||||
| import { JWTPayloadSpec } from "@elysiajs/jwt"; | ||||
| import { randomInt } from "node:crypto"; | ||||
| @@ -8,6 +8,7 @@ import { BaseHtml } from "../components/base"; | ||||
| import { Header } from "../components/header"; | ||||
| import { getAllTargets } from "../converters/main"; | ||||
| import db from "../db/db"; | ||||
| import { User } from "../db/types"; | ||||
|  | ||||
| export const root = new Elysia() | ||||
|   .use(userService) | ||||
|   | ||||
| @@ -7,12 +7,7 @@ import { randomUUID } from "node:crypto"; | ||||
|  | ||||
| import { ACCOUNT_REGISTRATION, WEBROOT, HIDE_HISTORY, ALLOW_UNAUTHENTICATED, HTTP_ALLOWED } from "../helpers/env"; | ||||
| import db from "../db/db"; | ||||
|  | ||||
| export class User { | ||||
|   id!: number; | ||||
|   email!: string; | ||||
|   password!: string; | ||||
| } | ||||
| import { User } from "../db/types"; | ||||
|  | ||||
| export let FIRST_RUN = db.query("SELECT * FROM users").get() === null || false; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user