feat(v3): Adding baseline for API v3
This commit is contained in:
38
server/src/Shared/Resources/index.js
Normal file
38
server/src/Shared/Resources/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
class SharedResources{
|
||||
constructor(){
|
||||
this.dictionary = {};
|
||||
}
|
||||
|
||||
set( key , val ){
|
||||
this.dictionary[ key ] = val;
|
||||
}
|
||||
|
||||
exists( key ){
|
||||
return ( this.dictionary[ key ] != undefined );
|
||||
}
|
||||
|
||||
get( key ){
|
||||
if( ! this.exists( key ) ){
|
||||
throw new Error( `Key [${key}] not defined!` );
|
||||
}
|
||||
return this.dictionary[ key ];
|
||||
}
|
||||
|
||||
try_get( key ){
|
||||
if( ! this.exists( key ) ){
|
||||
return null;
|
||||
}else{
|
||||
return this.dictionary[ key ];
|
||||
}
|
||||
}
|
||||
|
||||
remove( key ){
|
||||
if( this.exists(key) ){
|
||||
delete this.dictionary[ key ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new SharedResources();
|
||||
Reference in New Issue
Block a user