diff --git a/backend/.env.example b/backend/.env.example index 6c6c357..87e4613 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -1,6 +1,5 @@ APP_KEY= PORT= -SERVER_PATH= API_ENV= LOG_LEVEL= URI_WHITELIST= diff --git a/backend/.env.test b/backend/.env.test index 64a6bb8..05f948c 100644 --- a/backend/.env.test +++ b/backend/.env.test @@ -1,6 +1,5 @@ APP_KEY=testtesttesttest PORT=1337 -SERVER_PATH=test API_ENV=test NODE_ENV=test LOG_LEVEL=info diff --git a/backend/app/services/auth/local/local.auth.ts b/backend/app/services/auth/local/local.auth.ts index 7736599..0b96cf9 100644 --- a/backend/app/services/auth/local/local.auth.ts +++ b/backend/app/services/auth/local/local.auth.ts @@ -4,7 +4,6 @@ import { Strategy } from "passport-local"; import LocalLoginValidator from "#services/auth/local/local-login.validator"; import TokenHandler from "#services/auth/token/token.handler"; -import { createPath } from "#services/config/api-path"; import BlResponseHandler from "#services/response/bl-response.handler"; import { BlError } from "#shared/bl-error/bl-error"; import { BlapiResponse } from "#shared/blapi-response/blapi-response"; @@ -53,7 +52,7 @@ function createPassportStrategy() { } function createAuthLogin() { - router.post(createPath("auth/local/login"), (ctx) => { + router.post("/auth/local/login", (ctx) => { return new Promise((resolve) => { passport.authenticate( "local", @@ -93,7 +92,7 @@ function createAuthLogin() { } function createAuthRegister() { - router.post(createPath("auth/local/register"), (ctx) => { + router.post("/auth/local/register", (ctx) => { return new Promise((resolve, reject) => { const username = ctx.request.body()["username"]; LocalLoginValidator.create( diff --git a/backend/app/services/auth/token/token.endpoint.ts b/backend/app/services/auth/token/token.endpoint.ts index a641bb6..ae0b46d 100644 --- a/backend/app/services/auth/token/token.endpoint.ts +++ b/backend/app/services/auth/token/token.endpoint.ts @@ -2,14 +2,13 @@ import router from "@adonisjs/core/services/router"; import RefreshTokenValidator from "#services/auth/token/refresh/refresh-token.validator"; import TokenHandler from "#services/auth/token/token.handler"; -import { createPath } from "#services/config/api-path"; import BlResponseHandler from "#services/response/bl-response.handler"; import { RefreshToken } from "#services/types/refresh-token"; import { BlError } from "#shared/bl-error/bl-error"; import { BlapiResponse } from "#shared/blapi-response/blapi-response"; function generateEndpoint() { - router.post(createPath("token"), (ctx) => { + router.post("/token", (ctx) => { const refreshToken = ctx.request.body()["refreshToken"]; if (refreshToken) { RefreshTokenValidator.validate(refreshToken).then( @@ -52,7 +51,6 @@ function generateEndpoint() { ); } }); - return router; } const TokenEndpoint = { generateEndpoint, diff --git a/backend/app/services/collection-endpoint/collection-endpoint.ts b/backend/app/services/collection-endpoint/collection-endpoint.ts index 6cd2ad0..b1f2284 100644 --- a/backend/app/services/collection-endpoint/collection-endpoint.ts +++ b/backend/app/services/collection-endpoint/collection-endpoint.ts @@ -4,7 +4,6 @@ import router from "@adonisjs/core/services/router"; import CollectionEndpointAuth from "#services/collection-endpoint/collection-endpoint-auth"; import CollectionEndpointHandler from "#services/collection-endpoint/collection-endpoint-handler"; import CollectionEndpointOperation from "#services/collection-endpoint/collection-endpoint-operation"; -import { createPath } from "#services/config/api-path"; import BlResponseHandler from "#services/response/bl-response.handler"; import { BlStorageData } from "#services/storage/bl-storage"; import { BlApiRequest } from "#services/types/bl-api-request"; @@ -45,7 +44,7 @@ function createRequestHandler( } function create(endpoint: BlEndpoint, collection: BlCollection) { - const collectionUri = createPath(collection.storage.path); + const collectionUri = `/${collection.storage.path}`; let onRequest: (blApiRequest: BlApiRequest) => Promise<BlStorageData>; let checkDocumentPermission = false; let uri = collectionUri; diff --git a/backend/app/services/config/api-path.ts b/backend/app/services/config/api-path.ts index 555bf9e..83f3a6a 100644 --- a/backend/app/services/config/api-path.ts +++ b/backend/app/services/config/api-path.ts @@ -3,10 +3,6 @@ import { IncomingHttpHeaders } from "node:http"; import { APP_CONFIG } from "#services/config/application-config"; import env from "#start/env"; -export function createPath(customPath: string): string { - return env.get("SERVER_PATH") + customPath; -} - function retrieveBasePath(href: string) { const url = new URL(href); const host = url.host; diff --git a/backend/config/ally.ts b/backend/config/ally.ts index 9c62c0e..603fe68 100644 --- a/backend/config/ally.ts +++ b/backend/config/ally.ts @@ -1,18 +1,17 @@ import { defineConfig, services } from "@adonisjs/ally"; -import { createPath } from "#services/config/api-path"; import env from "#start/env"; const allyConfig = defineConfig({ facebook: services.facebook({ clientId: env.get("FACEBOOK_CLIENT_ID"), clientSecret: env.get("FACEBOOK_SECRET"), - callbackUrl: env.get("BL_API_URI") + createPath("auth/facebook/callback"), + callbackUrl: env.get("BL_API_URI") + "/auth/facebook/callback", }), google: services.google({ clientId: env.get("GOOGLE_CLIENT_ID"), clientSecret: env.get("GOOGLE_SECRET"), - callbackUrl: env.get("BL_API_URI") + createPath("auth/google/callback"), + callbackUrl: env.get("BL_API_URI") + "/auth/google/callback", }), }); export default allyConfig; diff --git a/backend/start/env.ts b/backend/start/env.ts index 222f03c..fa58bec 100644 --- a/backend/start/env.ts +++ b/backend/start/env.ts @@ -14,7 +14,6 @@ import { Env } from "@adonisjs/core/env"; export default await Env.create(new URL("../", import.meta.url), { APP_KEY: Env.schema.string(), PORT: Env.schema.number(), - SERVER_PATH: Env.schema.string(), API_ENV: Env.schema.enum(["dev", "test", "staging", "production"]), // fixme: Currently used for Winston, consider updating when using Adonis Logger LOG_LEVEL: Env.schema.enum([