Merge pull request #332 from Monadical-SAS/sara/move-config

Move config
This commit is contained in:
Sara
2023-12-14 16:36:38 +01:00
committed by GitHub
4 changed files with 19 additions and 16 deletions

View File

@@ -75,9 +75,11 @@ FIEF_URL=https://auth.reflector-ui.dev/reflector-local
FIEF_CLIENT_ID=s03<omitted> FIEF_CLIENT_ID=s03<omitted>
FIEF_CLIENT_SECRET=<omitted> FIEF_CLIENT_SECRET=<omitted>
EDGE_CONFIG=<omitted> EDGE_CONFIG=<omitted> (optional)
``` ```
Then copy config-template.ts to a new file called config.ts, this is where you will configure the features or your local project.
### Run the Application ### Run the Application
To run the application in development mode, run: To run the application in development mode, run:

2
www/.gitignore vendored
View File

@@ -39,3 +39,5 @@ next-env.d.ts
# Sentry Auth Token # Sentry Auth Token
.sentryclirc .sentryclirc
config.ts

View File

@@ -1,19 +1,6 @@
import { get } from "@vercel/edge-config"; import { get } from "@vercel/edge-config";
import { isDevelopment } from "./utils"; import { isDevelopment } from "./utils";
const localConfig = {
features: {
requireLogin: false,
privacy: true,
browse: false,
sendToZulip: true,
},
api_url: "http://127.0.0.1:1250",
websocket_url: "ws://127.0.0.1:1250",
auth_callback_url: "http://localhost:3000/auth-callback",
zulip_streams: "https://d3ow1y42gqfmk.cloudfront.net",
};
type EdgeConfig = { type EdgeConfig = {
[domainWithDash: string]: { [domainWithDash: string]: {
features: { features: {
@@ -43,8 +30,8 @@ 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(domain: string) { export async function getConfig(domain: string) {
if (isDevelopment()) { if (process.env.NEXT_PUBLIC_ENV === "development") {
return localConfig; return require("../../config").localConfig;
} }
let config = await get(edgeDomainToKey(domain)); let config = await get(edgeDomainToKey(domain));

12
www/config-template.ts Normal file
View File

@@ -0,0 +1,12 @@
export const localConfig = {
features: {
requireLogin: true,
privacy: true,
browse: true,
sendToZulip: true,
},
api_url: "http://127.0.0.1:1250",
websocket_url: "ws://127.0.0.1:1250",
auth_callback_url: "http://localhost:3000/auth-callback",
zulip_streams: "", // Find the value on zulip
};