mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
github debug
This commit is contained in:
7
.github/workflows/test_next_server.yml
vendored
7
.github/workflows/test_next_server.yml
vendored
@@ -43,10 +43,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pnpm test
|
run: pnpm test
|
||||||
env:
|
|
||||||
NEXT_PUBLIC_IS_CI: true
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: pnpm build
|
|
||||||
env:
|
|
||||||
NEXT_PUBLIC_IS_CI: true
|
|
||||||
@@ -10,11 +10,8 @@ import {
|
|||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import createFetchClient from "openapi-react-query";
|
import createFetchClient from "openapi-react-query";
|
||||||
import { assertExistsAndNonEmptyString } from "./utils";
|
import { assertExistsAndNonEmptyString } from "./utils";
|
||||||
import { isCI } from "./next";
|
|
||||||
|
|
||||||
const API_URL = !isCI
|
const API_URL = assertExistsAndNonEmptyString(process.env.NEXT_PUBLIC_API_URL);
|
||||||
? assertExistsAndNonEmptyString(process.env.NEXT_PUBLIC_API_URL)
|
|
||||||
: "http://127.0.0.1:1250";
|
|
||||||
|
|
||||||
// Create the base openapi-fetch client with a default URL
|
// Create the base openapi-fetch client with a default URL
|
||||||
// The actual URL will be set via middleware in AuthProvider
|
// The actual URL will be set via middleware in AuthProvider
|
||||||
|
|||||||
@@ -17,16 +17,15 @@ import {
|
|||||||
deleteTokenCache,
|
deleteTokenCache,
|
||||||
} from "./redisTokenCache";
|
} from "./redisTokenCache";
|
||||||
import { tokenCacheRedis } from "./redisClient";
|
import { tokenCacheRedis } from "./redisClient";
|
||||||
import { isCI } from "./next";
|
|
||||||
|
|
||||||
// REFRESH_ACCESS_TOKEN_BEFORE because refresh is based on access token expiration (imagine we cache it 30 days)
|
// REFRESH_ACCESS_TOKEN_BEFORE because refresh is based on access token expiration (imagine we cache it 30 days)
|
||||||
const TOKEN_CACHE_TTL = REFRESH_ACCESS_TOKEN_BEFORE;
|
const TOKEN_CACHE_TTL = REFRESH_ACCESS_TOKEN_BEFORE;
|
||||||
|
|
||||||
const refreshLocks = new Map<string, Promise<JWTWithAccessToken>>();
|
const refreshLocks = new Map<string, Promise<JWTWithAccessToken>>();
|
||||||
|
|
||||||
const CLIENT_ID = !isCI
|
const CLIENT_ID = assertExistsAndNonEmptyString(
|
||||||
? assertExistsAndNonEmptyString(process.env.AUTHENTIK_CLIENT_ID)
|
process.env.AUTHENTIK_CLIENT_ID,
|
||||||
: "noop";
|
);
|
||||||
const CLIENT_SECRET = !isCI
|
const CLIENT_SECRET = !isCI
|
||||||
? assertExistsAndNonEmptyString(process.env.AUTHENTIK_CLIENT_SECRET)
|
? assertExistsAndNonEmptyString(process.env.AUTHENTIK_CLIENT_SECRET)
|
||||||
: "noop";
|
: "noop";
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { get } from "@vercel/edge-config";
|
import { get } from "@vercel/edge-config";
|
||||||
|
|
||||||
import { isBuildPhase, isCI } from "./next";
|
|
||||||
|
|
||||||
type EdgeConfig = {
|
type EdgeConfig = {
|
||||||
[domainWithDash: string]: {
|
[domainWithDash: string]: {
|
||||||
features: {
|
features: {
|
||||||
@@ -30,12 +28,6 @@ export function edgeDomainToKey(domain: string) {
|
|||||||
|
|
||||||
// get edge config server-side (prefer DomainContext when available), domain is the hostname
|
// get edge config server-side (prefer DomainContext when available), domain is the hostname
|
||||||
export async function getConfig() {
|
export async function getConfig() {
|
||||||
if (isCI) {
|
|
||||||
// "noop"
|
|
||||||
// TODO sometime later we may have proper config if we have bigger test suite that requires values from the config
|
|
||||||
return require("../../config-template").localConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.NEXT_PUBLIC_ENV === "development") {
|
if (process.env.NEXT_PUBLIC_ENV === "development") {
|
||||||
// helps to stop nextjs build from eager loading. don't inline it.
|
// helps to stop nextjs build from eager loading. don't inline it.
|
||||||
const configPath = "../../config";
|
const configPath = "../../config";
|
||||||
|
|||||||
@@ -1,7 +1,2 @@
|
|||||||
// next.js tries to run all the lib code during build phase; we don't always want it when e.g. we have connections initialized we don't want to have
|
// next.js tries to run all the lib code during build phase; we don't always want it when e.g. we have connections initialized we don't want to have
|
||||||
export const isBuildPhase = process.env.NEXT_PHASE?.includes("build");
|
export const isBuildPhase = process.env.NEXT_PHASE?.includes("build");
|
||||||
// useful for "next build" conditional executions
|
|
||||||
export const isCI =
|
|
||||||
process.env.CI === "true" ||
|
|
||||||
process.env.IS_CI === "true" ||
|
|
||||||
process.env.NEXT_PUBLIC_IS_CI === "true";
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import Redis from "ioredis";
|
import Redis from "ioredis";
|
||||||
import { isBuildPhase } from "./next";
|
|
||||||
|
|
||||||
export type RedisClient = Pick<Redis, "get" | "setex" | "del">;
|
export type RedisClient = Pick<Redis, "get" | "setex" | "del">;
|
||||||
|
|
||||||
@@ -27,20 +26,4 @@ const getRedisClient = (): RedisClient => {
|
|||||||
return redis;
|
return redis;
|
||||||
};
|
};
|
||||||
|
|
||||||
// next.js buildtime usage - we want to isolate next.js "build" time concepts here
|
export const tokenCacheRedis = getRedisClient();
|
||||||
const noopClient: RedisClient = (() => {
|
|
||||||
const noopSetex: Redis["setex"] = async () => {
|
|
||||||
return "OK" as const;
|
|
||||||
};
|
|
||||||
const noopDel: Redis["del"] = async () => {
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
get: async () => {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
setex: noopSetex,
|
|
||||||
del: noopDel,
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
export const tokenCacheRedis = isBuildPhase ? noopClient : getRedisClient();
|
|
||||||
|
|||||||
Reference in New Issue
Block a user