🏗️ separate http and internal service

separate between internal and http service due security concern in auth module
This commit is contained in:
Rafi Arrafif
2025-08-07 23:07:53 +07:00
parent 0d71710b14
commit ac0b25fb62
9 changed files with 21 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { Context } from "elysia"; import { Context } from "elysia";
import { returnWriteResponse } from "../../../helpers/callback/httpResponse"; import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
import { githubCallbackService } from "../services/githubCallback.service"; import { githubCallbackService } from "../services/http/githubCallback.service";
import { mainErrorHandler } from "../../../helpers/error/handler"; import { mainErrorHandler } from "../../../helpers/error/handler";
export const githubCallbackController = async ( export const githubCallbackController = async (

View File

@ -1,6 +1,6 @@
import { Context } from "elysia"; import { Context } from "elysia";
import { returnReadResponse } from "../../../helpers/callback/httpResponse"; import { returnReadResponse } from "../../../helpers/callback/httpResponse";
import { githubRequestService } from "../services/githubRequest.service"; import { githubRequestService } from "../services/http/githubRequest.service";
export const githubRequestController = async (ctx: Context) => { export const githubRequestController = async (ctx: Context) => {
const loginUrl = await githubRequestService(); const loginUrl = await githubRequestService();

View File

@ -1,7 +1,7 @@
import { Context } from "elysia"; import { Context } from "elysia";
import { returnWriteResponse } from "../../../helpers/callback/httpResponse"; import { returnWriteResponse } from "../../../helpers/callback/httpResponse";
import { mainErrorHandler } from "../../../helpers/error/handler"; import { mainErrorHandler } from "../../../helpers/error/handler";
import { googleCallbackService } from "../services/googleCallback.service"; import { googleCallbackService } from "../services/http/googleCallback.service";
export const googleCallbackController = async ( export const googleCallbackController = async (
ctx: Context & { query: { code: string; state: string } } ctx: Context & { query: { code: string; state: string } }

View File

@ -1,6 +1,6 @@
import { Context } from "elysia"; import { Context } from "elysia";
import { mainErrorHandler } from "../../../helpers/error/handler"; import { mainErrorHandler } from "../../../helpers/error/handler";
import { googleRequestService } from "../services/googleRequest.service"; import { googleRequestService } from "../services/http/googleRequest.service";
import { returnReadResponse } from "../../../helpers/callback/httpResponse"; import { returnReadResponse } from "../../../helpers/callback/httpResponse";
export const googleRequestController = async (ctx: Context) => { export const googleRequestController = async (ctx: Context) => {

View File

@ -1,5 +1,5 @@
import { AppError } from "../../../helpers/error/instances/app"; import { AppError } from "../../../../helpers/error/instances/app";
import { githubProvider } from "../providers/github.provider"; import { githubProvider } from "../../providers/github.provider";
export const githubCallbackService = async (code: string) => { export const githubCallbackService = async (code: string) => {
try { try {

View File

@ -1,6 +1,6 @@
import * as arctic from "arctic"; import * as arctic from "arctic";
import { githubProvider } from "../providers/github.provider"; import { githubProvider } from "../../providers/github.provider";
import { AppError } from "../../../helpers/error/instances/app"; import { AppError } from "../../../../helpers/error/instances/app";
export const githubRequestService = async () => { export const githubRequestService = async () => {
try { try {

View File

@ -1,7 +1,7 @@
import { AppError } from "../../../helpers/error/instances/app"; import { AppError } from "../../../../helpers/error/instances/app";
import { googleProvider } from "../providers/google.provider"; import { googleProvider } from "../../providers/google.provider";
import { redis } from "../../../utils/databases/redis/connection"; import { redis } from "../../../../utils/databases/redis/connection";
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder"; import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
export const googleCallbackService = async (query: { export const googleCallbackService = async (query: {
state: string; state: string;

View File

@ -1,7 +1,7 @@
import * as arctic from "arctic"; import * as arctic from "arctic";
import { AppError } from "../../../helpers/error/instances/app"; import { AppError } from "../../../../helpers/error/instances/app";
import { googleProvider } from "../providers/google.provider"; import { googleProvider } from "../../providers/google.provider";
import { redis } from "../../../utils/databases/redis/connection"; import { redis } from "../../../../utils/databases/redis/connection";
export const googleRequestService = async () => { export const googleRequestService = async () => {
try { try {

View File

@ -0,0 +1,6 @@
export const loginIfExistAndCreateIfNotService = () => {
/**
* Create auth session if user already exist,
* create user account and give them auth session if not
*/
};