You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-07-03 00:47:20 +02:00
improving configs
This commit is contained in:
1280
package-lock.json
generated
1280
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,7 @@
|
|||||||
"sqlite3": "4.1.1",
|
"sqlite3": "4.1.1",
|
||||||
"ts-exif-parser": "0.1.4",
|
"ts-exif-parser": "0.1.4",
|
||||||
"ts-node-iptc": "1.0.11",
|
"ts-node-iptc": "1.0.11",
|
||||||
"typeconfig": "1.0.7",
|
"typeconfig": "1.0.8c",
|
||||||
"typeorm": "0.2.21",
|
"typeorm": "0.2.21",
|
||||||
"winston": "2.4.4"
|
"winston": "2.4.4"
|
||||||
},
|
},
|
||||||
|
@ -2,27 +2,18 @@ import {UserDTO, UserRoles} from '../../../common/entities/UserDTO';
|
|||||||
import {IUserManager} from '../interfaces/IUserManager';
|
import {IUserManager} from '../interfaces/IUserManager';
|
||||||
import {ProjectPath} from '../../ProjectPath';
|
import {ProjectPath} from '../../ProjectPath';
|
||||||
import {Utils} from '../../../common/Utils';
|
import {Utils} from '../../../common/Utils';
|
||||||
import * as path from 'path';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {PasswordHelper} from '../PasswordHelper';
|
import {PasswordHelper} from '../PasswordHelper';
|
||||||
|
import {Config} from '../../../common/config/private/Config';
|
||||||
|
|
||||||
|
|
||||||
export class UserManager implements IUserManager {
|
export class UserManager implements IUserManager {
|
||||||
private db: { users?: UserDTO[], idCounter?: number } = {};
|
private db: { users?: UserDTO[], idCounter?: number } = {};
|
||||||
private readonly dbPath: string;
|
private readonly dbPath: string;
|
||||||
|
|
||||||
generateId(): string {
|
|
||||||
function s4() {
|
|
||||||
return Math.floor((1 + Math.random()) * 0x10000)
|
|
||||||
.toString(16)
|
|
||||||
.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s4() + s4() + s4() + s4();
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dbPath = path.join(ProjectPath.Root, 'users.db');
|
this.dbPath = ProjectPath.getAbsolutePath(Config.Server.Database.memory.usersFile);
|
||||||
if (fs.existsSync(this.dbPath)) {
|
if (fs.existsSync(this.dbPath)) {
|
||||||
this.loadDB();
|
this.loadDB();
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,22 @@ declare var process: NodeJS.Process;
|
|||||||
*/
|
*/
|
||||||
export class ConfigClass extends PrivateConfigDefaultsClass implements IPrivateConfig {
|
export class ConfigClass extends PrivateConfigDefaultsClass implements IPrivateConfig {
|
||||||
|
|
||||||
private static readonly CONFIG_PATH = path.join(__dirname, './../../../../config.json');
|
private static CONFIG_PATH = path.join(__dirname, './../../../../config.json');
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
// TODO: refactor this
|
||||||
|
let configPath = process.argv.find(s => s.startsWith('--config-path='));
|
||||||
|
if (configPath) {
|
||||||
|
configPath = configPath.replace('--config-path=', '');
|
||||||
|
if (path.isAbsolute(configPath)) {
|
||||||
|
ConfigClass.CONFIG_PATH = configPath;
|
||||||
|
} else {
|
||||||
|
ConfigClass.CONFIG_PATH = path.join(__dirname, './../../../../', configPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public setDatabaseType(type: ServerConfig.DatabaseType) {
|
public setDatabaseType(type: ServerConfig.DatabaseType) {
|
||||||
this.Server.Database.type = type;
|
this.Server.Database.type = type;
|
||||||
@ -30,7 +44,8 @@ export class ConfigClass extends PrivateConfigDefaultsClass implements IPrivateC
|
|||||||
['MYSQL_HOST', 'Server-Database-mysql-host'],
|
['MYSQL_HOST', 'Server-Database-mysql-host'],
|
||||||
['MYSQL_PASSWORD', 'Server-Database-mysql-password'],
|
['MYSQL_PASSWORD', 'Server-Database-mysql-password'],
|
||||||
['MYSQL_USERNAME', 'Server-Database-mysql-username'],
|
['MYSQL_USERNAME', 'Server-Database-mysql-username'],
|
||||||
['MYSQL_DATABASE', 'Server-Database-mysql-database']]);
|
['MYSQL_DATABASE', 'Server-Database-mysql-database']],
|
||||||
|
process.argv.indexOf('--force-rewrite-config') !== -1);
|
||||||
this.removeComment();
|
this.removeComment();
|
||||||
|
|
||||||
if (process.argv.indexOf('--config-only') !== -1) {
|
if (process.argv.indexOf('--config-only') !== -1) {
|
||||||
|
@ -31,10 +31,15 @@ export module ServerConfig {
|
|||||||
storage: string;
|
storage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MemoryConfig {
|
||||||
|
usersFile: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DataBaseConfig {
|
export interface DataBaseConfig {
|
||||||
type: DatabaseType;
|
type: DatabaseType;
|
||||||
mysql?: MySQLConfig;
|
mysql?: MySQLConfig;
|
||||||
sqlite?: SQLiteConfig;
|
sqlite?: SQLiteConfig;
|
||||||
|
memory?: MemoryConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThumbnailConfig {
|
export interface ThumbnailConfig {
|
||||||
|
@ -35,6 +35,9 @@ export class PrivateConfigDefaultsClass extends PublicConfigClass implements IPr
|
|||||||
},
|
},
|
||||||
sqlite: {
|
sqlite: {
|
||||||
storage: 'sqlite.db'
|
storage: 'sqlite.db'
|
||||||
|
},
|
||||||
|
memory: {
|
||||||
|
usersFile: 'user.db'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Sharing: {
|
Sharing: {
|
||||||
|
Reference in New Issue
Block a user