diff --git a/src/app/_dto/misskey-callback/user-info.dto.ts b/src/app/_dto/misskey-callback/user-info.dto.ts index 96ff146..b1dbe43 100644 --- a/src/app/_dto/misskey-callback/user-info.dto.ts +++ b/src/app/_dto/misskey-callback/user-info.dto.ts @@ -1,4 +1,4 @@ -import type { MiUser } from '@/app/api/misskey-entities/user'; +import type { MiUser } from '@/app/api/_misskey-entities/user'; export class misskeyUserInfoPayload { user: MiUser; diff --git a/src/app/api/misskey-entities/user.ts b/src/app/api/_misskey-entities/user.ts similarity index 100% rename from src/app/api/misskey-entities/user.ts rename to src/app/api/_misskey-entities/user.ts diff --git a/src/utils/apiErrorResponse/sendApiError.ts b/src/app/api/_utils/apiErrorResponse/sendApiError.ts similarity index 100% rename from src/utils/apiErrorResponse/sendApiError.ts rename to src/app/api/_utils/apiErrorResponse/sendApiError.ts diff --git a/src/app/api/functions/web/fetchUsername.ts b/src/app/api/_utils/fetchUsername.ts similarity index 100% rename from src/app/api/functions/web/fetchUsername.ts rename to src/app/api/_utils/fetchUsername.ts diff --git a/src/utils/getIp/get-ip-from-Request.ts b/src/app/api/_utils/getIp/get-ip-from-Request.ts similarity index 86% rename from src/utils/getIp/get-ip-from-Request.ts rename to src/app/api/_utils/getIp/get-ip-from-Request.ts index 8e3748a..f74f13f 100644 --- a/src/utils/getIp/get-ip-from-Request.ts +++ b/src/app/api/_utils/getIp/get-ip-from-Request.ts @@ -1,5 +1,5 @@ import { NextRequest } from 'next/server'; -import { Logger } from '../logger/Logger'; +import { Logger } from '@/utils/logger/Logger'; const logger = new Logger('get-ip-from-request'); export function getIpFromRequest(req: NextRequest) { diff --git a/src/utils/getIp/get-ip-hash.ts b/src/app/api/_utils/getIp/get-ip-hash.ts similarity index 100% rename from src/utils/getIp/get-ip-hash.ts rename to src/app/api/_utils/getIp/get-ip-hash.ts diff --git a/src/utils/getPrismaClient/get-prisma-client.ts b/src/app/api/_utils/getPrismaClient/get-prisma-client.ts similarity index 100% rename from src/utils/getPrismaClient/get-prisma-client.ts rename to src/app/api/_utils/getPrismaClient/get-prisma-client.ts diff --git a/src/app/api/functions/josa.ts b/src/app/api/_utils/josa.ts similarity index 100% rename from src/app/api/functions/josa.ts rename to src/app/api/_utils/josa.ts diff --git a/src/app/api/functions/web/verify-jwt.ts b/src/app/api/_utils/jwt/verify-jwt.ts similarity index 100% rename from src/app/api/functions/web/verify-jwt.ts rename to src/app/api/_utils/jwt/verify-jwt.ts diff --git a/src/utils/ratelimiter/rateLimiter.ts b/src/app/api/_utils/ratelimiter/rateLimiter.ts similarity index 98% rename from src/utils/ratelimiter/rateLimiter.ts rename to src/app/api/_utils/ratelimiter/rateLimiter.ts index 213c59d..ae0ea5b 100644 --- a/src/utils/ratelimiter/rateLimiter.ts +++ b/src/app/api/_utils/ratelimiter/rateLimiter.ts @@ -1,5 +1,5 @@ import { Redis } from 'ioredis'; -import { Logger } from '../logger/Logger'; +import { Logger } from '@/utils/logger/Logger'; export class RateLimiterService { private redis: Redis; diff --git a/src/app/api/db/create-question/route.ts b/src/app/api/db/create-question/route.ts index e0a8b35..9c5bb20 100644 --- a/src/app/api/db/create-question/route.ts +++ b/src/app/api/db/create-question/route.ts @@ -1,15 +1,14 @@ import { CreateQuestionDto } from '@/app/_dto/create_question/create-question.dto'; import type { user } from '@prisma/client'; import { type NextRequest, NextResponse } from 'next/server'; -import { verifyToken } from '../../functions/web/verify-jwt'; +import { verifyToken } from '../../_utils/jwt/verify-jwt'; import { validateStrict } from '@/utils/validator/strictValidator'; -import { sendErrorResponse } from '../../functions/web/errorResponse'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; -import { getIpFromRequest } from '@/utils/getIp/get-ip-from-Request'; -import { getIpHash } from '@/utils/getIp/get-ip-hash'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; +import { getIpFromRequest } from '@/app/api/_utils/getIp/get-ip-from-Request'; +import { getIpHash } from '@/app/api/_utils/getIp/get-ip-hash'; const logger = new Logger('create-question'); export async function POST(req: NextRequest) { @@ -17,7 +16,7 @@ export async function POST(req: NextRequest) { const token = req.cookies.get('jwtToken')?.value; const tokenPayload = await verifyToken(token) .then((payload) => payload) - .catch(() => { }); + .catch(() => {}); if (tokenPayload) { const limiter = RateLimiterService.getLimiter(); const limited = await limiter.limit(`create-question-${tokenPayload.handle}`, { @@ -45,7 +44,7 @@ export async function POST(req: NextRequest) { data = await validateStrict(CreateQuestionDto, await req.json()); } catch (errors) { logger.warn(errors); - return sendErrorResponse(400, `${errors}`); + return sendApiError(400, `${errors}`); } const questionee_user = await prisma.user.findUniqueOrThrow({ @@ -78,7 +77,7 @@ export async function POST(req: NextRequest) { } } catch (err) { logger.warn(`questioner verify ERROR! ${err}`); - return sendErrorResponse(403, `${err}`); + return sendApiError(403, `${err}`); } } diff --git a/src/app/api/db/delete-answer/route.ts b/src/app/api/db/delete-answer/route.ts index f329a01..5f70aa9 100644 --- a/src/app/api/db/delete-answer/route.ts +++ b/src/app/api/db/delete-answer/route.ts @@ -1,12 +1,12 @@ import { DeleteAnswerDto } from '@/app/_dto/delete-answer/delete-answer.dto'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; import { validateStrict } from '@/utils/validator/strictValidator'; import { cookies } from 'next/headers'; import { NextRequest, NextResponse } from 'next/server'; -import { verifyToken } from '../../functions/web/verify-jwt'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { verifyToken } from '../../_utils/jwt/verify-jwt'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; const logger = new Logger('delete-answer'); export async function POST(req: NextRequest) { diff --git a/src/app/api/db/fetch-all-answers/route.ts b/src/app/api/db/fetch-all-answers/route.ts index ecf50de..d85cd7f 100644 --- a/src/app/api/db/fetch-all-answers/route.ts +++ b/src/app/api/db/fetch-all-answers/route.ts @@ -1,10 +1,10 @@ import { AnswerDto } from '@/app/_dto/Answers.dto'; import { FetchAllAnswersReqDto } from '@/app/_dto/fetch-all-answers/fetch-all-answers.dto'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; -import { getIpFromRequest } from '@/utils/getIp/get-ip-from-Request'; -import { getIpHash } from '@/utils/getIp/get-ip-hash'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; +import { getIpFromRequest } from '@/app/api/_utils/getIp/get-ip-from-Request'; +import { getIpHash } from '@/app/api/_utils/getIp/get-ip-hash'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; import { validateStrict } from '@/utils/validator/strictValidator'; import { NextRequest, NextResponse } from 'next/server'; diff --git a/src/app/api/db/fetch-my-profile/route.ts b/src/app/api/db/fetch-my-profile/route.ts index 4bb8420..7bb9fd0 100644 --- a/src/app/api/db/fetch-my-profile/route.ts +++ b/src/app/api/db/fetch-my-profile/route.ts @@ -1,9 +1,9 @@ import { userProfileMeDto } from '@/app/_dto/fetch-profile/Profile.dto'; import { NextRequest, NextResponse } from 'next/server'; -import { verifyToken } from '../../functions/web/verify-jwt'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; +import { verifyToken } from '../../_utils/jwt/verify-jwt'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; export async function GET(req: NextRequest) { const prisma = GetPrismaClient.getClient(); diff --git a/src/app/api/db/fetch-my-questions/route.ts b/src/app/api/db/fetch-my-questions/route.ts index 1e6ee15..9dc0ac9 100644 --- a/src/app/api/db/fetch-my-questions/route.ts +++ b/src/app/api/db/fetch-my-questions/route.ts @@ -1,8 +1,8 @@ import { NextRequest, NextResponse } from 'next/server'; -import { verifyToken } from '../../functions/web/verify-jwt'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; +import { verifyToken } from '../../_utils/jwt/verify-jwt'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; export async function GET(req: NextRequest) { const prisma = GetPrismaClient.getClient(); diff --git a/src/app/api/db/fetch-profile/[handle]/route.ts b/src/app/api/db/fetch-profile/[handle]/route.ts index d59f18c..695956c 100644 --- a/src/app/api/db/fetch-profile/[handle]/route.ts +++ b/src/app/api/db/fetch-profile/[handle]/route.ts @@ -1,10 +1,10 @@ -import { userProfileDto, userProfileWithHostnameDto } from '@/app/_dto/fetch-profile/Profile.dto'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; -import { getIpFromRequest } from '@/utils/getIp/get-ip-from-Request'; -import { getIpHash } from '@/utils/getIp/get-ip-hash'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { userProfileWithHostnameDto } from '@/app/_dto/fetch-profile/Profile.dto'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; +import { getIpFromRequest } from '@/app/api/_utils/getIp/get-ip-from-Request'; +import { getIpHash } from '@/app/api/_utils/getIp/get-ip-hash'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; import { NextRequest, NextResponse } from 'next/server'; const logger = new Logger('fetch-profile/handle'); diff --git a/src/app/api/db/fetch-user-answers/route.ts b/src/app/api/db/fetch-user-answers/route.ts index 70d314b..4ba94db 100644 --- a/src/app/api/db/fetch-user-answers/route.ts +++ b/src/app/api/db/fetch-user-answers/route.ts @@ -1,13 +1,12 @@ import { FetchUserAnswersDto } from '@/app/_dto/fetch-user-answers/fetch-user-answers.dto'; import { validateStrict } from '@/utils/validator/strictValidator'; import { NextRequest, NextResponse } from 'next/server'; -import { sendErrorResponse } from '../../functions/web/errorResponse'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; -import { getIpHash } from '@/utils/getIp/get-ip-hash'; -import { getIpFromRequest } from '@/utils/getIp/get-ip-from-Request'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; +import { getIpHash } from '@/app/api/_utils/getIp/get-ip-hash'; +import { getIpFromRequest } from '@/app/api/_utils/getIp/get-ip-from-Request'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; const logger = new Logger('fetch-user-answer'); export async function POST(req: NextRequest) { @@ -17,7 +16,7 @@ export async function POST(req: NextRequest) { try { data = await validateStrict(FetchUserAnswersDto, await req.json()); } catch (err) { - return sendErrorResponse(400, `${err}`); + return sendApiError(400, `${err}`); } const limiter = RateLimiterService.getLimiter(); diff --git a/src/app/api/functions/web/errorResponse.ts b/src/app/api/functions/web/errorResponse.ts deleted file mode 100644 index be32b1c..0000000 --- a/src/app/api/functions/web/errorResponse.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { NextResponse } from 'next/server'; - -export function sendErrorResponse(code: number, message: string) { - return NextResponse.json({ status: code, message: message }, { status: code }); -} diff --git a/src/app/api/web/fetch-name-with-emoji/route.ts b/src/app/api/web/fetch-name-with-emoji/route.ts index 949b643..87e5926 100644 --- a/src/app/api/web/fetch-name-with-emoji/route.ts +++ b/src/app/api/web/fetch-name-with-emoji/route.ts @@ -1,9 +1,9 @@ import { fetchNameWithEmojiReqDto } from '@/app/_dto/fetch-name-with-emoji/fetch-name-with-emoji.dto'; import { validateStrict } from '@/utils/validator/strictValidator'; import { NextRequest, NextResponse } from 'next/server'; -import { sendErrorResponse } from '../../functions/web/errorResponse'; import detectInstance from '../../../../utils/detectInstance/detectInstance'; import { Logger } from '@/utils/logger/Logger'; +import { sendApiError } from '../../_utils/apiErrorResponse/sendApiError'; const logger = new Logger('fetch-name-with-emoji'); export async function POST(req: NextRequest) { @@ -11,7 +11,7 @@ export async function POST(req: NextRequest) { try { data = await validateStrict(fetchNameWithEmojiReqDto, await req.json()); } catch (err) { - return sendErrorResponse(400, `${err}`); + return sendApiError(400, `${err}`); } const { name, baseUrl }: fetchNameWithEmojiReqDto = data; @@ -48,38 +48,6 @@ export async function POST(req: NextRequest) { } case 'misskey': - try { - if (emojiInUsername) { - for (let i = 0; i < emojiInUsername.length; i++) { - const emojiAddress = await fetch(`https://${baseUrl}/api/emoji`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - name: emojiInUsername[i], - }), - }).then((r) => r.json()); - - usernameEmojiAddress.push(emojiAddress.url); - } - - for (const el in nameArray) { - usernameIndex.push(nameArray.indexOf(emojiInUsername[el])); - } - const filteredIndex = usernameIndex.filter((value) => value >= 0); - - for (let i = 0; i < usernameEmojiAddress.length; i++) { - nameArray.splice(filteredIndex[i], 1, usernameEmojiAddress[i]); - } - } - - return NextResponse.json({ nameWithEmoji: nameArray }); - } catch (err) { - logger.error(err); - return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }); - } - case 'cherrypick': try { if (emojiInUsername) { @@ -109,8 +77,8 @@ export async function POST(req: NextRequest) { return NextResponse.json({ nameWithEmoji: nameArray }); } catch (err) { - logger.error(err); - return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }); + logger.warn(err); + return NextResponse.json({ nameWithEmoji: [name] }); } default: diff --git a/src/app/api/web/mastodon-login/route.ts b/src/app/api/web/mastodon-login/route.ts index 30e6a40..59ce041 100644 --- a/src/app/api/web/mastodon-login/route.ts +++ b/src/app/api/web/mastodon-login/route.ts @@ -1,14 +1,13 @@ import { loginReqDto } from '@/app/_dto/web/login/login.dto'; import { validateStrict } from '@/utils/validator/strictValidator'; import { NextRequest, NextResponse } from 'next/server'; -import { sendErrorResponse } from '../../functions/web/errorResponse'; import { v4 as uuid } from 'uuid'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils//getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; -import { getIpHash } from '@/utils/getIp/get-ip-hash'; -import { getIpFromRequest } from '@/utils/getIp/get-ip-from-Request'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; +import { getIpHash } from '@/app/api/_utils/getIp/get-ip-hash'; +import { getIpFromRequest } from '@/app/api/_utils/getIp/get-ip-from-Request'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; const logger = new Logger('mastodon-login'); export async function POST(req: NextRequest) { @@ -19,7 +18,7 @@ export async function POST(req: NextRequest) { try { data = await validateStrict(loginReqDto, await req.json()); } catch (err) { - return sendErrorResponse(400, `${err}`); + return sendApiError(400, `${err}`); } const limiter = RateLimiterService.getLimiter(); @@ -57,7 +56,7 @@ export async function POST(req: NextRequest) { }).then((r) => r.json()); if (!res.id) { - return sendErrorResponse(500, `Mastodon Response: ${JSON.stringify(res)}`); + return sendApiError(500, `Mastodon Response: ${JSON.stringify(res)}`); } logger.log('New Mastodon OAuth2 App Created:', res); @@ -84,7 +83,7 @@ export async function POST(req: NextRequest) { return NextResponse.json(session); } } catch (err) { - return sendErrorResponse(500, `login error... ${err}`); + return sendApiError(500, `login error... ${err}`); } } diff --git a/src/app/api/web/misskey-login/route.ts b/src/app/api/web/misskey-login/route.ts index 636b51d..3bfd72c 100644 --- a/src/app/api/web/misskey-login/route.ts +++ b/src/app/api/web/misskey-login/route.ts @@ -1,15 +1,14 @@ import { loginReqDto } from '@/app/_dto/web/login/login.dto'; import { validateStrict } from '@/utils/validator/strictValidator'; import { NextRequest, NextResponse } from 'next/server'; -import { sendErrorResponse } from '../../functions/web/errorResponse'; import { MiApiError, MiAuthSession } from '@/app'; import detectInstance from '../../../../utils/detectInstance/detectInstance'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { RateLimiterService } from '@/utils/ratelimiter/rateLimiter'; -import { getIpHash } from '@/utils/getIp/get-ip-hash'; -import { getIpFromRequest } from '@/utils/getIp/get-ip-from-Request'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; +import { RateLimiterService } from '@/app/api/_utils/ratelimiter/rateLimiter'; +import { getIpHash } from '@/app/api/_utils/getIp/get-ip-hash'; +import { getIpFromRequest } from '@/app/api/_utils/getIp/get-ip-from-Request'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; const logger = new Logger('misskey-login'); export async function POST(req: NextRequest) { @@ -18,7 +17,7 @@ export async function POST(req: NextRequest) { try { data = await validateStrict(loginReqDto, await req.json()); } catch (err) { - return sendErrorResponse(400, `${err}`); + return sendApiError(400, `${err}`); } const limiter = RateLimiterService.getLimiter(); @@ -58,7 +57,7 @@ export async function POST(req: NextRequest) { body: JSON.stringify(payload), }); if (!res.ok) { - return sendErrorResponse(500, `Login Error! From Remote: ${await res.text()}`); + return sendApiError(500, `Login Error! From Remote: ${await res.text()}`); } const data = await res.json(); const appSecret = data.secret; @@ -80,7 +79,7 @@ export async function POST(req: NextRequest) { }); const authRes = await initiateMisskeyAuthSession(misskeyHost, appSecret); if (!authRes.ok) { - return sendErrorResponse(500, `Fail to Create Auth Session: ${await authRes.text()}`); + return sendApiError(500, `Fail to Create Auth Session: ${await authRes.text()}`); } const misskeyAuthSession = (await authRes.json()) as MiAuthSession; logger.log(`New Misskey Auth Session Created: `, misskeyAuthSession); @@ -99,14 +98,14 @@ export async function POST(req: NextRequest) { data: { appSecret: null }, }); } - return sendErrorResponse(500, `Fail to Create Misskey Auth Session`); + return sendApiError(500, `Fail to Create Misskey Auth Session`); } const misskeyAuthSession = (await res.json()) as MiAuthSession; logger.log(`New Misskey Auth Session Created: `, misskeyAuthSession); return NextResponse.json(misskeyAuthSession); } } catch (err) { - return sendErrorResponse(500, `login error... ${err}`); + return sendApiError(500, `login error... ${err}`); } } diff --git a/src/app/index.d.ts b/src/app/index.d.ts index f0a5802..8d10782 100644 --- a/src/app/index.d.ts +++ b/src/app/index.d.ts @@ -1,5 +1,5 @@ import type { profile, user } from '@prisma/client'; -import { MiUser } from './api/misskey-entities/user'; +import { MiUser } from './api/_misskey-entities/user'; interface MiAuthSession { token: string; diff --git a/src/app/main/questions/action.ts b/src/app/main/questions/action.ts index 94dab4d..eccce14 100644 --- a/src/app/main/questions/action.ts +++ b/src/app/main/questions/action.ts @@ -1,9 +1,9 @@ 'use server'; import type { mastodonTootAnswers, MkNoteAnswers, typedAnswer } from '@/app'; -import { verifyToken } from '@/app/api/functions/web/verify-jwt'; -import { sendApiError } from '@/utils/apiErrorResponse/sendApiError'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { verifyToken } from '@/app/api/_utils/jwt/verify-jwt'; +import { sendApiError } from '@/app/api/_utils/apiErrorResponse/sendApiError'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; import { question } from '@prisma/client'; import { createHash } from 'crypto'; diff --git a/src/app/main/settings/action.ts b/src/app/main/settings/action.ts index 824dbde..dc020f0 100644 --- a/src/app/main/settings/action.ts +++ b/src/app/main/settings/action.ts @@ -2,9 +2,9 @@ import { cookies } from 'next/headers'; import { FormValue } from './page'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; -import { verifyToken } from '@/app/api/functions/web/verify-jwt'; +import { verifyToken } from '@/app/api/_utils/jwt/verify-jwt'; export async function fetchUser() { const logger = new Logger('fetchUser'); diff --git a/src/app/main/user/[handle]/[answer]/action.ts b/src/app/main/user/[handle]/[answer]/action.ts index 0ad2e40..7bdcf5a 100644 --- a/src/app/main/user/[handle]/[answer]/action.ts +++ b/src/app/main/user/[handle]/[answer]/action.ts @@ -1,6 +1,6 @@ 'use server'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; export async function fetchAnswer(id: string) { const prisma = GetPrismaClient.getClient(); diff --git a/src/app/main/user/[handle]/_profile.tsx b/src/app/main/user/[handle]/_profile.tsx index b0f8ed2..de5891f 100644 --- a/src/app/main/user/[handle]/_profile.tsx +++ b/src/app/main/user/[handle]/_profile.tsx @@ -2,7 +2,7 @@ import DialogModalOneButton from '@/app/_components/modalOneButton'; import NameComponents from '@/app/_components/NameComponents'; import { CreateQuestionDto } from '@/app/_dto/create_question/create-question.dto'; import { userProfileWithHostnameDto } from '@/app/_dto/fetch-profile/Profile.dto'; -import josa from '@/app/api/functions/josa'; +import josa from '@/app/api/_utils/josa'; import Link from 'next/link'; import { useParams } from 'next/navigation'; import { useEffect, useRef, useState } from 'react'; diff --git a/src/app/mastodon-callback/action.ts b/src/app/mastodon-callback/action.ts index 5b76381..a328669 100644 --- a/src/app/mastodon-callback/action.ts +++ b/src/app/mastodon-callback/action.ts @@ -2,11 +2,11 @@ import { validateStrict } from '@/utils/validator/strictValidator'; import { mastodonCallbackTokenClaimPayload } from '../_dto/mastodon-callback/callback-token-claim.dto'; -import { fetchNameWithEmoji } from '../api/functions/web/fetchUsername'; +import { fetchNameWithEmoji } from '../api/_utils/fetchUsername'; import { DBpayload } from '../misskey-callback/page'; import { cookies } from 'next/headers'; import { SignJWT } from 'jose'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; const logger = new Logger('Mastodon-callback'); diff --git a/src/app/misskey-callback/actions.ts b/src/app/misskey-callback/actions.ts index cb27b2c..8adc4fb 100644 --- a/src/app/misskey-callback/actions.ts +++ b/src/app/misskey-callback/actions.ts @@ -4,12 +4,12 @@ import { DBpayload } from './page'; import { cookies } from 'next/headers'; import { SignJWT } from 'jose'; import { misskeyAccessKeyApiResponse } from '..'; -import { MiUser } from '../api/misskey-entities/user'; -import { fetchNameWithEmoji } from '../api/functions/web/fetchUsername'; +import { MiUser } from '../api/_misskey-entities/user'; +import { fetchNameWithEmoji } from '../api/_utils/fetchUsername'; import { validateStrict } from '@/utils/validator/strictValidator'; import { misskeyCallbackTokenClaimPayload } from '../_dto/misskey-callback/callback-token-claim.dto'; import { misskeyUserInfoPayload } from '../_dto/misskey-callback/user-info.dto'; -import { GetPrismaClient } from '@/utils/getPrismaClient/get-prisma-client'; +import { GetPrismaClient } from '@/app/api/_utils/getPrismaClient/get-prisma-client'; import { Logger } from '@/utils/logger/Logger'; const logger = new Logger('misskey-callback'); diff --git a/src/app/misskey-callback/page.tsx b/src/app/misskey-callback/page.tsx index 9eec7bb..2e3e4c2 100644 --- a/src/app/misskey-callback/page.tsx +++ b/src/app/misskey-callback/page.tsx @@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'; import Image from 'next/image'; import { useRouter } from 'next/navigation'; import { login } from './actions'; -import { MiUser as MiUser } from '../api/misskey-entities/user'; +import { MiUser as MiUser } from '../api/_misskey-entities/user'; import { misskeyCallbackTokenClaimPayload } from '../_dto/misskey-callback/callback-token-claim.dto'; import { misskeyUserInfoPayload } from '../_dto/misskey-callback/user-info.dto'; import type { profile, user } from '@prisma/client'; diff --git a/src/utils/detectInstance/detectInstance.ts b/src/utils/detectInstance/detectInstance.ts index 82f2218..8d7c859 100644 --- a/src/utils/detectInstance/detectInstance.ts +++ b/src/utils/detectInstance/detectInstance.ts @@ -1,4 +1,4 @@ -'use server' +'use server'; import { Logger } from '@/utils/logger/Logger';