mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
chore(pockethost): refactor MOTHERSHIP_URL
This commit is contained in:
parent
89264631ea
commit
a1dfee22a7
@ -3,7 +3,7 @@ import { LoggerService } from '../../../../../common'
|
||||
import {
|
||||
MOTHERSHIP_ADMIN_PASSWORD,
|
||||
MOTHERSHIP_ADMIN_USERNAME,
|
||||
MOTHERSHIP_INTERNAL_URL,
|
||||
MOTHERSHIP_URL,
|
||||
discordAlert,
|
||||
tryFetch,
|
||||
} from '../../../../../core'
|
||||
@ -24,19 +24,19 @@ export async function daemon() {
|
||||
await PortService({})
|
||||
await PocketbaseService({})
|
||||
|
||||
await tryFetch(`${MOTHERSHIP_INTERNAL_URL(`/api/health`)}`, {})
|
||||
await tryFetch(`${MOTHERSHIP_URL(`/api/health`)}`, {})
|
||||
|
||||
info(`Serving`)
|
||||
|
||||
/** Launch services */
|
||||
await MothershipAdminClientService({
|
||||
url: MOTHERSHIP_INTERNAL_URL(),
|
||||
url: MOTHERSHIP_URL(),
|
||||
username: MOTHERSHIP_ADMIN_USERNAME(),
|
||||
password: MOTHERSHIP_ADMIN_PASSWORD(),
|
||||
})
|
||||
|
||||
await proxyService({
|
||||
coreInternalUrl: MOTHERSHIP_INTERNAL_URL(),
|
||||
coreInternalUrl: MOTHERSHIP_URL(),
|
||||
})
|
||||
await realtimeLog({})
|
||||
await instanceService({
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
mkSingleton,
|
||||
} from '../../../../../common'
|
||||
import {
|
||||
MOTHERSHIP_INTERNAL_URL,
|
||||
MOTHERSHIP_URL,
|
||||
PH_FTP_PASV_IP,
|
||||
PH_FTP_PASV_PORT_MAX,
|
||||
PH_FTP_PASV_PORT_MIN,
|
||||
@ -67,7 +67,7 @@ export function virtualFolderGuard(
|
||||
export const ftpService = mkSingleton((config: Partial<FtpConfig> = {}) => {
|
||||
const { mothershipUrl } = mergeConfig(
|
||||
{
|
||||
mothershipUrl: MOTHERSHIP_INTERNAL_URL(),
|
||||
mothershipUrl: MOTHERSHIP_URL(),
|
||||
},
|
||||
config,
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { LoggerService } from '../../../../../common'
|
||||
import { MOTHERSHIP_INTERNAL_URL, tryFetch } from '../../../../../core'
|
||||
import { MOTHERSHIP_URL, tryFetch } from '../../../../../core'
|
||||
import { ftpService } from '../FtpService'
|
||||
|
||||
export async function ftp() {
|
||||
@ -7,9 +7,9 @@ export async function ftp() {
|
||||
const { dbg, error, info, warn } = logger
|
||||
info(`Starting`)
|
||||
|
||||
await tryFetch(`${MOTHERSHIP_INTERNAL_URL(`/api/health`)}`, {})
|
||||
await tryFetch(`${MOTHERSHIP_URL(`/api/health`)}`, {})
|
||||
|
||||
await ftpService({
|
||||
mothershipUrl: MOTHERSHIP_INTERNAL_URL(),
|
||||
mothershipUrl: MOTHERSHIP_URL(),
|
||||
})
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import {
|
||||
MOTHERSHIP_ADMIN_PASSWORD,
|
||||
MOTHERSHIP_ADMIN_USERNAME,
|
||||
MOTHERSHIP_DATA_DB,
|
||||
MOTHERSHIP_INTERNAL_URL,
|
||||
MOTHERSHIP_URL,
|
||||
TEST_EMAIL,
|
||||
} from '../../../core'
|
||||
@ -51,7 +50,7 @@ export const sendMail = async () => {
|
||||
|
||||
info(MOTHERSHIP_URL())
|
||||
|
||||
const client = new PocketBase(MOTHERSHIP_INTERNAL_URL())
|
||||
const client = new PocketBase(MOTHERSHIP_URL())
|
||||
await client.admins.authWithPassword(
|
||||
MOTHERSHIP_ADMIN_USERNAME(),
|
||||
MOTHERSHIP_ADMIN_PASSWORD(),
|
||||
|
@ -98,11 +98,7 @@ export const SETTINGS = {
|
||||
DAEMON_PORT: mkNumber(3000),
|
||||
DAEMON_PB_IDLE_TTL: mkNumber(1000 * 60 * 5), // 5 minutes
|
||||
|
||||
MOTHERSHIP_URL: mkString(
|
||||
`${_HTTP_PROTOCOL}//${_MOTHERSHIP_NAME}.${_APEX_DOMAIN}`,
|
||||
),
|
||||
MOTHERSHIP_NAME: mkString(_MOTHERSHIP_NAME),
|
||||
MOTHERSHIP_INTERNAL_HOST: mkString(`localhost`),
|
||||
MOTHERSHIP_ADMIN_USERNAME: mkString(),
|
||||
MOTHERSHIP_ADMIN_PASSWORD: mkString(),
|
||||
PH_MOTHERSHIP_APP_ROOT: mkString(_MOTHERSHIP_APP_ROOT()),
|
||||
@ -224,9 +220,15 @@ export const IPCIDR_LIST = () => settings().IPCIDR_LIST
|
||||
export const DAEMON_PORT = () => settings().DAEMON_PORT
|
||||
export const DAEMON_PB_IDLE_TTL = () => settings().DAEMON_PB_IDLE_TTL
|
||||
|
||||
export const MOTHERSHIP_URL = () => settings().MOTHERSHIP_URL
|
||||
export const MOTHERSHIP_INTERNAL_HOST = () =>
|
||||
settings().MOTHERSHIP_INTERNAL_HOST
|
||||
export const MOTHERSHIP_URL = (...path: string[]) =>
|
||||
join(
|
||||
env
|
||||
.get('MOTHERSHIP_URL')
|
||||
.default(`${HTTP_PROTOCOL()}://${MOTHERSHIP_NAME()}:${APEX_DOMAIN()}`)
|
||||
.asString(),
|
||||
...path,
|
||||
)
|
||||
|
||||
export const MOTHERSHIP_NAME = () => settings().MOTHERSHIP_NAME
|
||||
export const MOTHERSHIP_ADMIN_USERNAME = () =>
|
||||
settings().MOTHERSHIP_ADMIN_USERNAME
|
||||
@ -286,8 +288,6 @@ export const MOTHERSHIP_DATA_ROOT = (...paths: string[]) =>
|
||||
join(INSTANCE_DATA_ROOT(MOTHERSHIP_NAME()), ...paths)
|
||||
export const MOTHERSHIP_DATA_DB = () =>
|
||||
join(MOTHERSHIP_DATA_ROOT(), `pb_data`, `data.db`)
|
||||
export const MOTHERSHIP_INTERNAL_URL = (path = '') =>
|
||||
`http://${MOTHERSHIP_INTERNAL_HOST()}:${MOTHERSHIP_PORT()}${path}`
|
||||
export const INSTANCE_DATA_ROOT = (id: InstanceId) => join(DATA_ROOT(), id)
|
||||
export const INSTANCE_DATA_DB = (id: InstanceId) =>
|
||||
join(DATA_ROOT(), id, `pb_data`, `data.db`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user