🚨 fix all linting error
This commit is contained in:
@ -4,6 +4,9 @@ import tseslint from "typescript-eslint";
|
||||
import { defineConfig } from "eslint/config";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
ignores: ["src/modules/debug/**"],
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.{js,mjs,cjs,ts,mts,cts}"],
|
||||
plugins: { js },
|
||||
|
||||
@ -9,6 +9,6 @@ export const unautenticatedMiddleware = (ctx: Context) => {
|
||||
if (cookie && cookie.auth_token)
|
||||
return returnErrorResponse(ctx.set, 401, "You are already logged in. ");
|
||||
} catch (_) {
|
||||
// Pass
|
||||
void _; // Pass
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
import { jwtDecode } from "../../../helpers/http/jwt/decode";
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
import { Context } from "elysia";
|
||||
import {
|
||||
returnErrorResponse,
|
||||
returnWriteResponse,
|
||||
} from "../../../helpers/callback/httpResponse";
|
||||
import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
|
||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { editUserService } from "../services/editUser.service";
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
import {
|
||||
returnErrorResponse,
|
||||
returnReadResponse,
|
||||
} from "../../../helpers/callback/httpResponse";
|
||||
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
|
||||
import { Context } from "elysia";
|
||||
import { getAllUsersService } from "../services/getAllUser.service";
|
||||
import { mainErrorHandler } from "../../../helpers/error/handler";
|
||||
|
||||
@ -5,20 +5,13 @@ export const checkUserEmailAndUsernameAvailabillityRepo = async (
|
||||
username: string,
|
||||
email: string
|
||||
) => {
|
||||
try {
|
||||
const checkUsernameAndEmailAvailabillity = await userModel.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{ username: username ?? undefined },
|
||||
{ email: email ?? undefined },
|
||||
],
|
||||
OR: [{ username: username ?? undefined }, { email: email ?? undefined }],
|
||||
NOT: {
|
||||
id: id,
|
||||
},
|
||||
},
|
||||
});
|
||||
return checkUsernameAndEmailAvailabillity;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -2,7 +2,6 @@ import { Prisma } from "@prisma/client";
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const createUserRepo = async (data: Prisma.UserCreateInput) => {
|
||||
try {
|
||||
const userData = await userModel.create({
|
||||
data,
|
||||
omit: {
|
||||
@ -11,7 +10,4 @@ export const createUserRepo = async (data: Prisma.UserCreateInput) => {
|
||||
});
|
||||
|
||||
return userData;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const findUserByEmailOrUsernameRepo = async (identifier: string) => {
|
||||
try {
|
||||
const userData =
|
||||
(await userModel.findUnique({
|
||||
where: { email: identifier },
|
||||
@ -33,7 +31,4 @@ export const findUserByEmailOrUsernameRepo = async (identifier: string) => {
|
||||
|
||||
if (!userData) return false;
|
||||
return userData;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { userModel } from "../user.model";
|
||||
|
||||
export const getAllUserRepo = async () => {
|
||||
try {
|
||||
const data = await userModel.findMany({
|
||||
where: {
|
||||
deletedAt: null,
|
||||
@ -9,7 +8,4 @@ export const getAllUserRepo = async () => {
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,20 +1,16 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { userModel } from "../user.model";
|
||||
import { JWTSessionPayload } from "../../auth/auth.types";
|
||||
|
||||
export const updateUserRepo = async (
|
||||
username: string,
|
||||
payload: Prisma.UserUpdateInput
|
||||
) => {
|
||||
try {
|
||||
const userData = await userModel.update({
|
||||
where: {
|
||||
username,
|
||||
},
|
||||
data: payload,
|
||||
});
|
||||
|
||||
return userData;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
import { getAllUserRepo } from "../repositories/getAllUser.repository";
|
||||
|
||||
export const getAllUsersService = async () => {
|
||||
@ -5,6 +6,6 @@ export const getAllUsersService = async () => {
|
||||
const allUser = await getAllUserRepo();
|
||||
return allUser;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
ErrorForwarder(error);
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,12 +4,8 @@ import { userRoleModel } from "../userRole.model";
|
||||
export const createUserRoleRepo = async (
|
||||
data: Prisma.UserRoleUncheckedCreateInput
|
||||
) => {
|
||||
try {
|
||||
const newUserRole = await userRoleModel.create({
|
||||
data,
|
||||
});
|
||||
return newUserRole;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { createUserRoleRepo } from "../repositories/createUserRole.repository";
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
|
||||
export const createUserRoleService = async (
|
||||
userRoleData: Prisma.UserRoleUncheckedCreateInput
|
||||
@ -23,6 +24,6 @@ export const createUserRoleService = async (
|
||||
const newUserRole = await createUserRoleRepo(dataPayload);
|
||||
return newUserRole;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
ErrorForwarder(error);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { userSessionModel } from "../userSession.model";
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
|
||||
export const createUserSessionRepo = async (
|
||||
data: Prisma.UserSessionUncheckedCreateInput
|
||||
) => {
|
||||
try {
|
||||
const newUserSession = await userSessionModel.create({
|
||||
data: data,
|
||||
include: {
|
||||
@ -24,8 +22,6 @@ export const createUserSessionRepo = async (
|
||||
updatedAt: true,
|
||||
},
|
||||
});
|
||||
|
||||
return newUserSession;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,19 +1,14 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
import { redis } from "../../../utils/databases/redis/connection";
|
||||
|
||||
export const storeUserSessionToCacheRepo = async (
|
||||
userSession: Prisma.UserSessionUncheckedCreateInput,
|
||||
timeExpires: number
|
||||
) => {
|
||||
try {
|
||||
await redis.set(
|
||||
`${process.env.APP_NAME}:users:${userSession.userId}:sessions:${userSession.id}`,
|
||||
String(userSession.validUntil),
|
||||
"EX",
|
||||
timeExpires
|
||||
);
|
||||
} catch (error) {
|
||||
throw new AppError(401, "Failed to store user session to cache");
|
||||
}
|
||||
};
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
* @typedef {Object} ErrorResponse
|
||||
* @property {number} status - The HTTP status code corresponding to the error.
|
||||
* @property {string} message - A human-readable error message.
|
||||
* @property {any} [details] - Additional details about the error, if available.
|
||||
* @property {unknown} [details] - Additional details about the error, if available.
|
||||
*/
|
||||
export interface PrismaErrorTypes {
|
||||
status: number;
|
||||
message: string;
|
||||
details?: any;
|
||||
details?: unknown;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user