mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
reading https files path from json
This commit is contained in:
parent
5ce0c2d71c
commit
088a3785cc
4 changed files with 37 additions and 3 deletions
|
@ -212,6 +212,7 @@ https://gitlab.com/MrFry/moodle-test-userscript
|
|||
.
|
||||
├── data/ server specific data files not tracked by git
|
||||
│ ├── admins.json forum admins. should be removed and should use admin column from user db
|
||||
│ ├── httpsfiles.json file including privkeyFile, fullchainFile, chainFile for https functionality
|
||||
│ ├── apiRootRedirectTo url where domain/api should redirect to
|
||||
│ ├── dbs/ directory for databases, and for their backups
|
||||
│ ├── domain the domain the server is hosted on. Used when `DOMAIN` env var is empty
|
||||
|
|
|
@ -180,3 +180,9 @@ export interface PeerInfo {
|
|||
note?: string
|
||||
http?: boolean
|
||||
}
|
||||
|
||||
export interface HttpsFiles {
|
||||
privkeyFile: string
|
||||
fullchainFile: string
|
||||
chainFile: string
|
||||
}
|
||||
|
|
|
@ -156,3 +156,13 @@ export const ModulesSchema: Schema = {
|
|||
'.*': ModuleSchema,
|
||||
},
|
||||
}
|
||||
|
||||
export const HttpsFilesSchema: Schema = {
|
||||
type: 'object',
|
||||
patternProperties: {
|
||||
privkeyFile: { type: 'string' },
|
||||
fullchainFile: { type: 'string' },
|
||||
chainFile: { type: 'string' },
|
||||
},
|
||||
required: ['privkeyFile', 'fullchainFile', 'chainFile'],
|
||||
}
|
||||
|
|
|
@ -6,9 +6,11 @@ import {
|
|||
ModulesSchema,
|
||||
SelfInfoSchema,
|
||||
LinksSchema,
|
||||
HttpsFilesSchema,
|
||||
} from '../types/typeSchemas'
|
||||
import logger from './logger'
|
||||
import utils from './utils'
|
||||
import { HttpsFiles } from '../types/basicTypes'
|
||||
|
||||
// FIXME: remove all file exists checks from everywhere for files that are created / checked here
|
||||
|
||||
|
@ -75,7 +77,22 @@ export const readAndValidateFile = <T>(file: FileDescriptor): T => {
|
|||
return parsedContent
|
||||
}
|
||||
|
||||
const filesFiles = {
|
||||
httpsFiles: {
|
||||
path: 'data/httpsfiles.json',
|
||||
description:
|
||||
'file paths for https functionality (privkey, chain files). Optional if https server is not used',
|
||||
schema: HttpsFilesSchema,
|
||||
warningIfMissing: true,
|
||||
},
|
||||
} as const satisfies Record<string, FileDescriptor>
|
||||
|
||||
const httpsFiles: HttpsFiles = utils.FileExists(filesFiles.httpsFiles.path)
|
||||
? utils.ReadJSON<HttpsFiles>(filesFiles.httpsFiles.path)
|
||||
: null
|
||||
|
||||
export const files = {
|
||||
...filesFiles,
|
||||
// --------------------------------------------------------------------------------
|
||||
// server / modules files
|
||||
// --------------------------------------------------------------------------------
|
||||
|
@ -155,15 +172,15 @@ export const files = {
|
|||
// https files
|
||||
// --------------------------------------------------------------------------------
|
||||
privkeyFile: {
|
||||
path: '/etc/letsencrypt/live/frylabs.net/privkey.pem',
|
||||
path: httpsFiles?.privkeyFile,
|
||||
description: 'private key file for https',
|
||||
},
|
||||
fullchainFile: {
|
||||
path: '/etc/letsencrypt/live/frylabs.net/fullchain.pem',
|
||||
path: httpsFiles?.fullchainFile,
|
||||
description: 'full chain key file for https',
|
||||
},
|
||||
chainFile: {
|
||||
path: '/etc/letsencrypt/live/frylabs.net/chain.pem',
|
||||
path: httpsFiles?.chainFile,
|
||||
description: 'chain key file for https',
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue