This commit is contained in:
xiaojunnuo
2024-08-04 22:46:08 +08:00
parent 330b84de33
commit 0227155ab4
2 changed files with 15 additions and 0 deletions
@@ -2,6 +2,7 @@ import fs from 'fs';
import yaml from 'js-yaml';
import * as _ from 'lodash-es';
import { nanoid } from 'nanoid';
import path from 'path';
const KEYS_FILE = './data/keys.yaml';
export class Keys {
jwtKey: string = nanoid();
@@ -19,6 +20,12 @@ export class Keys {
}
save() {
const parent = path.dirname(KEYS_FILE);
if (!fs.existsSync(parent)) {
fs.mkdirSync(parent, {
recursive: true,
});
}
fs.writeFileSync(KEYS_FILE, yaml.dump(this));
}
}