first commit
This commit is contained in:
parent
b2cd5d7c5c
commit
0edd12ebad
@ -18,7 +18,7 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"indent": [
|
"indent": [
|
||||||
"error",
|
"error",
|
||||||
4
|
2
|
||||||
],
|
],
|
||||||
"linebreak-style": [
|
"linebreak-style": [
|
||||||
"error",
|
"error",
|
||||||
|
15753
package-lock.json
generated
15753
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,10 +10,12 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
"dcc-utils": "^0.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^4.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
"@types/node": "^16.9.6",
|
"@types/node": "^16.9.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
||||||
"@typescript-eslint/parser": "^4.31.2",
|
"@typescript-eslint/parser": "^4.31.2",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
|
|
||||||
export const get = (req: Request, res: Response):void => {
|
export const get = (req: Request, res: Response):void => {
|
||||||
res.status(200).send({});
|
res.status(200).send({});
|
||||||
};
|
};
|
@ -7,10 +7,10 @@ export default class GreenApi implements API {
|
|||||||
private router: Router;
|
private router: Router;
|
||||||
|
|
||||||
constructor(router: Router) {
|
constructor(router: Router) {
|
||||||
this.router = router;
|
this.router = router;
|
||||||
}
|
}
|
||||||
|
|
||||||
setupApi():void {
|
setupApi():void {
|
||||||
this.router.get('/example',exampleMW.canGet,exampleCtrl.get);
|
this.router.get('/example',exampleMW.canGet,exampleCtrl.get);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ import GreenApi from './green';
|
|||||||
import { Router, Express } from 'express';
|
import { Router, Express } from 'express';
|
||||||
|
|
||||||
export const setupApis = (application: Express):void => {
|
export const setupApis = (application: Express):void => {
|
||||||
const router = Router();
|
const router = Router();
|
||||||
const exampleApi = new GreenApi(router);
|
const exampleApi = new GreenApi(router);
|
||||||
|
|
||||||
exampleApi.setupApi();
|
exampleApi.setupApi();
|
||||||
|
|
||||||
application.use('/api', router);
|
application.use('/api', router);
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface API {
|
export interface API {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import app from './app';
|
import app from './app';
|
||||||
|
|
||||||
const server = app.listen(app.get('port'), () => {
|
const server = app.listen(app.get('port'), () => {
|
||||||
console.log(
|
console.log(
|
||||||
'App is running at http://localhost:%d in %s mode',
|
'App is running at http://localhost:%d in %s mode',
|
||||||
app.get('port'),
|
app.get('port'),
|
||||||
app.get('env')
|
app.get('env')
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('Press CTRL-C to stop\n');
|
console.log('Press CTRL-C to stop\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
export default server;
|
export default server;
|
||||||
|
@ -13,7 +13,7 @@ export class CertificateDownloader{
|
|||||||
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
||||||
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
||||||
this.getAllCertificate()
|
this.getAllCertificate()
|
||||||
.then(() => { console.log('could not read the certificates from the local file'); return this.cerficateCollection })
|
.then(() => { console.log('could not read the certificates from the local file'); return this.cerficateCollection; })
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
console.log('cerficates collection is valid loading from local source');
|
console.log('cerficates collection is valid loading from local source');
|
||||||
@ -36,7 +36,7 @@ export class CertificateDownloader{
|
|||||||
this.cerficateCollection = await response.json();
|
this.cerficateCollection = await response.json();
|
||||||
console.log(response);
|
console.log(response);
|
||||||
const lastupdateDate = Date.now();
|
const lastupdateDate = Date.now();
|
||||||
localStorage.setItem(this.keyStorage, JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}))
|
localStorage.setItem(this.keyStorage, JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}));
|
||||||
// fs.writeFile('./cerificate_collection.json', JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}),'utf8',console.error);
|
// fs.writeFile('./cerificate_collection.json', JSON.stringify({'certificates':this.cerficateCollection, lastupdateDate}),'utf8',console.error);
|
||||||
}else{
|
}else{
|
||||||
throw new Error(response.statusText);
|
throw new Error(response.statusText);
|
||||||
|
@ -14,7 +14,7 @@ export class RuleDownloader {
|
|||||||
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
const savedData = JSON.parse(localStorage.getItem(this.keyStorage) || '{}');
|
||||||
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
if(savedData.lastupdateDate == null || Date.now() - savedData?.lastupdateDate > this.timeSpan){
|
||||||
this.getSettings()
|
this.getSettings()
|
||||||
.then(() => { console.log('could not read the certificates from the local file'); return this.rules })
|
.then(() => { console.log('could not read the certificates from the local file'); return this.rules; })
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
console.log('cerficates collection is valid loading from local source');
|
console.log('cerficates collection is valid loading from local source');
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { CertificateDownloader } from './CertificateDownloader';
|
import { CertificateDownloader } from './CertificateDownloader';
|
||||||
import { RuleDownloader } from './RuleDownloader';
|
import { RuleDownloader } from './RuleDownloader';
|
||||||
import {DCC} from 'dcc-utils';
|
import {DCC} from 'dcc-utils';
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
export default class Verifier {
|
export default class Verifier {
|
||||||
static certDownloader: CertificateDownloader;
|
static certDownloader: CertificateDownloader;
|
||||||
static ruleDownloader: RuleDownloader;
|
static ruleDownloader: RuleDownloader;
|
||||||
static certificateList: any;
|
static certificateList: unknown;
|
||||||
|
|
||||||
static async setup():Promise<void> {
|
static async setup():Promise<void> {
|
||||||
Verifier.certDownloader = CertificateDownloader.getCertificateDownloader();
|
Verifier.certDownloader = CertificateDownloader.getCertificateDownloader();
|
||||||
Verifier.ruleDownloader = RuleDownloader.getRuleDownloader();
|
Verifier.ruleDownloader = RuleDownloader.getRuleDownloader();
|
||||||
Verifier.certificateList = await Verifier.certDownloader.getCertificates()
|
Verifier.certificateList = await Verifier.certDownloader.getCertificates();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async checkCertificate(certificate:string): Promise<unknown>{
|
static async checkCertificate(certificate:string): Promise<unknown>{
|
||||||
|
Loading…
Reference in New Issue
Block a user