public-env-urls
This commit is contained in:
parent
d9b3d18e95
commit
5f939839fb
|
@ -21,10 +21,11 @@ import {
|
||||||
QueryLoad_ChatsArgs,
|
QueryLoad_ChatsArgs,
|
||||||
QueryLoad_Messages_ByArgs,
|
QueryLoad_Messages_ByArgs,
|
||||||
} from '../schema/chat.gen'
|
} from '../schema/chat.gen'
|
||||||
|
import { chatApiUrl } from '../../utils/config'
|
||||||
|
|
||||||
export const inboxClient = {
|
export const inboxClient = {
|
||||||
private: null,
|
private: null,
|
||||||
connect: (token: string) => (inboxClient.private = createGraphQLClient('chat', token)),
|
connect: (token: string) => (inboxClient.private = createGraphQLClient(chatApiUrl, token)),
|
||||||
|
|
||||||
loadChats: async (options: QueryLoad_ChatsArgs): Promise<Chat[]> => {
|
loadChats: async (options: QueryLoad_ChatsArgs): Promise<Chat[]> => {
|
||||||
const resp = await inboxClient.private.query(myChats, options).toPromise()
|
const resp = await inboxClient.private.query(myChats, options).toPromise()
|
||||||
|
|
|
@ -46,14 +46,15 @@ import reactionsLoadBy from '../query/core/reactions-load-by'
|
||||||
import topicBySlug from '../query/core/topic-by-slug'
|
import topicBySlug from '../query/core/topic-by-slug'
|
||||||
import topicsAll from '../query/core/topics-all'
|
import topicsAll from '../query/core/topics-all'
|
||||||
import topicsRandomQuery from '../query/core/topics-random'
|
import topicsRandomQuery from '../query/core/topics-random'
|
||||||
|
import { coreApiUrl } from "../../utils/config"
|
||||||
|
|
||||||
const publicGraphQLClient = createGraphQLClient('core')
|
const publicGraphQLClient = createGraphQLClient(coreApiUrl)
|
||||||
|
|
||||||
export const apiClient = {
|
export const apiClient = {
|
||||||
private: null,
|
private: null,
|
||||||
connect: (token: string) => {
|
connect: (token: string) => {
|
||||||
// NOTE: use it after token appears
|
// NOTE: use it after token appears
|
||||||
apiClient.private = createGraphQLClient('core', token)
|
apiClient.private = createGraphQLClient(coreApiUrl, token)
|
||||||
},
|
},
|
||||||
|
|
||||||
getRandomTopShouts: async (params: QueryLoad_Shouts_Random_TopArgs) => {
|
getRandomTopShouts: async (params: QueryLoad_Shouts_Random_TopArgs) => {
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
import { ClientOptions, Exchange, createClient, dedupExchange, fetchExchange } from '@urql/core'
|
import { ClientOptions, Exchange, createClient, fetchExchange } from '@urql/core'
|
||||||
import { devtoolsExchange } from '@urql/devtools'
|
import { devtoolsExchange } from '@urql/devtools'
|
||||||
|
|
||||||
import { isDev } from '../utils/config'
|
import { isDev } from '../utils/config'
|
||||||
|
|
||||||
const exchanges: Exchange[] = [dedupExchange, fetchExchange]
|
const exchanges: Exchange[] = [fetchExchange]
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
exchanges.unshift(devtoolsExchange)
|
exchanges.unshift(devtoolsExchange)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createGraphQLClient = (serviceName: string, token = '') => {
|
export const createGraphQLClient = (url: string, token = '') => {
|
||||||
const options: ClientOptions = {
|
const options: ClientOptions = {
|
||||||
url: `https://${serviceName}.discours.io`,
|
url,
|
||||||
maskTypename: true,
|
|
||||||
requestPolicy: 'cache-and-network',
|
requestPolicy: 'cache-and-network',
|
||||||
fetchOptions: () => (token ? { headers: { Authorization: token } } : {}),
|
fetchOptions: () => (token ? { headers: { Authorization: token } } : {}),
|
||||||
exchanges,
|
exchanges,
|
||||||
|
|
|
@ -8,3 +8,12 @@ export const SENTRY_DSN = import.meta.env.PUBLIC_SENTRY_DSN || ''
|
||||||
|
|
||||||
const defaultSearchUrl = 'https://search.discours.io'
|
const defaultSearchUrl = 'https://search.discours.io'
|
||||||
export const searchUrl = import.meta.env.PUBLIC_SEARCH_URL || defaultSearchUrl
|
export const searchUrl = import.meta.env.PUBLIC_SEARCH_URL || defaultSearchUrl
|
||||||
|
|
||||||
|
const defaultCoreUrl = 'https://core.discours.io'
|
||||||
|
export const coreApiUrl = import.meta.env.PUBLIC_CORE_API || defaultCoreUrl
|
||||||
|
|
||||||
|
const defaultChatUrl = 'https://chat.discours.io'
|
||||||
|
export const chatApiUrl = import.meta.env.PUBLIC_CHAT_API || defaultChatUrl
|
||||||
|
|
||||||
|
const defaultAuthUrl = 'https://auth.discours.io'
|
||||||
|
export const authApiUrl = import.meta.env.PUBLIC_AUTH_API || defaultAuthUrl
|
Loading…
Reference in New Issue
Block a user