Skip to content
Snippets Groups Projects
Commit 18c397ef authored by michael.minelli's avatar michael.minelli
Browse files

Config => Add some var for default enonce values and gitlab params

parent 66a6f6eb
No related branches found
No related tags found
No related merge requests found
import Toolbox from '../shared/Toolbox';
class Config { class Config {
private static _instance: Config; private static _instance: Config;
...@@ -17,6 +20,14 @@ class Config { ...@@ -17,6 +20,14 @@ class Config {
teachingStaff: Array<string>; teachingStaff: Array<string>;
}; };
public gitlab: {
apiURL: string; urls: Array<string>; account: { id: number; username: string; token: string; }; group: { root: number; templates: number; enonces: number; exercices: number; };
};
public enonce: {
default: { description: string; initReadme: boolean; sharedRunnersEnabled: boolean; visibility: string; wikiEnabled: boolean; template: string };
};
public readonly userPasswordLength: number; public readonly userPasswordLength: number;
public readonly userPasswordSaltRounds: number; public readonly userPasswordSaltRounds: number;
...@@ -43,8 +54,37 @@ class Config { ...@@ -43,8 +54,37 @@ class Config {
teachingStaff: JSON.parse(process.env.ROLES_WITH_TEACHING_STAFF_PERMISSIONS) teachingStaff: JSON.parse(process.env.ROLES_WITH_TEACHING_STAFF_PERMISSIONS)
}; };
this.gitlab = {
apiURL : process.env.GITLAB_API_URL,
urls : JSON.parse(process.env.GITLAB_URLS || '[]'),
account: {
id : Number(process.env.GITLAB_DOJO_ACCOUNT_ID),
username: process.env.GITLAB_DOJO_ACCOUNT_USERNAME,
token : process.env.GITLAB_DOJO_ACCOUNT_TOKEN
},
group : {
root : Number(process.env.GITLAB_GROUP_ROOT_ID),
templates: Number(process.env.GITLAB_GROUP_TEMPLATES_ID),
enonces : Number(process.env.GITLAB_GROUP_ENONCES_ID),
exercices: Number(process.env.GITLAB_GROUP_EXERCICES_ID)
}
};
this.enonce = {
default: {
description : process.env.ENONCE_DEFAULT_DESCRIPTION,
initReadme : Toolbox.strToBool(process.env.ENONCE_DEFAULT_INIT_README),
sharedRunnersEnabled: Toolbox.strToBool(process.env.ENONCE_DEFAULT_SHARED_RUNNERS_ENABLED),
visibility : process.env.ENONCE_DEFAULT_VISIBILITY,
wikiEnabled : Toolbox.strToBool(process.env.ENONCE_DEFAULT_WIKI_ENABLED),
template : process.env.ENONCE_DEFAULT_TEMPLATE.replace('{{USERNAME}}', this.gitlab.account.username).replace('{{TOKEN}}', this.gitlab.account.token)
}
};
this.userPasswordLength = Number(process.env.USER_PASSWORD_LENGTH); this.userPasswordLength = Number(process.env.USER_PASSWORD_LENGTH);
this.userPasswordSaltRounds = Number(process.env.USER_PASSWORD_SALT_ROUNDS); this.userPasswordSaltRounds = Number(process.env.USER_PASSWORD_SALT_ROUNDS);
} }
public static get instance(): Config { public static get instance(): Config {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment