Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
2915ac21
Commit
2915ac21
authored
2 years ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
Config loader singleton
parent
ee2da1dd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ExpressAPI/src/config/Config.ts
+49
-0
49 additions, 0 deletions
ExpressAPI/src/config/Config.ts
with
49 additions
and
0 deletions
ExpressAPI/src/config/Config.ts
0 → 100644
+
49
−
0
View file @
2915ac21
class
Config
{
private
static
_instance
:
Config
;
public
readonly
api
:
{
port
:
number
};
public
readonly
database
:
{
type
:
string
,
host
:
string
,
port
:
number
,
user
:
string
,
password
:
string
,
database
:
string
};
public
readonly
jwtSecretKey
:
string
;
public
readonly
sessionTimeout
:
number
;
public
readonly
userPasswordLength
:
number
;
public
readonly
userPasswordSaltRounds
:
number
;
private
constructor
()
{
this
.
api
=
{
port
:
Number
(
process
.
env
.
API_PORT
)
};
this
.
database
=
{
type
:
process
.
env
.
DATABASE_TYPE
,
host
:
process
.
env
.
DATABASE_HOST
,
port
:
Number
(
process
.
env
.
DATABASE_PORT
),
user
:
process
.
env
.
DATABASE_USER
,
password
:
process
.
env
.
DATABASE_PASSWORD
,
database
:
process
.
env
.
DATABASE_NAME
};
this
.
jwtSecretKey
=
process
.
env
.
JWT_SECRET_KEY
;
this
.
sessionTimeout
=
Number
(
process
.
env
.
SESSION_TIMEOUT
);
this
.
userPasswordLength
=
Number
(
process
.
env
.
USER_PASSWORD_LENGTH
);
this
.
userPasswordSaltRounds
=
Number
(
process
.
env
.
USER_PASSWORD_SALT_ROUNDS
);
}
public
static
get
instance
():
Config
{
if
(
!
Config
.
_instance
)
{
Config
.
_instance
=
new
Config
();
}
return
Config
.
_instance
;
}
}
export
default
Config
.
instance
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment