Skip to content

Commit

Permalink
[config] Split config into client and server
Browse files Browse the repository at this point in the history
  • Loading branch information
54nd10 committed Sep 27, 2023
1 parent 86cc335 commit 91cf6a0
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NEXT_PUBLIC_HUBSPOT_API=
NEXT_PUBLIC_STRAPI_API_URL=
NEXT_PUBLIC_STRAPI_API_TOKEN=
STRAPI_API_URL=
STRAPI_API_TOKEN=
6 changes: 0 additions & 6 deletions config.ts

This file was deleted.

3 changes: 3 additions & 0 deletions configs/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {Fetcher} from '@/models/fetcher.model'
export const hubspotAPI = process.env.NEXT_PUBLIC_HUBSPOT_API || ''
export const hubspotFetcher = new Fetcher(hubspotAPI)
4 changes: 4 additions & 0 deletions configs/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {Fetcher} from '@/models/fetcher.model'
export const strapiAPI = process.env.STRAPI_API_URL || ''
export const strapiAPIToken = process.env.STRAPI_API_TOKEN || ''
export const strapiFetcher = new Fetcher(strapiAPI, {headers: {Authorization: `Bearer ${strapiAPIToken}`}})
2 changes: 1 addition & 1 deletion src/pages/about/team-members/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {PageProps} from '@/models/page.mode'
import {TeamMember} from '@/models/team-member'
import {getPageProps} from '@/utils/cms/endpoints'
import {pageRenderer} from '@/utils/cms/renderer/components'
import {strapiFetcher} from '../../../../config'
import {strapiFetcher} from '../../../../configs/server'

export default function BlogPage({components, openGraph}: PageProps) {
return pageRenderer(components, openGraph, 'CenteredLayout')
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blog/[article].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {GetStaticPropsContext} from 'next'
import {PageProps} from '@/models/page.mode'
import {getPageProps} from '@/utils/cms/endpoints'
import {pageRenderer} from '@/utils/cms/renderer/components'
import {strapiFetcher} from '../../../config'
import {strapiFetcher} from '../../../configs/server'

export default function BlogPage({components, openGraph}: PageProps) {
return pageRenderer(components, openGraph, 'CenteredLayout')
Expand Down
2 changes: 1 addition & 1 deletion src/pages/services/[service].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {PageProps} from '@/models/page.mode'
import {Service} from '@/models/service.model'
import {getPageProps} from '@/utils/cms/endpoints'
import {pageRenderer} from '@/utils/cms/renderer/components'
import {strapiFetcher} from '../../../config'
import {strapiFetcher} from '../../../configs/server'

export default function ServicePage({layout, components, openGraph}: PageProps) {
return pageRenderer(components, openGraph, layout, true)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/solutions/[solution].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {PageProps} from '@/models/page.mode'
import {Solution} from '@/models/solution.model'
import {getPageProps} from '@/utils/cms/endpoints'
import {pageRenderer} from '@/utils/cms/renderer/components'
import {strapiFetcher} from '../../../config'
import {strapiFetcher} from '../../../configs/server'

export default function SolutionPage({layout, components, openGraph}: PageProps) {
return pageRenderer(components, openGraph, layout, true)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cms/endpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {PageProps} from '@/models/page.mode'
import {componentBlueprints} from './renderer/components'
import {getPropsFromNestedObjects} from './renderer/parser'
import {snakeCaseObjectKeysToCamelCase} from '../toolbox'
import {strapiFetcher} from '../../../config'
import {strapiFetcher} from '../../../configs/server'

export async function getPageProps(path='/', lang='en'): Promise<PageProps|undefined> {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/hubspot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HsformsPayload} from '../models/contact-us-form-data.model'
import {hubspotFetcher} from '../../config'
import {hubspotFetcher} from '../../configs/client'

export const sendEmail = async(data: HsformsPayload) => {
return await hubspotFetcher.call({
Expand Down

0 comments on commit 91cf6a0

Please sign in to comment.