Add creators to the response
This commit is contained in:
3 files changed
+14
-3
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
-- https://www.phpmyadmin.net/
|
-- https://www.phpmyadmin.net/
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- Host: localhost
|
||||||
-- Generation Time: Mar 24, 2026 at 09:47 PM
|
-- Generation Time: Mar 24, 2026 at 10:33 PM
|
||||||
-- Server version: 10.11.14-MariaDB-0ubuntu0.24.04.1
|
-- Server version: 10.11.14-MariaDB-0ubuntu0.24.04.1
|
||||||
-- PHP Version: 8.3.30
|
-- PHP Version: 8.3.30
|
||||||
|
|
||||||
@@ -111,6 +111,7 @@ CREATE TABLE `loaderupdates` (
|
|||||||
CREATE TABLE `mods` (
|
CREATE TABLE `mods` (
|
||||||
`id` bigint(20) NOT NULL,
|
`id` bigint(20) NOT NULL,
|
||||||
`name` text NOT NULL,
|
`name` text NOT NULL,
|
||||||
|
`creators` text NOT NULL DEFAULT '[]',
|
||||||
`description` text DEFAULT NULL,
|
`description` text DEFAULT NULL,
|
||||||
`downloadCount` bigint(20) NOT NULL DEFAULT 0,
|
`downloadCount` bigint(20) NOT NULL DEFAULT 0,
|
||||||
`hidden` tinyint(1) NOT NULL DEFAULT 1
|
`hidden` tinyint(1) NOT NULL DEFAULT 1
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ export const cdnFiles = mysqlTable('cdnfiles', {
|
|||||||
export const mods = mysqlTable('mods', {
|
export const mods = mysqlTable('mods', {
|
||||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||||
name: text('name').notNull(),
|
name: text('name').notNull(),
|
||||||
|
creators: text('creators').default('{}').notNull(),
|
||||||
description: text('description').notNull(),
|
description: text('description').notNull(),
|
||||||
downloadCount: bigint('downloadCount', { mode: 'number' })
|
downloadCount: bigint('downloadCount', { mode: 'number' })
|
||||||
.notNull()
|
.notNull()
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import {
|
|||||||
games,
|
games,
|
||||||
launcherVersionManifest,
|
launcherVersionManifest,
|
||||||
mods,
|
mods,
|
||||||
modVersions
|
modVersions,
|
||||||
|
users
|
||||||
} from '../../../lib/tables'
|
} from '../../../lib/tables'
|
||||||
import { and, asc, desc, eq } from 'drizzle-orm'
|
import { and, asc, desc, eq, inArray, sql } from 'drizzle-orm'
|
||||||
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
|
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
|
||||||
import { Context } from 'elysia'
|
import { Context } from 'elysia'
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ export const handler = async (context: Context) => {
|
|||||||
.select({
|
.select({
|
||||||
id: mods.id,
|
id: mods.id,
|
||||||
name: mods.name,
|
name: mods.name,
|
||||||
|
creators: mods.creators,
|
||||||
description: mods.description,
|
description: mods.description,
|
||||||
downloadCount: mods.downloadCount
|
downloadCount: mods.downloadCount
|
||||||
})
|
})
|
||||||
@@ -126,10 +128,17 @@ export const handler = async (context: Context) => {
|
|||||||
|
|
||||||
if (!download || !downloads[download]) return
|
if (!download || !downloads[download]) return
|
||||||
|
|
||||||
|
const creators = await db
|
||||||
|
.select({ username: users.username })
|
||||||
|
.from(users)
|
||||||
|
.where(inArray(users.id, JSON.parse(v.creators)))
|
||||||
|
.execute()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: v.id,
|
id: v.id,
|
||||||
name: v.name,
|
name: v.name,
|
||||||
description: v.description,
|
description: v.description,
|
||||||
|
creators: creators.map(u => u.username),
|
||||||
downloads: v.downloadCount,
|
downloads: v.downloadCount,
|
||||||
released: vi[vi.length - 1].releaseDate,
|
released: vi[vi.length - 1].releaseDate,
|
||||||
updated: vi[0].releaseDate,
|
updated: vi[0].releaseDate,
|
||||||
|
|||||||
Reference in new issue
Block a user