refactor: standardize API base URL usage across proxy routes

- Introduced a consistent API_BASE_URL variable in all proxy route files to streamline API endpoint construction.
- Updated fetch calls to utilize the new variable, enhancing maintainability and reducing redundancy in URL definitions.
- This change improves code clarity and ensures that the base URL can be easily modified in one place if needed.
This commit is contained in:
Daniel Luiz Alves
2025-06-30 11:53:05 -03:00
parent 7eaae9fcb4
commit 9e1c6c0e9a
71 changed files with 275 additions and 86 deletions

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/storage/check-upload`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/storage/check-upload`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
const url = `${API_BASE_URL}/app/configs`;
const apiRes = await fetch(`${API_BASE_URL}/app/configs`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/storage/disk-space`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/storage/disk-space`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/health`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/health`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/app/info`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/app/info`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/app/logo`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/app/logo`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/app/test-smtp`;
const body = await req.text();
const apiRes = await fetch(`${process.env.API_BASE_URL}/app/test-smtp`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/app/logo`;
const formData = await req.formData();
const apiRes = await fetch(`${process.env.API_BASE_URL}/app/logo`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const body = await req.text();
const url = `${API_BASE_URL}/auth/forgot-password`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/auth/forgot-password`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const body = await req.text();
const url = `${API_BASE_URL}/auth/login`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/auth/login`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/auth/logout`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/auth/logout`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
cookie: cookieHeader || "",

View File

@@ -2,8 +2,10 @@ import { NextRequest, NextResponse } from "next/server";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
const url = `${API_BASE_URL}/auth/me`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/auth/me`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -7,11 +7,11 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
const { provider } = await params;
const url = new URL(request.url);
const queryString = url.search;
const originalHost = request.headers.get("host") || url.host;
const originalProtocol = request.headers.get("x-forwarded-proto") || url.protocol.replace(":", "");
const authorizeUrl = `${API_BASE_URL}/auth/providers/${provider}/authorize${queryString}`;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers/${provider}/authorize${queryString}`, {
const apiRes = await fetch(authorizeUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -7,11 +7,11 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
const { provider } = await params;
const url = new URL(request.url);
const queryString = url.search;
const originalHost = request.headers.get("host") || url.host;
const originalProtocol = request.headers.get("x-forwarded-proto") || url.protocol.replace(":", "");
const callbackUrl = `${API_BASE_URL}/auth/providers/${provider}/callback${queryString}`;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers/${provider}/callback${queryString}`, {
const apiRes = await fetch(callbackUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -3,8 +3,9 @@ import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(request: NextRequest) {
const url = `${API_BASE_URL}/auth/providers/all`;
try {
const apiRes = await fetch(`${API_BASE_URL}/auth/providers/all`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -6,8 +6,9 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
try {
const body = await request.json();
const { id } = await params;
const updateUrl = `${API_BASE_URL}/auth/providers/${id}`;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers/${id}`, {
const apiRes = await fetch(updateUrl, {
method: "PUT",
headers: {
"Content-Type": "application/json",
@@ -37,7 +38,9 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
export async function DELETE(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers/${id}`, {
const deleteUrl = `${API_BASE_URL}/auth/providers/${id}`;
const apiRes = await fetch(deleteUrl, {
method: "DELETE",
headers: {
...Object.fromEntries(

View File

@@ -5,8 +5,9 @@ const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PUT(request: NextRequest) {
try {
const body = await request.json();
const url = `${API_BASE_URL}/auth/providers/order`;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers/order`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",

View File

@@ -9,8 +9,9 @@ export async function GET(request: NextRequest) {
const originalHost = request.headers.get("host") || url.host;
const originalProtocol = request.headers.get("x-forwarded-proto") || url.protocol.replace(":", "");
const listUrl = `${API_BASE_URL}/auth/providers${queryString}`;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers${queryString}`, {
const apiRes = await fetch(listUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
@@ -38,8 +39,9 @@ export async function GET(request: NextRequest) {
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const createUrl = `${API_BASE_URL}/auth/providers`;
const apiRes = await fetch(`${API_BASE_URL}/auth/providers`, {
const apiRes = await fetch(createUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const body = await req.text();
const url = `${API_BASE_URL}/auth/reset-password`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/auth/reset-password`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ key: string }> }) {
const { key } = await params;
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/app/configs/${key}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/app/configs/${key}`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest) {
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/app/configs`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/app/configs`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { id } = await params;
const url = `${API_BASE_URL}/files/${id}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/files/${id}`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
@@ -35,8 +38,9 @@ export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/files/${id}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/files/${id}`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/files/check`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/files/check`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,12 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ objectPath: string[] }> }) {
const { objectPath } = await params;
const cookieHeader = req.headers.get("cookie");
const objectName = objectPath.join("/");
const url = `${process.env.API_BASE_URL}/files/${encodeURIComponent(objectName)}/download`;
const url = `${API_BASE_URL}/files/${encodeURIComponent(objectName)}/download`;
const apiRes = await fetch(url, {
method: "GET",

View File

@@ -1,9 +1,11 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const searchParams = req.nextUrl.searchParams.toString();
const url = `${process.env.API_BASE_URL}/files/presigned-url${searchParams ? `?${searchParams}` : ""}`;
const url = `${API_BASE_URL}/files/presigned-url${searchParams ? `?${searchParams}` : ""}`;
const apiRes = await fetch(url, {
method: "GET",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
const url = `${API_BASE_URL}/files`;
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const apiRes = await fetch(`${process.env.API_BASE_URL}/files`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",
@@ -31,7 +34,7 @@ export async function POST(req: NextRequest) {
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const apiRes = await fetch(`${process.env.API_BASE_URL}/files`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ token: string }> }) {
const { token } = await params;
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/filesystem/download/${token}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/filesystem/download/${token}`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,15 +1,17 @@
import { NextRequest, NextResponse } from "next/server";
export const maxDuration = 300;
export const maxDuration = 3000;
export const dynamic = "force-dynamic";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PUT(req: NextRequest, { params }: { params: Promise<{ token: string }> }) {
const { token } = await params;
const cookieHeader = req.headers.get("cookie");
const body = await req.arrayBuffer();
const url = `${API_BASE_URL}/filesystem/upload/${token}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/filesystem/upload/${token}`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ reverseShareId: string }> }) {
const { reverseShareId } = await params;
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/reverse-shares/${reverseShareId}/alias`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${reverseShareId}/alias`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/reverse-shares/${id}/activate`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${id}/activate`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",

View File

@@ -1,12 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ alias: string }> }) {
const { searchParams } = new URL(req.url);
const password = searchParams.get("password");
const body = await req.text();
const { alias } = await params;
let url = `${process.env.API_BASE_URL}/reverse-shares/alias/${alias}/presigned-url`;
let url = `${API_BASE_URL}/reverse-shares/alias/${alias}/presigned-url`;
if (password) {
url += `?password=${encodeURIComponent(password)}`;
}

View File

@@ -1,12 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ alias: string }> }) {
const { searchParams } = new URL(req.url);
const password = searchParams.get("password");
const body = await req.text();
const { alias } = await params;
let url = `${process.env.API_BASE_URL}/reverse-shares/alias/${alias}/register-file`;
let url = `${API_BASE_URL}/reverse-shares/alias/${alias}/register-file`;
if (password) {
url += `?password=${encodeURIComponent(password)}`;
}

View File

@@ -1,11 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ alias: string }> }) {
const { searchParams } = new URL(req.url);
const password = searchParams.get("password");
const { alias } = await params;
let url = `${process.env.API_BASE_URL}/reverse-shares/alias/${alias}/upload`;
let url = `${API_BASE_URL}/reverse-shares/alias/${alias}/upload`;
if (password) {
url += `?password=${encodeURIComponent(password)}`;
}

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const body = await req.text();
const { id } = await params;
const url = `${API_BASE_URL}/reverse-shares/${id}/check-password`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${id}/check-password`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const url = `${API_BASE_URL}/reverse-shares`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/reverse-shares/${id}/deactivate`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${id}/deactivate`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/reverse-shares/${id}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${id}`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/reverse-shares/${id}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${id}`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ fileId: string }> }) {
const { fileId } = await params;
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/reverse-shares/files/${fileId}/copy`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/files/${fileId}/copy`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ fileId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { fileId } = await params;
const url = `${API_BASE_URL}/reverse-shares/files/${fileId}/download`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/files/${fileId}/download`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
@@ -34,8 +37,9 @@ export async function PUT(req: NextRequest, { params }: { params: Promise<{ file
const cookieHeader = req.headers.get("cookie");
const { fileId } = await params;
const body = await req.json();
const url = `${API_BASE_URL}/reverse-shares/files/${fileId}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/files/${fileId}`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
@@ -65,8 +69,9 @@ export async function PUT(req: NextRequest, { params }: { params: Promise<{ file
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ fileId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { fileId } = await params;
const url = `${API_BASE_URL}/reverse-shares/files/${fileId}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/files/${fileId}`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ fileId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { fileId } = await params;
const url = `${API_BASE_URL}/reverse-shares/files/${fileId}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/files/${fileId}`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ fileId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { fileId } = await params;
const url = `${API_BASE_URL}/reverse-shares/files/${fileId}/download`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/files/${fileId}/download`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/reverse-shares`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PUT(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { id } = await params;
const url = `${API_BASE_URL}/reverse-shares/${id}/password`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares/${id}/password`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",

View File

@@ -1,12 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const { searchParams } = new URL(req.url);
const password = searchParams.get("password");
const body = await req.text();
const { id } = await params;
let url = `${process.env.API_BASE_URL}/reverse-shares/${id}/presigned-url`;
let url = `${API_BASE_URL}/reverse-shares/${id}/presigned-url`;
if (password) {
url += `?password=${encodeURIComponent(password)}`;
}

View File

@@ -1,12 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const { searchParams } = new URL(req.url);
const password = searchParams.get("password");
const body = await req.text();
const { id } = await params;
let url = `${process.env.API_BASE_URL}/reverse-shares/${id}/register-file`;
let url = `${API_BASE_URL}/reverse-shares/${id}/register-file`;
if (password) {
url += `?password=${encodeURIComponent(password)}`;
}

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PUT(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const url = `${API_BASE_URL}/reverse-shares`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/reverse-shares`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const { searchParams } = new URL(req.url);
const password = searchParams.get("password");
const { id } = await params;
let url = `${process.env.API_BASE_URL}/reverse-shares/${id}/upload`;
let url = `${API_BASE_URL}/reverse-shares/${id}/upload`;
if (password) {
url += `?password=${encodeURIComponent(password)}`;
}

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const { shareId } = await params;
const url = `${API_BASE_URL}/shares/${shareId}/alias`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/alias`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ alias: string }> }) {
const cookieHeader = req.headers.get("cookie");
const url = new URL(req.url);
const queryParams = url.search;
const { alias } = await params;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/alias/${alias}${queryParams}`, {
const fetchUrl = `${API_BASE_URL}/shares/alias/${alias}${queryParams}`;
const apiRes = await fetch(fetchUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const url = `${API_BASE_URL}/shares`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/shares/${id}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${id}`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,12 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const url = new URL(req.url);
const searchParams = url.searchParams.toString();
const { shareId } = await params;
const fetchUrl = `${API_BASE_URL}/shares/${shareId}${searchParams ? `?${searchParams}` : ""}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}${searchParams ? `?${searchParams}` : ""}`, {
const apiRes = await fetch(fetchUrl, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { shareId } = await params;
const url = `${API_BASE_URL}/shares/${shareId}/files`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/files`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { shareId } = await params;
const url = `${API_BASE_URL}/shares/${shareId}/files`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/files`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
"Content-Type": "application/json",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/shares/me`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/me`, {
const apiRes = await fetch(url, {
method: "GET",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { shareId } = await params;
const url = `${API_BASE_URL}/shares/${shareId}/password`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/password`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { shareId } = await params;
const url = `${API_BASE_URL}/shares/${shareId}/recipients`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/recipients`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { shareId } = await params;
const body = await req.text();
const url = `${API_BASE_URL}/shares/${shareId}/notify`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/notify`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ shareId: string }> }) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const { shareId } = await params;
const url = `${API_BASE_URL}/shares/${shareId}/recipients`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares/${shareId}/recipients`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PUT(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const body = await req.text();
const url = `${API_BASE_URL}/shares`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/shares`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/users/${id}/activate`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users/${id}/activate`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,9 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/users/avatar`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users/avatar`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const formData = await req.formData();
const url = `${API_BASE_URL}/users/avatar`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users/avatar`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/users/${id}/deactivate`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users/${id}/deactivate`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function DELETE(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const url = `${API_BASE_URL}/users/${id}`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users/${id}`, {
const apiRes = await fetch(url, {
method: "DELETE",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,11 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const searchParams = req.nextUrl.searchParams.toString();
const { id } = await params;
const url = `${process.env.API_BASE_URL}/users/${id}${searchParams ? `?${searchParams}` : ""}`;
const url = `${API_BASE_URL}/users/${id}${searchParams ? `?${searchParams}` : ""}`;
const apiRes = await fetch(url, {
method: "GET",

View File

@@ -1,10 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
const cookieHeader = req.headers.get("cookie");
const searchParams = req.nextUrl.searchParams.toString();
const url = `${process.env.API_BASE_URL}/users${searchParams ? `?${searchParams}` : ""}`;
const url = `${API_BASE_URL}/users${searchParams ? `?${searchParams}` : ""}`;
const apiRes = await fetch(url, {
method: "GET",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function POST(req: NextRequest) {
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/auth/register`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/auth/register`, {
const apiRes = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,12 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const cookieHeader = req.headers.get("cookie");
const { id } = await params;
const body = await req.formData();
const url = `${API_BASE_URL}/users/${id}/avatar`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users/${id}/avatar`, {
const apiRes = await fetch(url, {
method: "PATCH",
headers: {
cookie: cookieHeader || "",

View File

@@ -1,10 +1,13 @@
import { NextRequest, NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function PUT(req: NextRequest) {
const body = await req.text();
const cookieHeader = req.headers.get("cookie");
const url = `${API_BASE_URL}/users`;
const apiRes = await fetch(`${process.env.API_BASE_URL}/users`, {
const apiRes = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",