From c3d0fe4623648fcc0da8d63d18e0781a0729cc8d Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Sun, 11 Dec 2022 09:10:17 +0000 Subject: [PATCH] fix lint. --- CommonServer/Utils/Express.ts | 6 +-- CommonServer/Utils/StartServer.ts | 2 +- Model/Models/GreenlockCertificate.ts | 1 - StatusPage/Index.ts | 1 - StatusPage/Serve.ts | 1 - .../Jobs/StatusPageCerts/StausPageCerts.ts | 43 +++++++++++-------- Workers/Utils/Greenlock/HttpChallenge.ts | 7 ++- Workers/Utils/Greenlock/Store.ts | 18 +++----- 8 files changed, 37 insertions(+), 42 deletions(-) diff --git a/CommonServer/Utils/Express.ts b/CommonServer/Utils/Express.ts index a19c7e05e3..2edc45344f 100644 --- a/CommonServer/Utils/Express.ts +++ b/CommonServer/Utils/Express.ts @@ -65,17 +65,13 @@ class Express { public static async launchApplication( appName: string, - port?: Port, + port?: Port ): Promise { - if (!this.app) { this.setupExpress(); } - - return new Promise((resolve: Function) => { - this.app.listen(port?.toNumber() || this.app.get('port'), () => { // eslint-disable-next-line logger.info(`${appName} server started on port: ${port?.toNumber() || this.app.get('port')}`); diff --git a/CommonServer/Utils/StartServer.ts b/CommonServer/Utils/StartServer.ts index ebb9caef6a..d88e2e5126 100644 --- a/CommonServer/Utils/StartServer.ts +++ b/CommonServer/Utils/StartServer.ts @@ -93,7 +93,7 @@ app.use(logRequest); const init: Function = async ( appName: string, - port?: Port, + port?: Port ): Promise => { await Express.launchApplication(appName, port); LocalCache.setString('app', 'name', appName); diff --git a/Model/Models/GreenlockCertificate.ts b/Model/Models/GreenlockCertificate.ts index 86c66715f2..1e8a2e160c 100644 --- a/Model/Models/GreenlockCertificate.ts +++ b/Model/Models/GreenlockCertificate.ts @@ -47,7 +47,6 @@ export default class GreenlockCertificate extends BaseModel { }) public blob?: string = undefined; - @ColumnAccessControl({ create: [], read: [], diff --git a/StatusPage/Index.ts b/StatusPage/Index.ts index 6551b7db93..4fb9c7d632 100755 --- a/StatusPage/Index.ts +++ b/StatusPage/Index.ts @@ -55,7 +55,6 @@ app.get( app.get( '/status-page-api/cname-verification/:token', async (req: ExpressRequest, res: ExpressResponse) => { - const host: string | undefined = req.get('host'); if (!host) { diff --git a/StatusPage/Serve.ts b/StatusPage/Serve.ts index 15fa07c678..b9aa5372cd 100644 --- a/StatusPage/Serve.ts +++ b/StatusPage/Serve.ts @@ -30,7 +30,6 @@ const init: Function = async (): Promise => { await PostgresAppInstance.connect( PostgresAppInstance.getDatasourceOptions() ); - } catch (err) { logger.error('App Init Failed:'); logger.error(err); diff --git a/Workers/Jobs/StatusPageCerts/StausPageCerts.ts b/Workers/Jobs/StatusPageCerts/StausPageCerts.ts index 5d59cfdb93..f76d2e115a 100644 --- a/Workers/Jobs/StatusPageCerts/StausPageCerts.ts +++ b/Workers/Jobs/StatusPageCerts/StausPageCerts.ts @@ -18,7 +18,7 @@ import ClusterKeyAuthorization from 'CommonServer/Middleware/ClusterKeyAuthoriza import { JSONObject } from 'Common/Types/JSON'; import Response from 'CommonServer/Utils/Response'; import LIMIT_MAX from 'Common/Types/Database/LimitMax'; -import axios from 'axios'; +import axios, { AxiosResponse } from 'axios'; import GreenlockCertificate from 'Model/Models/GreenlockCertificate'; import GreenlockCertificateService from 'CommonServer/Services/GreenlockCertificateService'; import fs from 'fs'; @@ -326,7 +326,6 @@ RunCron( } ); - RunCron( 'StatusPageCerts:WriteCertsToDisk', IsDevelopment ? EVERY_MINUTE : EVERY_HOUR, @@ -335,12 +334,10 @@ RunCron( const certs: Array = await GreenlockCertificateService.findBy({ - query: { - - }, + query: {}, select: { isKeyPair: true, - key: true, + key: true, blob: true, }, limit: LIMIT_MAX, @@ -355,18 +352,30 @@ RunCron( continue; } - const certBlob = certs.find((i) => i.key === cert.key && !i.isKeyPair); - + const certBlob: GreenlockCertificate | undefined = certs.find( + (i: GreenlockCertificate) => { + return i.key === cert.key && !i.isKeyPair; + } + ); + if (!certBlob) { - continue; + continue; } - const key = JSON.parse(cert.blob || '{}').privateKeyPem; - const crt = JSON.parse(certBlob.blob || '{}').cert; + const key: string = JSON.parse(cert.blob || '{}').privateKeyPem; + const crt: string = JSON.parse(certBlob.blob || '{}').cert; - // Write to disk. - fs.writeFileSync(`/usr/src/Certs/StatusPageCerts/${cert.key}.crt`, crt, { flag: 'wx' }); - fs.writeFileSync(`/usr/src/Certs/StatusPageCerts/${cert.key}.key`, key, { flag: 'wx' }); + // Write to disk. + fs.writeFileSync( + `/usr/src/Certs/StatusPageCerts/${cert.key}.crt`, + crt, + { flag: 'wx' } + ); + fs.writeFileSync( + `/usr/src/Certs/StatusPageCerts/${cert.key}.key`, + key, + { flag: 'wx' } + ); } } ); @@ -437,11 +446,11 @@ const checkCnameValidation: Function = async ( logger.info('Check CNAMeValidation.'); try { - const agent = new https.Agent({ + const agent: https.Agent = new https.Agent({ rejectUnauthorized: false, }); - const result = await axios.get( + const result: AxiosResponse = await axios.get( 'https://' + fulldomain + '/status-page-api/cname-verification/' + @@ -463,7 +472,7 @@ const isSslProvisioned: Function = async ( token: string ): Promise => { try { - const result = await axios.get( + const result: AxiosResponse = await axios.get( 'https://' + fulldomain + '/status-page-api/cname-verification/' + diff --git a/Workers/Utils/Greenlock/HttpChallenge.ts b/Workers/Utils/Greenlock/HttpChallenge.ts index ef9cc20ba8..a63044a949 100644 --- a/Workers/Utils/Greenlock/HttpChallenge.ts +++ b/Workers/Utils/Greenlock/HttpChallenge.ts @@ -17,7 +17,7 @@ module.exports = { const ch: any = data.challenge; const key: string = ch.identifier.value + '#' + ch.token; - const token: string = ch.token; + const token: string = ch.token; let challenge: GreenlockChallenge | null = await GreenlockChallengeService.findOneBy({ @@ -107,7 +107,6 @@ module.exports = { return null; }, - } - } - + }; + }, }; diff --git a/Workers/Utils/Greenlock/Store.ts b/Workers/Utils/Greenlock/Store.ts index 72abd700b1..f3efd6bad3 100644 --- a/Workers/Utils/Greenlock/Store.ts +++ b/Workers/Utils/Greenlock/Store.ts @@ -8,17 +8,17 @@ module.exports = { const saveCertificate: Function = async ( id: string, blob: string, - isKeyPair: boolean, + isKeyPair: boolean ): Promise => { let cert: GreenlockCertificate | null = await GreenlockCertificateService.findOneBy({ query: { key: id, - isKeyPair: isKeyPair + isKeyPair: isKeyPair, }, select: { _id: true, - isKeyPair: isKeyPair + isKeyPair: isKeyPair, }, props: { isRoot: true, @@ -62,7 +62,7 @@ module.exports = { await GreenlockCertificateService.findOneBy({ query: { key: id, - isKeyPair: isKeyPair + isKeyPair: isKeyPair, }, select: { _id: true, @@ -102,10 +102,7 @@ module.exports = { opts.account.id || opts.email || 'default'; const keypair: any = opts.keypair; - return await saveKeypair( - id, - JSON.stringify(keypair) - ); // Must return or Promise `null` instead of `undefined` + return await saveKeypair(id, JSON.stringify(keypair)); // Must return or Promise `null` instead of `undefined` }, // We need a way to retrieve a prior account's keypair for renewals and additional ACME certificate "orders" checkKeypair: async (opts: any): Promise => { @@ -131,10 +128,7 @@ module.exports = { opts.subject; const keypair: any = opts.keypair; - return await saveKeypair( - id, - JSON.stringify(keypair) - ); // Must return or Promise `null` instead of `undefined` + return await saveKeypair(id, JSON.stringify(keypair)); // Must return or Promise `null` instead of `undefined` // Side Note: you can use the "keypairs" package to convert between // public and private for jwk and pem, as well as convert JWK <-> PEM },