Skip to content

Commit

Permalink
chore: remove SERVER_PATH env
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Jan 28, 2025
1 parent a72dbcd commit 5b43227
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 18 deletions.
1 change: 0 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
APP_KEY=
PORT=
SERVER_PATH=
API_ENV=
LOG_LEVEL=
URI_WHITELIST=
Expand Down
1 change: 0 additions & 1 deletion backend/.env.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
APP_KEY=testtesttesttest
PORT=1337
SERVER_PATH=test
API_ENV=test
NODE_ENV=test
LOG_LEVEL=info
Expand Down
5 changes: 2 additions & 3 deletions backend/app/services/auth/local/local.auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions backend/app/services/auth/token/token.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -52,7 +51,6 @@ function generateEndpoint() {
);
}
});
return router;
}
const TokenEndpoint = {
generateEndpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions backend/app/services/config/api-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions backend/config/ally.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion backend/start/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit 5b43227

Please sign in to comment.