-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from msisaifu/fix-banned-and-maintanance-auth
Fix banned and maintanance auth
- Loading branch information
Showing
5 changed files
with
68 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,40 @@ | ||
import { env } from '$env/dynamic/public' | ||
import { writable, type Writable } from "svelte/store" | ||
import { writable, type Writable } from 'svelte/store' | ||
|
||
export const isMaintenanceModeEnabled: Writable<boolean> = writable(false) | ||
export const isFeatureVideoResponsesEnabled: Writable<boolean> = writable(false) | ||
export const isFeatureGroupChatEnabled: Writable<boolean> = writable(false) | ||
export const isFeatureMintPageEnabled: Writable<boolean> = writable(false) | ||
export const isFeaturePremiumPageEnabled: Writable<boolean> = writable(false) | ||
|
||
async function createRemoteConfig({ flagKey, flagValue }: { flagKey: string, flagValue: string }) { | ||
return await fetch(`${env.PUBLIC_API_URL}/remote-config`, { | ||
method: 'PUT', | ||
body: JSON.stringify({ flagKey, flagValue }) | ||
}).then(response => response.json()) | ||
async function createRemoteConfig({ flagKey, flagValue }: { flagKey: string; flagValue: string }) { | ||
return await fetch(`${env.PUBLIC_API_URL}/remote-config`, { | ||
method: 'PUT', | ||
body: JSON.stringify({ flagKey, flagValue }) | ||
}).then((response) => response.json()) | ||
} | ||
|
||
async function getRemoteConfigs() { | ||
return await fetch(`${env.PUBLIC_API_URL}/remote-config`, { | ||
method: 'GET' | ||
}).then(async response => { | ||
const remoteConfigs = await response.json() | ||
remoteConfigs.map((config: { flagKey: string; flagValue: boolean }) => { | ||
if (config.flagKey === 'maintenance-mode') isMaintenanceModeEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-video-responses') isFeatureVideoResponsesEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-group-chat') isFeatureGroupChatEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-mint-page') isFeatureMintPageEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-premium-page') isFeaturePremiumPageEnabled.set(config.flagValue) | ||
}) | ||
}) | ||
return await fetch(`${env.PUBLIC_API_URL}/remote-configs`, { | ||
method: 'GET' | ||
}).then(async (response) => { | ||
const remoteConfigs = await response.json() | ||
remoteConfigs.map((config: { flagKey: string; flagValue: boolean }) => { | ||
if (config.flagKey === 'maintenance-mode') isMaintenanceModeEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-video-responses') | ||
isFeatureVideoResponsesEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-group-chat') isFeatureGroupChatEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-mint-page') isFeatureMintPageEnabled.set(config.flagValue) | ||
if (config.flagKey === 'feature-premium-page') | ||
isFeaturePremiumPageEnabled.set(config.flagValue) | ||
}) | ||
}) | ||
} | ||
|
||
async function getRemoteConfigByKey({ flagKey }: { flagKey: string }) { | ||
return await fetch(`${env.PUBLIC_API_URL}/remote-config?flagKey=${flagKey}`, { | ||
method: 'GET' | ||
}).then(response => response.json()) | ||
return await fetch(`${env.PUBLIC_API_URL}/remote-config?flagKey=${flagKey}`, { | ||
method: 'GET' | ||
}).then((response) => response.json()) | ||
} | ||
|
||
|
||
export { | ||
createRemoteConfig, | ||
getRemoteConfigs, | ||
getRemoteConfigByKey | ||
} | ||
export { createRemoteConfig, getRemoteConfigs, getRemoteConfigByKey } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import type { LayoutServerLoad } from './$types' | ||
|
||
export const load: LayoutServerLoad = async ({ locals }) => { | ||
console.log('locals', locals) | ||
return { | ||
user: locals.user | ||
user: locals.user, | ||
isBanned: locals.isBanned | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters