Merge pull request #7 from rafiarrafif/fix/linting-issues
Fix/linting issues
This commit is contained in:
0
.github/workflows/ci.yaml
vendored
Normal file
0
.github/workflows/ci.yaml
vendored
Normal file
@ -5,7 +5,7 @@ import { defineConfig } from "eslint/config";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
ignores: ["src/modules/debug/**"],
|
||||
ignores: ["src/modules/debug/**", "src/helpers/characters/generateSlug.ts"],
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.{js,mjs,cjs,ts,mts,cts}"],
|
||||
|
||||
@ -7,7 +7,7 @@ async function main() {
|
||||
console.log("🔌 Connecting to database...");
|
||||
|
||||
const userSystemSeedResult = await userSystemSeed();
|
||||
const userRoleSeedResult = await userRoleSeed(userSystemSeedResult.id);
|
||||
await userRoleSeed(userSystemSeedResult.id);
|
||||
|
||||
console.log("🌳 All seeds completed");
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ try {
|
||||
|
||||
// Extract the key and the remainder after "="
|
||||
const key = line.substring(0, delimiterIndex).trim();
|
||||
let remainder = line.substring(delimiterIndex + 1);
|
||||
const remainder = line.substring(delimiterIndex + 1);
|
||||
|
||||
// Attempt to separate value and inline comment (if any)
|
||||
let value = remainder;
|
||||
|
||||
@ -14,7 +14,7 @@ for (const remote of remotes) {
|
||||
try {
|
||||
execSync(`git push ${remote} main`, { stdio: "inherit" });
|
||||
} catch (err) {
|
||||
console.error(`❌ Failed to push to ${remote}`);
|
||||
console.error(`❌ Failed to push to ${remote}`, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,17 +14,13 @@ export async function generateSlug(
|
||||
const baseSlug = slugify(input, { lower: true, strict: true });
|
||||
let uniqueSlug = baseSlug;
|
||||
|
||||
// CASE 1: Tidak ada config → langsung return slug
|
||||
if (!config) return uniqueSlug;
|
||||
|
||||
const { model, target } = config;
|
||||
|
||||
// CASE 2: Validasi pasangan model-target
|
||||
if (!model || !target) {
|
||||
throw new Error(`Both "model" and "target" must be provided together.`);
|
||||
}
|
||||
|
||||
// CASE 3: Cek unique
|
||||
const prismaModel = (prisma as any)[model];
|
||||
if (!prismaModel) {
|
||||
throw new Error(`Model "${model as string}" not found in PrismaClient.`);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { generateUUIDv7 } from "./uuidv7";
|
||||
|
||||
function createManyWithUUID<T extends { id?: string }>(items: T[]): T[] {
|
||||
export const createManyWithUUID = <T extends { id?: string }>(
|
||||
items: T[],
|
||||
): T[] => {
|
||||
return items.map((i) => ({
|
||||
...i,
|
||||
id: i.id ?? generateUUIDv7(),
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
|
||||
import { middleware } from "./middleware";
|
||||
import { validateEnv } from "./utils/startups/validateEnv";
|
||||
|
||||
@ -12,7 +14,7 @@ async function bootstrap() {
|
||||
sentryInit();
|
||||
|
||||
console.log("\x1b[1m\x1b[33m🚀 Starting backend services...\x1b[0m");
|
||||
const app = new Elysia()
|
||||
new Elysia()
|
||||
.use(middleware)
|
||||
.use(routes)
|
||||
.listen(process.env.APP_PORT || 3000);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import Elysia, { Context } from "elysia";
|
||||
import Elysia from "elysia";
|
||||
import { returnErrorResponse } from "../../helpers/callback/httpResponse";
|
||||
|
||||
export const appAccessTokenMiddleware = () =>
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
import { Context } from "elysia";
|
||||
|
||||
export const isAdminMiddleware = (ctx: Context) => {
|
||||
//validate here
|
||||
const isAdmin = ctx.headers["isAdmin"];
|
||||
if (!isAdmin) {
|
||||
ctx.set.status = 403;
|
||||
return {
|
||||
error: "Forbidden",
|
||||
message: "You don't have access to this resource",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { AppError } from "../../../../helpers/error/instances/app";
|
||||
import { jwtDecode } from "../../../../helpers/http/jwt/decode";
|
||||
import { jwtEncode } from "../../../../helpers/http/jwt/encode";
|
||||
|
||||
export const tokenValidationService = (payload: string) => {
|
||||
try {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { getEpisodeReferenceAPI } from "../../../../config/apis/episode.reference";
|
||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||
import { MediaEpisodeInfoResponse } from "../../types/mediaEpisodeInfo.type";
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { SystemAccountId } from "../../../../config/account/system";
|
||||
import { getContentReferenceAPI } from "../../../../config/apis/media.reference";
|
||||
import { generateUUIDv7 } from "../../../../helpers/databases/uuidv7";
|
||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||
import { bulkInsertCharactersRepository } from "../../repositories/bulkInsertCharacters.repository";
|
||||
import { bulkInsertLangVARepository } from "../../repositories/bulkInsertLangVA.repository";
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { SystemAccountId } from "../../../../config/account/system";
|
||||
import { generateUUIDv7 } from "../../../../helpers/databases/uuidv7";
|
||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||
import { bulkInsertVoiceActorRepository } from "../../repositories/bulkInsertVoiceActor.repository";
|
||||
import { Person } from "../../types/mediaCharWithVAInfo";
|
||||
|
||||
@ -34,12 +34,12 @@ interface Data {
|
||||
year: number;
|
||||
broadcast: Broadcast;
|
||||
producers: Genre[];
|
||||
licensors: any[];
|
||||
licensors: unknown[];
|
||||
studios: Genre[];
|
||||
genres: Genre[];
|
||||
explicit_genres: any[];
|
||||
explicit_genres: unknown[];
|
||||
themes: Genre[];
|
||||
demographics: any[];
|
||||
demographics: unknown[];
|
||||
relations: Relation[];
|
||||
theme: Theme;
|
||||
external: External[];
|
||||
|
||||
@ -10,7 +10,7 @@ interface Data {
|
||||
name: string;
|
||||
given_name: null;
|
||||
family_name: null;
|
||||
alternate_names: any[];
|
||||
alternate_names: string[];
|
||||
birthday: Date;
|
||||
favorites: number;
|
||||
about: string;
|
||||
|
||||
@ -6,14 +6,17 @@ const includeOptions = ["preference", "assignedRoles"] as const;
|
||||
export const getUserOptionsSchema = z.object({
|
||||
verbosity: z.enum(
|
||||
["exists", "basic", "full"],
|
||||
"option: verbosity value must match with enum types"
|
||||
"option: verbosity value must match with enum types",
|
||||
),
|
||||
include: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => val?.split(",") ?? [])
|
||||
.refine(
|
||||
(arr) => arr.every((val) => includeOptions.includes(val.trim() as any)),
|
||||
"option: include value didn't match with enum types"
|
||||
(arr) =>
|
||||
arr.every((val) =>
|
||||
includeOptions.includes(val.trim() as typeof includeOptions[number]),
|
||||
),
|
||||
"option: include value didn't match with enum types",
|
||||
),
|
||||
});
|
||||
|
||||
@ -2,26 +2,6 @@ import { Prisma } from "@prisma/client";
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
import { userSessionModel } from "../userSession.model";
|
||||
|
||||
type CreateUserSessionResponse = Prisma.UserSessionGetPayload<{
|
||||
select: {
|
||||
id: true;
|
||||
deviceType: true;
|
||||
isAuthenticated: true;
|
||||
validUntil: true;
|
||||
user: {
|
||||
select: {
|
||||
id: true;
|
||||
name: true;
|
||||
email: true;
|
||||
username: true;
|
||||
avatar: true;
|
||||
birthDate: true;
|
||||
bioProfile: true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}>;
|
||||
|
||||
export const createUserSessionRepository = async (
|
||||
data: Prisma.UserSessionUncheckedCreateInput,
|
||||
) => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { minioBucketName, minioClient } from "../client";
|
||||
import { minioClient } from "../client";
|
||||
import { ensureBucketExists } from "../validations/ensureBucketExists";
|
||||
|
||||
export const getStreamFile = async (filename: string) => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { minioBucketName, minioClient, minioProtocol } from "../client";
|
||||
import { minioBucketName, minioClient } from "../client";
|
||||
import { ensureBucketExists } from "../validations/ensureBucketExists";
|
||||
import { Readable } from "stream";
|
||||
|
||||
@ -7,7 +7,7 @@ export const uploadFile = async (
|
||||
options?: {
|
||||
fileDir?: string;
|
||||
fileName?: string;
|
||||
}
|
||||
},
|
||||
): Promise<string> => {
|
||||
// Ensure the target MinIO bucket exists before performing any upload
|
||||
await ensureBucketExists();
|
||||
|
||||
Reference in New Issue
Block a user