Useless db connection and imports
This commit is contained in:
@@ -4,12 +4,8 @@ import {
|
|||||||
getDatabaseConnection,
|
getDatabaseConnection,
|
||||||
jsonResponse
|
jsonResponse
|
||||||
} from '../../../lib/util'
|
} from '../../../lib/util'
|
||||||
import {
|
import { berryDashUserData, users } from '../../../lib/tables'
|
||||||
berryDashUserData,
|
import { and, eq } from 'drizzle-orm'
|
||||||
berryDashUserPosts,
|
|
||||||
users
|
|
||||||
} from '../../../lib/tables'
|
|
||||||
import { and, desc, eq } from 'drizzle-orm'
|
|
||||||
|
|
||||||
export async function handler (context: Context) {
|
export async function handler (context: Context) {
|
||||||
const dbInfo0 = getDatabaseConnection(0)
|
const dbInfo0 = getDatabaseConnection(0)
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
import { Context } from 'elysia'
|
import { Context } from 'elysia'
|
||||||
import {
|
import { getDatabaseConnection, jsonResponse } from '../../../../lib/util'
|
||||||
genTimestamp,
|
import { berryDashUserData, berryDashUserPosts } from '../../../../lib/tables'
|
||||||
getDatabaseConnection,
|
import { and, eq } from 'drizzle-orm'
|
||||||
jsonResponse
|
|
||||||
} from '../../../../lib/util'
|
|
||||||
import {
|
|
||||||
berryDashUserData,
|
|
||||||
berryDashUserPosts,
|
|
||||||
users
|
|
||||||
} from '../../../../lib/tables'
|
|
||||||
import { and, desc, eq } from 'drizzle-orm'
|
|
||||||
|
|
||||||
export async function handler (context: Context) {
|
export async function handler (context: Context) {
|
||||||
const dbInfo0 = getDatabaseConnection(0)
|
const dbInfo0 = getDatabaseConnection(0)
|
||||||
@@ -20,13 +12,11 @@ export async function handler (context: Context) {
|
|||||||
{ success: false, message: 'Failed to connect to database', data: null },
|
{ success: false, message: 'Failed to connect to database', data: null },
|
||||||
500
|
500
|
||||||
)
|
)
|
||||||
const { connection: connection0, db: db0 } = dbInfo0
|
|
||||||
const { connection: connection1, db: db1 } = dbInfo1
|
const { connection: connection1, db: db1 } = dbInfo1
|
||||||
|
|
||||||
let authorizationToken = context.headers.authorization
|
let authorizationToken = context.headers.authorization
|
||||||
let idQuery = context.query.id ? parseInt(context.query.id, 10) : 0
|
let idQuery = context.query.id ? parseInt(context.query.id, 10) : 0
|
||||||
if (!idQuery || idQuery < 1) {
|
if (!idQuery || idQuery < 1) {
|
||||||
connection0.end()
|
|
||||||
connection1.end()
|
connection1.end()
|
||||||
return jsonResponse(
|
return jsonResponse(
|
||||||
{ success: false, message: 'No valid post ID provided', data: null },
|
{ success: false, message: 'No valid post ID provided', data: null },
|
||||||
@@ -34,7 +24,6 @@ export async function handler (context: Context) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!authorizationToken) {
|
if (!authorizationToken) {
|
||||||
connection0.end()
|
|
||||||
connection1.end()
|
connection1.end()
|
||||||
return jsonResponse(
|
return jsonResponse(
|
||||||
{ success: false, message: 'Unauthorized', data: null },
|
{ success: false, message: 'Unauthorized', data: null },
|
||||||
@@ -49,7 +38,6 @@ export async function handler (context: Context) {
|
|||||||
.execute()
|
.execute()
|
||||||
|
|
||||||
if (!userData[0]) {
|
if (!userData[0]) {
|
||||||
connection0.end()
|
|
||||||
connection1.end()
|
connection1.end()
|
||||||
return jsonResponse(
|
return jsonResponse(
|
||||||
{ success: false, message: 'Unauthorized', data: null },
|
{ success: false, message: 'Unauthorized', data: null },
|
||||||
@@ -69,7 +57,6 @@ export async function handler (context: Context) {
|
|||||||
)
|
)
|
||||||
.execute()
|
.execute()
|
||||||
|
|
||||||
connection0.end()
|
|
||||||
connection1.end()
|
connection1.end()
|
||||||
|
|
||||||
if (result[0])
|
if (result[0])
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { games, launcherVersionManifest } from '../../lib/tables'
|
|||||||
import { asc, desc, eq } from 'drizzle-orm'
|
import { asc, desc, eq } from 'drizzle-orm'
|
||||||
import { getDatabaseConnection, jsonResponse } from '../../lib/util'
|
import { getDatabaseConnection, jsonResponse } from '../../lib/util'
|
||||||
import { Context } from 'elysia'
|
import { Context } from 'elysia'
|
||||||
import { boolean } from 'drizzle-orm/gel-core'
|
|
||||||
|
|
||||||
export async function handler (context: Context) {
|
export async function handler (context: Context) {
|
||||||
const dbResult = getDatabaseConnection(0)
|
const dbResult = getDatabaseConnection(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user