Skip to content

Commit 60c27f8

Browse files
committed
env: SELFHOSTED -> __SELFHOSTED
1 parent ff7ee1b commit 60c27f8

File tree

6 files changed

+30
-26
lines changed

6 files changed

+30
-26
lines changed

web/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ADD package.json ./
2323
FROM base as build
2424

2525
ENV NODE_ENV=production \
26-
SELFHOSTED=true
26+
__SELFHOSTED=true
2727

2828
RUN mkdir /app
2929
WORKDIR /app
@@ -37,7 +37,7 @@ RUN npm run build
3737
FROM base
3838

3939
ENV NODE_ENV=production \
40-
SELFHOSTED=true
40+
__SELFHOSTED=true
4141

4242
RUN mkdir /app
4343
WORKDIR /app

web/app/redux/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ const isStaging = isBrowser ? window.REMIX_ENV?.STAGING : process.env.STAGING
387387
const STAGING_API_URL = isBrowser ? window.REMIX_ENV?.API_STAGING_URL : process.env.API_STAGING_URL
388388
const PRODUCTION_API_URL = isBrowser ? window.REMIX_ENV?.API_URL : process.env.API_URL
389389

390-
export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.SELFHOSTED)
390+
export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.__SELFHOSTED)
391391

392392
export const API_URL = isSelfhosted || !isStaging ? PRODUCTION_API_URL : STAGING_API_URL
393393
export const AIAPI_URL = isBrowser ? window.REMIX_ENV?.AIAPI_URL : process.env.AIAPI_URL

web/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
190190
API_URL: process.env.API_URL,
191191
API_STAGING_URL: process.env.API_STAGING_URL,
192192
CDN_URL: process.env.CDN_URL,
193-
SELFHOSTED: process.env.SELFHOSTED,
193+
SELFHOSTED: process.env.__SELFHOSTED,
194194
STAGING: process.env.STAGING,
195195
PADDLE_CLIENT_SIDE_TOKEN: process.env.PADDLE_CLIENT_SIDE_TOKEN,
196196
}

web/app/routes/blog.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
import type { MetaFunction } from '@remix-run/node'
1+
import type { LoaderFunction, MetaFunction } from '@remix-run/node'
2+
import { redirect } from '@remix-run/node'
23
import { Link, useLoaderData } from '@remix-run/react'
3-
import { blogLoader } from 'utils/getPosts'
44
import _map from 'lodash/map'
5+
import _isEmpty from 'lodash/isEmpty'
56
import _filter from 'lodash/filter'
6-
import { TITLE_SUFFIX } from 'redux/constants'
7+
import { isSelfhosted, TITLE_SUFFIX } from 'redux/constants'
8+
import { getBlogPosts } from 'api'
79

8-
export const loader = blogLoader
10+
export const loader: LoaderFunction = async () => {
11+
if (isSelfhosted) {
12+
return redirect('/dashboard', 302)
13+
}
14+
15+
const data = await getBlogPosts()
16+
.then((data) => {
17+
return data
18+
})
19+
.catch((error) => {
20+
console.error(error)
21+
})
22+
23+
if (!data || _isEmpty(data)) {
24+
return null
25+
}
26+
27+
return data
28+
}
929

1030
export const meta: MetaFunction = () => {
1131
return [

web/app/utils/getPosts.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { marked, type Tokens } from 'marked'
22
import _isEmpty from 'lodash/isEmpty'
3-
import { LoaderFunction } from '@remix-run/node'
4-
import { getBlogPosts, getBlogPost, getBlogPostWithCategory } from 'api'
3+
import { getBlogPost, getBlogPostWithCategory } from 'api'
54

65
const renderer = new marked.Renderer()
76

@@ -66,19 +65,3 @@ export async function getPost(slug: string, category?: string): Promise<IPost |
6665
nickname: post.attributes?.nickname,
6766
}
6867
}
69-
70-
export const blogLoader: LoaderFunction = async () => {
71-
const data = await getBlogPosts()
72-
.then((data) => {
73-
return data
74-
})
75-
.catch((error) => {
76-
console.error(error)
77-
})
78-
79-
if (!data || _isEmpty(data)) {
80-
return null
81-
}
82-
83-
return data
84-
}

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"private": true,
33
"sideEffects": false,
4+
"license": "AGPL-3.0",
45
"scripts": {
56
"build": "remix build",
67
"dev": "remix dev",

0 commit comments

Comments
 (0)