fix(package): initial
This commit is contained in:
3
ts/index.ts
Normal file
3
ts/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
import * as smartsession from './smartsession.classes.smartsession';
|
||||
|
17
ts/smartsession.classes.smartsession.ts
Normal file
17
ts/smartsession.classes.smartsession.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import * as plugins from './smartsession.plugins';
|
||||
import { } from './smartsession.classes.store';
|
||||
|
||||
|
||||
|
||||
export class Smartsession {
|
||||
/**
|
||||
* registers a new user with a given key and assign
|
||||
*/
|
||||
register<T>(uuidArg: string, payloadArg: T): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
registerAndGenerateUuid(): string {
|
||||
return ''
|
||||
}
|
||||
}
|
63
ts/smartsession.classes.store.ts
Normal file
63
ts/smartsession.classes.store.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import * as plugins from './smartsession.plugins';
|
||||
|
||||
export interface storageObject {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* SessionStore is in charge of storing session related data
|
||||
*/
|
||||
export class SessionStore<T> {
|
||||
memoryStore: storageObject = {};
|
||||
|
||||
/**
|
||||
* check for an id
|
||||
*/
|
||||
checkForId(idArg: string): boolean {
|
||||
if(this.memoryStore[idArg]) {
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an id
|
||||
*/
|
||||
getId(idArg: string): T {
|
||||
return this.memoryStore[idArg];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
removeId(idArg: string): boolean {
|
||||
// TODO: implement
|
||||
if(this.checkForId(idArg)) {
|
||||
delete this.memoryStore[idArg];
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* updates an id within store
|
||||
*/
|
||||
updateId(idArg: string, payloadArg: T) {
|
||||
if(this.checkForId(idArg)) {
|
||||
this.memoryStore[idArg] = payloadArg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* upserts an id within store
|
||||
*/
|
||||
upsertId(idArg: string, payloadArg: T) {
|
||||
this.memoryStore[idArg] = payloadArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* syncs the fast memory store with a persistence layer in an async way
|
||||
* TODO: Think about what actions need to be blocking to ensure cluster availability
|
||||
*/
|
||||
sync() {}
|
||||
};
|
2
ts/smartsession.plugins.ts
Normal file
2
ts/smartsession.plugins.ts
Normal file
@ -0,0 +1,2 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
Reference in New Issue
Block a user