Files
yourpart3/backend/utils/initializeChat.js
Torsten Schulz (local) 1ab9407e79
All checks were successful
Deploy to production / deploy (push) Successful in 2m56s
Refactor code structure for improved readability and maintainability; optimize performance across multiple modules.
2026-07-21 09:08:15 +02:00

43 lines
842 B
JavaScript
Executable File

import ChatRight from "../models/chat/rights.js";
import RoomType from "../models/chat/room_type.js";
const initializeChat = async () => {
initializeChatRights();
initializeRoomTypes();
}
const RoomTypes = [
'chat',
'dice',
'poker',
'hangman'
];
const ChatRights = [
'talk',
'scream',
'whisper',
'start game',
'open room',
'systemmessage'
];
const initializeChatRights = async () => {
for (const right of ChatRights) {
await ChatRight.findOrCreate({
where: { tr: right },
defaults: { tr: right }
});
}
}
const initializeRoomTypes = async () => {
for (const type of RoomTypes) {
await RoomType.findOrCreate({
where: { tr: type },
defaults: { tr: type }
});
}
}
export default initializeChat;