1
0
forked from noxious/server

use camelcase file names from now on...

This commit is contained in:
2024-08-21 20:55:58 +02:00
parent acc9eaae9e
commit 6b97e7d9cb
55 changed files with 396 additions and 116 deletions

View File

@ -0,0 +1,38 @@
import { User } from '@prisma/client'
import logger from '../utilities/logger'
type TLoggedInUsers = {
users: User[]
}
class UserManager {
private loggedInUsers: TLoggedInUsers[] = []
// Method to initialize user manager
public async boot() {
logger.info('User manager loaded')
}
// Function that adds user to logged in users
public loginUser(user: User) {
this.loggedInUsers.push({
users: [user]
})
}
// Function that checks if a user is already logged in
public findUser(user: User) {
return this.loggedInUsers.find((loggedInUser) => {
return loggedInUser.users.includes(user)
})
}
// Function that lists all logged in users
public listUsers() {
return this.loggedInUsers.map((loggedInUser) => {
return loggedInUser.users
})
}
}
export default new UserManager()