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
|
├── data/ server specific data files not tracked by git
|
||||||
│ ├── admins.json forum admins. should be removed and should use admin column from user db
|
│ ├── 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
|
│ ├── apiRootRedirectTo url where domain/api should redirect to
|
||||||
│ ├── dbs/ directory for databases, and for their backups
|
│ ├── dbs/ directory for databases, and for their backups
|
||||||
│ ├── domain the domain the server is hosted on. Used when `DOMAIN` env var is empty
|
│ ├── domain the domain the server is hosted on. Used when `DOMAIN` env var is empty
|
||||||
|
|
|
@ -180,3 +180,9 @@ export interface PeerInfo {
|
||||||
note?: string
|
note?: string
|
||||||
http?: boolean
|
http?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface HttpsFiles {
|
||||||
|
privkeyFile: string
|
||||||
|
fullchainFile: string
|
||||||
|
chainFile: string
|
||||||
|
}
|
||||||
|
|
|
@ -156,3 +156,13 @@ export const ModulesSchema: Schema = {
|
||||||
'.*': ModuleSchema,
|
'.*': 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,
|
ModulesSchema,
|
||||||
SelfInfoSchema,
|
SelfInfoSchema,
|
||||||
LinksSchema,
|
LinksSchema,
|
||||||
|
HttpsFilesSchema,
|
||||||
} from '../types/typeSchemas'
|
} from '../types/typeSchemas'
|
||||||
import logger from './logger'
|
import logger from './logger'
|
||||||
import utils from './utils'
|
import utils from './utils'
|
||||||
|
import { HttpsFiles } from '../types/basicTypes'
|
||||||
|
|
||||||
// FIXME: remove all file exists checks from everywhere for files that are created / checked here
|
// 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
|
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 = {
|
export const files = {
|
||||||
|
...filesFiles,
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
// server / modules files
|
// server / modules files
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
@ -155,15 +172,15 @@ export const files = {
|
||||||
// https files
|
// https files
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
privkeyFile: {
|
privkeyFile: {
|
||||||
path: '/etc/letsencrypt/live/frylabs.net/privkey.pem',
|
path: httpsFiles?.privkeyFile,
|
||||||
description: 'private key file for https',
|
description: 'private key file for https',
|
||||||
},
|
},
|
||||||
fullchainFile: {
|
fullchainFile: {
|
||||||
path: '/etc/letsencrypt/live/frylabs.net/fullchain.pem',
|
path: httpsFiles?.fullchainFile,
|
||||||
description: 'full chain key file for https',
|
description: 'full chain key file for https',
|
||||||
},
|
},
|
||||||
chainFile: {
|
chainFile: {
|
||||||
path: '/etc/letsencrypt/live/frylabs.net/chain.pem',
|
path: httpsFiles?.chainFile,
|
||||||
description: 'chain key file for https',
|
description: 'chain key file for https',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue