fix(package): initial

This commit is contained in:
2018-08-17 23:23:49 +02:00
commit 15058aebfa
11 changed files with 274 additions and 0 deletions

3
ts/index.ts Normal file
View File

@ -0,0 +1,3 @@
import * as smartsession from './smartsession.classes.smartsession';

View 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 ''
}
}

View 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() {}
};

View File

@ -0,0 +1,2 @@
const removeme = {};
export { removeme };