Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | 2x 1x 1x 1x 2x 5x 1x 4x 1x 3x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x 1x 2x | import { DatabaseInterface, DatabaseInterfaceSessions } from '@accounts/types';
import { Configuration } from './types/configuration';
export class DatabaseManager implements DatabaseInterface {
private userStorage: DatabaseInterface;
private sessionStorage: DatabaseInterface | DatabaseInterfaceSessions;
constructor(configuration: Configuration) {
this.validateConfiguration(configuration);
this.userStorage = configuration.userStorage;
this.sessionStorage = configuration.sessionStorage;
}
private validateConfiguration(configuration: Configuration): void {
if (!configuration) {
throw new Error(
'[ Accounts - DatabaseManager ] configuration : A configuration object is required on DatabaseManager'
);
}
if (!configuration.userStorage) {
throw new Error(
'[ Accounts - DatabaseManager ] configuration : A userStorage DatabaseInterface is required'
);
}
if (!configuration.sessionStorage) {
throw new Error(
'[ Accounts - DatabaseManager ] configuration : A sessionStorage DatabaseInterface is required'
);
}
}
// Return the createUser function from the userStorage
public get createUser(): DatabaseInterface['createUser'] {
return this.userStorage.createUser.bind(this.userStorage);
}
// Return the findUserById function from the userStorage
public get findUserById(): DatabaseInterface['findUserById'] {
return this.userStorage.findUserById.bind(this.userStorage);
}
// Return the findUserByEmail function from the userStorage
public get findUserByEmail(): DatabaseInterface['findUserByEmail'] {
return this.userStorage.findUserByEmail.bind(this.userStorage);
}
// Return the findUserByUsername function from the userStorage
public get findUserByUsername(): DatabaseInterface['findUserByUsername'] {
return this.userStorage.findUserByUsername.bind(this.userStorage);
}
// Return the findPasswordHash function from the userStorage
public get findPasswordHash(): DatabaseInterface['findPasswordHash'] {
return this.userStorage.findPasswordHash.bind(this.userStorage);
}
// Return the findUserByEmailVerificationToken function from the userStorage
public get findUserByEmailVerificationToken(): DatabaseInterface['findUserByEmailVerificationToken'] {
return this.userStorage.findUserByEmailVerificationToken.bind(this.userStorage);
}
// Return the findUserByResetPasswordToken function from the userStorage
public get findUserByResetPasswordToken(): DatabaseInterface['findUserByResetPasswordToken'] {
return this.userStorage.findUserByResetPasswordToken.bind(this.userStorage);
}
// Return the findUserByServiceId function from the userStorage
public get findUserByServiceId(): DatabaseInterface['findUserByServiceId'] {
return this.userStorage.findUserByServiceId.bind(this.userStorage);
}
// Return the addEmail function from the userStorage
public get addEmail(): DatabaseInterface['addEmail'] {
return this.userStorage.addEmail.bind(this.userStorage);
}
// Return the removeEmail function from the userStorage
public get removeEmail(): DatabaseInterface['removeEmail'] {
return this.userStorage.removeEmail.bind(this.userStorage);
}
// Return the verifyEmail function from the userStorage
public get verifyEmail(): DatabaseInterface['verifyEmail'] {
return this.userStorage.verifyEmail.bind(this.userStorage);
}
// Return the setUsername function from the userStorage
public get setUsername(): DatabaseInterface['setUsername'] {
return this.userStorage.setUsername.bind(this.userStorage);
}
// Return the setPassword function from the userStorage
public get setPassword(): DatabaseInterface['setPassword'] {
return this.userStorage.setPassword.bind(this.userStorage);
}
// Return the setProfile function from the userStorage
public get setProfile(): DatabaseInterface['setProfile'] {
return this.userStorage.setProfile.bind(this.userStorage);
}
// Return the setService function from the userStorage
public get setService(): DatabaseInterface['setService'] {
return this.userStorage.setService.bind(this.userStorage);
}
// Return the unsetService function from the userStorage
public get unsetService(): DatabaseInterface['unsetService'] {
return this.userStorage.unsetService.bind(this.userStorage);
}
// Return the createSession function from the sessionStorage
public get createSession(): DatabaseInterface['createSession'] {
return this.sessionStorage.createSession.bind(this.sessionStorage);
}
// Return the updateSession function from the sessionStorage
public get updateSession(): DatabaseInterface['updateSession'] {
return this.sessionStorage.updateSession.bind(this.sessionStorage);
}
// Return the invalidateSession function from the sessionStorage
public get invalidateSession(): DatabaseInterface['invalidateSession'] {
return this.sessionStorage.invalidateSession.bind(this.sessionStorage);
}
// Return the invalidateAllSessions function from the sessionStorage
public get invalidateAllSessions(): DatabaseInterface['invalidateAllSessions'] {
return this.sessionStorage.invalidateAllSessions.bind(this.sessionStorage);
}
// Return the findSessionByToken function from the sessionStorage
public get findSessionByToken(): DatabaseInterface['findSessionByToken'] {
return this.sessionStorage.findSessionByToken.bind(this.sessionStorage);
}
// Return the findSessionById function from the sessionStorage
public get findSessionById(): DatabaseInterface['findSessionById'] {
return this.sessionStorage.findSessionById.bind(this.sessionStorage);
}
// Return the addEmailVerificationToken function from the userStorage
public get addEmailVerificationToken(): DatabaseInterface['addEmailVerificationToken'] {
return this.userStorage.addEmailVerificationToken.bind(this.userStorage);
}
// Return the addResetPasswordToken function from the userStorage
public get addResetPasswordToken(): DatabaseInterface['addResetPasswordToken'] {
return this.userStorage.addResetPasswordToken.bind(this.userStorage);
}
// Return the setResetPassword function from the userStorage
public get setResetPassword(): DatabaseInterface['setResetPassword'] {
return this.userStorage.setResetPassword.bind(this.userStorage);
}
// Return the setResetPassword function from the userStorage
public get setUserDeactivated(): DatabaseInterface['setUserDeactivated'] {
return this.userStorage.setUserDeactivated.bind(this.userStorage);
}
}
|