mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-27 15:53:49 +00:00
chore: cleanup deps
This commit is contained in:
parent
a6719e8864
commit
fe1ba459bd
58
package.json
58
package.json
@ -16,61 +16,13 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@changesets/cli": "^2.27.5",
|
|
||||||
"@commitlint/cli": "^19.3.0",
|
|
||||||
"@commitlint/config-conventional": "^19.2.2",
|
|
||||||
"@swc/cli": "^0.1.62",
|
|
||||||
"@swc/core": "^1.3.95",
|
|
||||||
"@types/bootstrap": "^5.2.8",
|
|
||||||
"@types/copyfiles": "^2.4.4",
|
|
||||||
"@types/cors": "^2.8.17",
|
|
||||||
"@types/d3-scale": "^4.0.6",
|
|
||||||
"@types/d3-scale-chromatic": "^3.0.1",
|
|
||||||
"@types/decompress": "^4.2.6",
|
|
||||||
"@types/dockerode": "^3.3.21",
|
|
||||||
"@types/eventsource": "^1.1.14",
|
|
||||||
"@types/express": "^4.17.21",
|
|
||||||
"@types/express-sslify": "^1.2.5",
|
|
||||||
"@types/http-proxy": "^1.17.13",
|
|
||||||
"@types/inquirer": "^9.0.7",
|
|
||||||
"@types/js-cookie": "^3.0.5",
|
|
||||||
"@types/js-yaml": "^4.0.9",
|
|
||||||
"@types/json-stringify-safe": "^5.0.2",
|
|
||||||
"@types/marked": "^4.3.2",
|
|
||||||
"@types/memorystream": "^0.3.3",
|
|
||||||
"@types/ncp": "^2.0.8",
|
|
||||||
"@types/node": "^20.8.10",
|
|
||||||
"@types/node-os-utils": "^1.3.4",
|
|
||||||
"@types/semver": "^7.5.4",
|
|
||||||
"@types/tmp": "^0.2.5",
|
|
||||||
"@types/unzipper": "^0.10.8",
|
|
||||||
"@types/vhost": "^3.0.9",
|
|
||||||
"@types/winston-syslog": "^2.4.3",
|
|
||||||
"chokidar-cli": "^3.0.0",
|
|
||||||
"concurrently": "^8.2.2",
|
|
||||||
"copyfiles": "^2.4.1",
|
|
||||||
"date-fns": "^2.30.0",
|
|
||||||
"dotenv-cli": "^7.3.0",
|
|
||||||
"express": "^4.18.2",
|
|
||||||
"gobot": "1.0.0-alpha.40",
|
|
||||||
"http-proxy-middleware": "^2.0.6",
|
|
||||||
"husky": "^9.0.11",
|
|
||||||
"inquirer": "^9.2.15",
|
|
||||||
"ip-cidr": "^3.1.0",
|
|
||||||
"js-yaml": "^4.1.0",
|
|
||||||
"ncp": "^2.0.0",
|
|
||||||
"nodemon": "^3.0.3",
|
|
||||||
"ora": "^7.0.1",
|
|
||||||
"postinstall-postinstall": "^2.1.0",
|
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"prettier-plugin-jsdoc": "^1.3.0",
|
"prettier-plugin-jsdoc": "^1.3.0",
|
||||||
"prettier-plugin-organize-imports": "^3.2.3",
|
"prettier-plugin-organize-imports": "^4.1.0",
|
||||||
"prettier-plugin-svelte": "^3.0.3",
|
"prettier-plugin-svelte": "^3.2.8",
|
||||||
"svelte": "^4.2.2",
|
"tslib": "^2.8.1",
|
||||||
"tslib": "^2.6.2",
|
"tsx": "^4.19.2",
|
||||||
"tsx": "^3.14.0",
|
"typescript": "^5.6.3"
|
||||||
"type-fest": "^4.6.0",
|
|
||||||
"typescript": "^5.2.2"
|
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
|
|||||||
@ -30,11 +30,9 @@
|
|||||||
"@types/d3-scale-chromatic": "^3.0.3",
|
"@types/d3-scale-chromatic": "^3.0.3",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"boolean": "^3.2.0",
|
|
||||||
"d3-scale": "^4.0.2",
|
"d3-scale": "^4.0.2",
|
||||||
"d3-scale-chromatic": "^3.1.0",
|
"d3-scale-chromatic": "^3.1.0",
|
||||||
"daisyui": "^4.12.12",
|
"daisyui": "^4.12.12",
|
||||||
"date-fns": "^4.1.0",
|
|
||||||
"highlight.js": "^11.10.0",
|
"highlight.js": "^11.10.0",
|
||||||
"just-camel-case": "^6.2.0",
|
"just-camel-case": "^6.2.0",
|
||||||
"mdsvex": "^0.12.3",
|
"mdsvex": "^0.12.3",
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import { boolean } from 'boolean'
|
import {
|
||||||
import { type InstanceFields, SubscriptionType } from 'pockethost/common'
|
type InstanceFields,
|
||||||
|
parseBoolean,
|
||||||
|
SubscriptionType,
|
||||||
|
} from 'pockethost/common'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These environment variables default to pointing to the production build so
|
* These environment variables default to pointing to the production build so
|
||||||
@ -24,7 +27,7 @@ export const PUBLIC_MOTHERSHIP_URL =
|
|||||||
`https://pockethost-central.${PUBLIC_APEX_DOMAIN}`
|
`https://pockethost-central.${PUBLIC_APEX_DOMAIN}`
|
||||||
|
|
||||||
// Whether we are in debugging mode - default TRUE
|
// Whether we are in debugging mode - default TRUE
|
||||||
export const PUBLIC_DEBUG = boolean(import.meta.env.PUBLIC_DEBUG || 'true')
|
export const PUBLIC_DEBUG = parseBoolean(import.meta.env.PUBLIC_DEBUG || 'true')
|
||||||
|
|
||||||
const mkPath = (...paths: string[]) => {
|
const mkPath = (...paths: string[]) => {
|
||||||
return paths.filter((v) => !!v).join('/')
|
return paths.filter((v) => !!v).join('/')
|
||||||
|
|||||||
@ -18,88 +18,59 @@
|
|||||||
"start": "./src/cli/index.ts"
|
"start": "./src/cli/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@s-libs/micro-dash": "^16.1.0",
|
"@s-libs/micro-dash": "^18.0.0",
|
||||||
"@types/node-os-utils": "^1.3.4",
|
|
||||||
"@types/winston-syslog": "^2.4.3",
|
|
||||||
"ajv": "^8.12.0",
|
"ajv": "^8.12.0",
|
||||||
"boolean": "^3.2.0",
|
"better-sqlite3": "^11.5.0",
|
||||||
"bottleneck": "^2.19.5",
|
"bottleneck": "^2.19.5",
|
||||||
"chalk": "^5.3.0",
|
"commander": "^12.1.0",
|
||||||
"commander": "^11.1.0",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"decompress": "^4.2.1",
|
|
||||||
"decompress-unzip": "https://github.com/pockethost/decompress-unzip.git#6ef397b9a2df11d39c7b26ce779e123833844751",
|
|
||||||
"devcert": "^1.2.2",
|
"devcert": "^1.2.2",
|
||||||
"dockerode": "^3.3.5",
|
"dockerode": "^4.0.2",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"env-paths": "^3.0.0",
|
"env-paths": "^3.0.0",
|
||||||
"env-var": "^7.5.0",
|
"env-var": "^7.5.0",
|
||||||
"event-source-polyfill": "^1.0.31",
|
|
||||||
"eventsource": "^2.0.2",
|
"eventsource": "^2.0.2",
|
||||||
"exit-hook": "^4.0.0",
|
"exit-hook": "^4.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-async-errors": "^3.1.1",
|
"express-async-errors": "^3.1.1",
|
||||||
"express-sslify": "^1.2.0",
|
"express-sslify": "^1.2.0",
|
||||||
"ftp-srv": "github:pockethost/ftp-srv#0fc708bae0d5d7a55ce948767f082d6fcfb2af59",
|
"ftp-srv": "github:pockethost/ftp-srv#0fc708bae0d5d7a55ce948767f082d6fcfb2af59",
|
||||||
"glob": "^10.3.10",
|
"glob": "^11.0.0",
|
||||||
"gobot": "1.0.0-alpha.41",
|
"gobot": "1.0.0-alpha.41",
|
||||||
"gobot-pocketbase": "0.22.8-alpha.22",
|
|
||||||
"http-proxy": "^1.18.1",
|
"http-proxy": "^1.18.1",
|
||||||
"http-proxy-middleware": "^2.0.6",
|
"http-proxy-middleware": "^3.0.3",
|
||||||
"ip-cidr": "^3.1.0",
|
"ip-cidr": "^4.0.2",
|
||||||
"json-stringify-safe": "^5.0.1",
|
"json-stringify-safe": "^5.0.1",
|
||||||
"knex": "^2.5.1",
|
|
||||||
"memorystream": "^0.3.1",
|
"memorystream": "^0.3.1",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"node-os-utils": "^1.3.7",
|
"node-os-utils": "^1.3.7",
|
||||||
"pocketbase": "^0.21.3",
|
"pocketbase": "^0.21.3",
|
||||||
"rimraf": "^5.0.5",
|
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.5.4",
|
||||||
"sqlite3": "^5.1.6",
|
|
||||||
"syslog-parse": "^2.0.0",
|
|
||||||
"tail": "^2.2.6",
|
"tail": "^2.2.6",
|
||||||
"tmp": "^0.2.1",
|
"type-fest": "^4.6.0",
|
||||||
"url-pattern": "^1.0.3",
|
|
||||||
"vhost": "^3.0.2",
|
"vhost": "^3.0.2",
|
||||||
"winston": "^3.11.0",
|
"winston": "^3.17.0",
|
||||||
"winston-syslog": "^2.7.0",
|
"winston-transport": "^4.9.0"
|
||||||
"winston-transport": "^4.7.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/better-sqlite3": "^7.6.11",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/d3-scale": "^4.0.6",
|
"@types/d3-scale": "^4.0.6",
|
||||||
"@types/d3-scale-chromatic": "^3.0.1",
|
"@types/d3-scale-chromatic": "^3.0.1",
|
||||||
"@types/decompress": "^4.2.6",
|
"@types/decompress": "^4.2.6",
|
||||||
"@types/dockerode": "^3.3.21",
|
"@types/dockerode": "^3.3.31",
|
||||||
"@types/eventsource": "^1.1.14",
|
"@types/eventsource": "^1.1.14",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/express-sslify": "^1.2.5",
|
"@types/express-sslify": "^1.2.5",
|
||||||
"@types/http-proxy": "^1.17.13",
|
"@types/http-proxy": "^1.17.13",
|
||||||
"@types/inquirer": "^9.0.7",
|
|
||||||
"@types/js-cookie": "^3.0.5",
|
"@types/js-cookie": "^3.0.5",
|
||||||
"@types/js-yaml": "^4.0.9",
|
|
||||||
"@types/json-stringify-safe": "^5.0.2",
|
"@types/json-stringify-safe": "^5.0.2",
|
||||||
"@types/memorystream": "^0.3.3",
|
"@types/memorystream": "^0.3.3",
|
||||||
"@types/ncp": "^2.0.8",
|
|
||||||
"@types/node": "^20.8.10",
|
"@types/node": "^20.8.10",
|
||||||
|
"@types/node-os-utils": "^1.3.4",
|
||||||
"@types/semver": "^7.5.4",
|
"@types/semver": "^7.5.4",
|
||||||
"@types/tail": "^2.2.3",
|
"@types/tail": "^2.2.3",
|
||||||
"@types/tmp": "^0.2.5",
|
|
||||||
"@types/unzipper": "^0.10.8",
|
"@types/unzipper": "^0.10.8",
|
||||||
"@types/vhost": "^3.0.9",
|
"@types/vhost": "^3.0.9"
|
||||||
"chokidar-cli": "^3.0.0",
|
|
||||||
"concurrently": "^8.2.2",
|
|
||||||
"copyfiles": "^2.4.1",
|
|
||||||
"date-fns": "^2.30.0",
|
|
||||||
"express": "^4.18.2",
|
|
||||||
"http-proxy-middleware": "^2.0.6",
|
|
||||||
"inquirer": "^9.2.15",
|
|
||||||
"ip-cidr": "^3.1.0",
|
|
||||||
"js-yaml": "^4.1.0",
|
|
||||||
"ncp": "^2.0.0",
|
|
||||||
"nodemon": "^3.0.3",
|
|
||||||
"ora": "^7.0.1",
|
|
||||||
"postinstall-postinstall": "^2.1.0",
|
|
||||||
"type-fest": "^4.6.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Request } from 'express'
|
import { Handler, Request } from 'express'
|
||||||
import { createProxyMiddleware } from 'http-proxy-middleware'
|
import { createProxyMiddleware } from 'http-proxy-middleware'
|
||||||
import vhost from 'vhost'
|
import vhost from 'vhost'
|
||||||
import { logger } from '../../../../../common/Logger'
|
import { logger } from '../../../../../common/Logger'
|
||||||
@ -7,7 +7,7 @@ export function createVhostProxyMiddleware(
|
|||||||
host: string,
|
host: string,
|
||||||
target: string,
|
target: string,
|
||||||
ws = false,
|
ws = false,
|
||||||
) {
|
): Handler {
|
||||||
const { dbg } = logger()
|
const { dbg } = logger()
|
||||||
dbg(`Creating ${host}->${target}`)
|
dbg(`Creating ${host}->${target}`)
|
||||||
const handler = createProxyMiddleware({ target, ws, changeOrigin: ws })
|
const handler = createProxyMiddleware({ target, ws, changeOrigin: ws })
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import copyfiles from 'copyfiles'
|
|
||||||
import { GobotOptions } from 'gobot'
|
import { GobotOptions } from 'gobot'
|
||||||
import {
|
import {
|
||||||
DEBUG,
|
|
||||||
DISCORD_ALERT_CHANNEL_URL,
|
DISCORD_ALERT_CHANNEL_URL,
|
||||||
DISCORD_HEALTH_CHANNEL_URL,
|
DISCORD_HEALTH_CHANNEL_URL,
|
||||||
DISCORD_STREAM_CHANNEL_URL,
|
DISCORD_STREAM_CHANNEL_URL,
|
||||||
@ -22,27 +20,6 @@ import { GobotService } from '../../../../services/GobotService'
|
|||||||
|
|
||||||
export type MothershipConfig = {}
|
export type MothershipConfig = {}
|
||||||
|
|
||||||
const _copy = (src: string, dst: string) => {
|
|
||||||
const { error } = LoggerService().create(`copy`)
|
|
||||||
|
|
||||||
return new Promise<void>((resolve) => {
|
|
||||||
copyfiles(
|
|
||||||
[src, dst],
|
|
||||||
{
|
|
||||||
verbose: DEBUG(),
|
|
||||||
up: true,
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
if (err) {
|
|
||||||
error(err)
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
resolve()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function mothership(cfg: MothershipConfig) {
|
export async function mothership(cfg: MothershipConfig) {
|
||||||
const logger = LoggerService().create(`Mothership`)
|
const logger = LoggerService().create(`Mothership`)
|
||||||
const { dbg, error, info, warn } = logger
|
const { dbg, error, info, warn } = logger
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
import knex from 'knex'
|
|
||||||
import {
|
|
||||||
createCleanupManager,
|
|
||||||
LoggerService,
|
|
||||||
mkSingleton,
|
|
||||||
serialAsyncExecutionGuard,
|
|
||||||
SingletonBaseConfig,
|
|
||||||
} from '../../../../../core'
|
|
||||||
|
|
||||||
export type SqliteServiceApi = ReturnType<typeof knex>
|
|
||||||
export type SqliteServiceConfig = SingletonBaseConfig & {}
|
|
||||||
|
|
||||||
export type SqliteService = ReturnType<typeof SqliteService>
|
|
||||||
|
|
||||||
export const SqliteService = mkSingleton((config: SqliteServiceConfig) => {
|
|
||||||
const { dbg, trace } = LoggerService().create(`sqliteService`)
|
|
||||||
const connections: { [_: string]: SqliteServiceApi } = {}
|
|
||||||
|
|
||||||
const cm = createCleanupManager()
|
|
||||||
|
|
||||||
/*
|
|
||||||
This function
|
|
||||||
*/
|
|
||||||
const _unsafe_getDatabase = async (
|
|
||||||
filename: string,
|
|
||||||
): Promise<SqliteServiceApi> => {
|
|
||||||
const _dbLogger = LoggerService().create(`SqliteService`)
|
|
||||||
_dbLogger.breadcrumb({ filename })
|
|
||||||
const { dbg, error, abort } = _dbLogger
|
|
||||||
|
|
||||||
trace(`Fetching database`, connections)
|
|
||||||
if (!connections[filename]) {
|
|
||||||
dbg(`Not yet opened`)
|
|
||||||
|
|
||||||
const api = await (async () => {
|
|
||||||
dbg(`Opening ${filename}`)
|
|
||||||
|
|
||||||
const db = knex({
|
|
||||||
client: 'sqlite3', // or 'better-sqlite3'
|
|
||||||
connection: {
|
|
||||||
filename,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
cm.add(() => {
|
|
||||||
dbg(`Closing connection`)
|
|
||||||
db.destroy()
|
|
||||||
})
|
|
||||||
|
|
||||||
return db
|
|
||||||
})().catch(error)
|
|
||||||
if (!api) {
|
|
||||||
throw new Error(`Unable to connect to SQLite`)
|
|
||||||
}
|
|
||||||
connections[filename] = api
|
|
||||||
}
|
|
||||||
return connections[filename]!
|
|
||||||
}
|
|
||||||
const getDatabase = serialAsyncExecutionGuard(
|
|
||||||
_unsafe_getDatabase,
|
|
||||||
(fileName) => fileName,
|
|
||||||
)
|
|
||||||
|
|
||||||
const shutdown = async () => {
|
|
||||||
dbg(`Shutting down sqlite service`)
|
|
||||||
await cm.shutdown()
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
getDatabase,
|
|
||||||
shutdown,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import { map } from '@s-libs/micro-dash'
|
import { map } from '@s-libs/micro-dash'
|
||||||
|
import Database from 'better-sqlite3'
|
||||||
import Bottleneck from 'bottleneck'
|
import Bottleneck from 'bottleneck'
|
||||||
import { Command, InvalidArgumentError } from 'commander'
|
import { Command, InvalidArgumentError } from 'commander'
|
||||||
import { PocketBase, UserFields, logger } from '../../../common'
|
import { PocketBase, UserFields, logger } from '../../../common'
|
||||||
@ -9,7 +10,6 @@ import {
|
|||||||
MOTHERSHIP_URL,
|
MOTHERSHIP_URL,
|
||||||
TEST_EMAIL,
|
TEST_EMAIL,
|
||||||
} from '../../../core'
|
} from '../../../core'
|
||||||
import { SqliteService } from './SqliteService'
|
|
||||||
|
|
||||||
const TBL_SENT_MESSAGES = `sent_messages`
|
const TBL_SENT_MESSAGES = `sent_messages`
|
||||||
|
|
||||||
@ -46,9 +46,7 @@ export const SendMailCommand = () =>
|
|||||||
|
|
||||||
dbg({ messageId, confirm, limit })
|
dbg({ messageId, confirm, limit })
|
||||||
|
|
||||||
const { getDatabase } = SqliteService({})
|
const db = new Database(MOTHERSHIP_DATA_DB())
|
||||||
|
|
||||||
const db = await getDatabase(MOTHERSHIP_DATA_DB())
|
|
||||||
|
|
||||||
info(MOTHERSHIP_URL())
|
info(MOTHERSHIP_URL())
|
||||||
|
|
||||||
@ -69,9 +67,8 @@ export const SendMailCommand = () =>
|
|||||||
}
|
}
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
map(campaign.vars, async (sql, k) => {
|
map(campaign.vars, async (sql, k) => {
|
||||||
const res = await db.raw(sql)
|
const result = db.prepare(sql).get() as { value: string }
|
||||||
const [{ value }] = res
|
vars[k.toLocaleLowerCase()] = result.value
|
||||||
vars[k.toLocaleLowerCase()] = value
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -85,7 +82,7 @@ export const SendMailCommand = () =>
|
|||||||
WHERE sm.id IS NULL;
|
WHERE sm.id IS NULL;
|
||||||
`
|
`
|
||||||
dbg(sql)
|
dbg(sql)
|
||||||
const users = (await db.raw<UserFields[]>(sql)).slice(0, limit)
|
const users = db.prepare(sql).all().slice(0, limit) as UserFields[]
|
||||||
|
|
||||||
// dbg({ users })
|
// dbg({ users })
|
||||||
|
|
||||||
@ -120,5 +117,5 @@ export const SendMailCommand = () =>
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
SqliteService().shutdown()
|
db.close()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -17,9 +17,7 @@ export const ServeCommand = () => {
|
|||||||
const { dbg, error, info, warn } = logger()
|
const { dbg, error, info, warn } = logger()
|
||||||
info(`Starting`)
|
info(`Starting`)
|
||||||
|
|
||||||
await mothership(options)
|
await Promise.all([mothership(options), daemon(), firewall()])
|
||||||
await daemon()
|
|
||||||
await firewall()
|
|
||||||
|
|
||||||
await neverendingPromise()
|
await neverendingPromise()
|
||||||
})
|
})
|
||||||
|
|||||||
5
packages/pockethost/src/common/boolean.ts
Normal file
5
packages/pockethost/src/common/boolean.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export const parseBoolean = (value: string | boolean): boolean => {
|
||||||
|
if (typeof value === 'boolean') return value
|
||||||
|
const normalized = value.toLowerCase().trim()
|
||||||
|
return ['true', '1', 'yes', 'on'].includes(normalized)
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
export * from './assert'
|
export * from './assert'
|
||||||
|
export * from './boolean'
|
||||||
export * from './CleanupManager'
|
export * from './CleanupManager'
|
||||||
export * from './ConsoleLogger'
|
export * from './ConsoleLogger'
|
||||||
export * from './events'
|
export * from './events'
|
||||||
|
|||||||
@ -71,7 +71,7 @@ export const _INSTANCE_APP_ROOT = (...paths: string[]) =>
|
|||||||
|
|
||||||
const TLS_PFX = `tls`
|
const TLS_PFX = `tls`
|
||||||
|
|
||||||
if (_IS_DEV) {
|
const createDevCert = async () => {
|
||||||
mkdirSync(_SSL_HOME, { recursive: true })
|
mkdirSync(_SSL_HOME, { recursive: true })
|
||||||
const { key, cert } = await devcert.certificateFor(_APEX_DOMAIN, {})
|
const { key, cert } = await devcert.certificateFor(_APEX_DOMAIN, {})
|
||||||
writeFileSync(join(_SSL_HOME, `${TLS_PFX}.key`), key)
|
writeFileSync(join(_SSL_HOME, `${TLS_PFX}.key`), key)
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { boolean as castToBoolean } from 'boolean'
|
|
||||||
import { existsSync, mkdirSync } from 'fs'
|
import { existsSync, mkdirSync } from 'fs'
|
||||||
import { mkSingleton } from '../common'
|
import { mkSingleton, parseBoolean } from '../common'
|
||||||
|
|
||||||
export type SettingsCaster<TValue, TConfig = {}> = {
|
export type SettingsCaster<TValue, TConfig = {}> = {
|
||||||
stringToType: (value: string, config?: Partial<TConfig>) => TValue
|
stringToType: (value: string, config?: Partial<TConfig>) => TValue
|
||||||
@ -53,7 +52,7 @@ const mkMaker =
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const mkBoolean = mkMaker<boolean>({
|
export const mkBoolean = mkMaker<boolean>({
|
||||||
stringToType: (v) => castToBoolean(v),
|
stringToType: (v) => parseBoolean(v),
|
||||||
typeToString: (v) => `${v}`,
|
typeToString: (v) => `${v}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
import * as winston from 'winston'
|
|
||||||
import 'winston-syslog'
|
|
||||||
import { SYSLOGD_PORT } from '..'
|
|
||||||
import { LoggerService } from '../common'
|
|
||||||
|
|
||||||
export function SyslogLogger(instanceId: string, target: string) {
|
|
||||||
// @ts-ignore
|
|
||||||
const syslogTransport = new winston.transports.Syslog({
|
|
||||||
host: `localhost`,
|
|
||||||
port: SYSLOGD_PORT(),
|
|
||||||
app_name: instanceId,
|
|
||||||
}) as winston.transport
|
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
|
||||||
format: winston.format.printf((info) => {
|
|
||||||
return info.message
|
|
||||||
}),
|
|
||||||
transports: [syslogTransport],
|
|
||||||
})
|
|
||||||
|
|
||||||
const { error, warn } = LoggerService()
|
|
||||||
.create('SyslogLogger')
|
|
||||||
.breadcrumb({ instanceId, target })
|
|
||||||
|
|
||||||
const api = {
|
|
||||||
info: (msg: string) => {
|
|
||||||
logger.info(msg)
|
|
||||||
},
|
|
||||||
error: (msg: string) => {
|
|
||||||
logger.error(msg)
|
|
||||||
},
|
|
||||||
shutdown: () => {
|
|
||||||
return new Promise<void>((resolve) => {
|
|
||||||
logger.on('close', resolve)
|
|
||||||
logger.close()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return api
|
|
||||||
}
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { boolean } from 'boolean'
|
|
||||||
import { existsSync } from 'fs'
|
import { existsSync } from 'fs'
|
||||||
import { env as _env } from 'process'
|
import { env as _env } from 'process'
|
||||||
|
import { parseBoolean } from '../common'
|
||||||
|
|
||||||
export const env = (name: string, _default = '') => {
|
export const env = (name: string, _default = '') => {
|
||||||
const v = _env[name]
|
const v = _env[name]
|
||||||
@ -12,7 +12,7 @@ export const envi = (name: string, _default: number) =>
|
|||||||
parseInt(env(name, _default.toString()))
|
parseInt(env(name, _default.toString()))
|
||||||
|
|
||||||
export const envb = (name: string, _default: boolean) =>
|
export const envb = (name: string, _default: boolean) =>
|
||||||
boolean(env(name, _default.toString()))
|
parseBoolean(env(name, _default.toString()))
|
||||||
|
|
||||||
export const envfile = (name: string, _default = '') => {
|
export const envfile = (name: string, _default = '') => {
|
||||||
const v = env(name, _default)
|
const v = env(name, _default)
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
export * from '../constants'
|
export * from '../constants'
|
||||||
export * from './Settings'
|
|
||||||
export * from './SyslogLogger'
|
|
||||||
export * from './asyncExecutionGuard'
|
export * from './asyncExecutionGuard'
|
||||||
export * from './discordAlert'
|
export * from './discordAlert'
|
||||||
export * from './env'
|
export * from './env'
|
||||||
export * from './exit'
|
export * from './exit'
|
||||||
export * from './internal'
|
export * from './internal'
|
||||||
export * from './process'
|
export * from './process'
|
||||||
|
export * from './Settings'
|
||||||
export * from './smartFetch'
|
export * from './smartFetch'
|
||||||
export * from './tryFetch'
|
export * from './tryFetch'
|
||||||
|
|||||||
4329
pnpm-lock.yaml
generated
4329
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user