Skip to content

Commit

Permalink
Merge pull request #96 from BingusBoingus-Developer-Team/Refactor/95-…
Browse files Browse the repository at this point in the history
…Project-structure

refactor(folder-structure): move model dependent modules into models …
  • Loading branch information
sanriodev authored May 7, 2024
2 parents 686f0ca + 0a0e4c5 commit a7f86e7
Show file tree
Hide file tree
Showing 31 changed files with 40 additions and 50 deletions.
8 changes: 4 additions & 4 deletions src/modules/command/command.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import { BugReport } from './commands/bug';
import { CoinflipCommand } from './commands/coinflip';
import { GoldCommand } from './commands/gold';
import SomeoneOnceSaidCommand from './commands/someone-once-said';
import { SomeoneOnceSaidModule } from '../someone-once-said/module/someone-once-said.module';
import GetRandomQuote from './commands/get-a-quote';
import { PollCommand } from './commands/poll';
import { PollModule } from '../poll/module/poll.module';
import { VersionModule } from '../version/module/version.module';
import { VersionCommand } from './commands/version';
import { BirthdayEntryModule } from '../birthday/module/birthday-entry.module';
import AddBirthdayEntryCommand from './commands/add-birthday-entry';
import ActivateBirthdayEntryShoutoutCommand from './commands/activate-birthday-shoutout';
import DeactivateBirthdayEntryShoutoutCommand from './commands/deactivate-birthday-shoutout';
import { SomeoneOnceSaidModule } from '../models/someone-once-said/module/someone-once-said.module';
import { PollModule } from '../models/poll/module/poll.module';
import { VersionModule } from '../models/version/module/version.module';
import { BirthdayEntryModule } from '../models/birthday/module/birthday-entry.module';

@Module({
providers: [
Expand Down
4 changes: 2 additions & 2 deletions src/modules/command/commands/activate-birthday-shoutout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from 'discord.js';
import { ACommand } from '../command.abstract';
import { Inject } from '@nestjs/common';
import { BirthdayEntryService } from '../../birthday/service/birthday-entry.service';
import { CreateOrUpdateBirthdayEntryDto } from '../../birthday/dto/create-or-update-birthday-entry.dto';
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service';
import { CreateOrUpdateBirthdayEntryDto } from '../../models/birthday/dto/create-or-update-birthday-entry.dto';

export default class ActivateBirthdayEntryShoutoutCommand extends ACommand {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions src/modules/command/commands/add-birthday-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
} from 'discord.js';
import { ACommand } from '../command.abstract';
import { Inject } from '@nestjs/common';
import { BirthdayEntryService } from '../../birthday/service/birthday-entry.service';
import { CreateOrUpdateBirthdayEntryDto } from '../../birthday/dto/create-or-update-birthday-entry.dto';
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service';
import { CreateOrUpdateBirthdayEntryDto } from '../../models/birthday/dto/create-or-update-birthday-entry.dto';

export default class AddBirthdayEntryCommand extends ACommand {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions src/modules/command/commands/deactivate-birthday-shoutout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CacheType, CommandInteraction, SlashCommandBuilder } from 'discord.js';
import { ACommand } from '../command.abstract';
import { Inject } from '@nestjs/common';
import { BirthdayEntryService } from '../../birthday/service/birthday-entry.service';
import { CreateOrUpdateBirthdayEntryDto } from '../../birthday/dto/create-or-update-birthday-entry.dto';
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service';
import { CreateOrUpdateBirthdayEntryDto } from '../../models/birthday/dto/create-or-update-birthday-entry.dto';

export default class DeactivateBirthdayEntryShoutoutCommand extends ACommand {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/command/commands/get-a-quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
SlashCommandBuilder,
} from 'discord.js';
import { ACommand } from '../command.abstract';
import { SomeoneOnceSaidService } from '../../someone-once-said/service/someone-once-said.service';
import { Inject } from '@nestjs/common';
import { SomeoneOnceSaidService } from '../../models/someone-once-said/service/someone-once-said.service';

export default class GetRandomQuote extends ACommand {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/command/commands/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SlashCommandBuilder,
} from 'discord.js';
import { ACommand } from '../command.abstract';
import { PollService } from '../../poll/service/poll.service';
import { PollService } from '../../models/poll/service/poll.service';

@Injectable()
export class PollCommand extends ACommand {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/command/commands/someone-once-said.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
SlashCommandBuilder,
} from 'discord.js';
import { ACommand } from '../command.abstract';
import { SomeoneOnceSaidService } from '../../someone-once-said/service/someone-once-said.service';
import { Inject } from '@nestjs/common';
import { SomeoneOnceSaid } from '../../../schemas/someone-once-said.schema';
import { SomeoneOnceSaidService } from '../../models/someone-once-said/service/someone-once-said.service';

export default class SomeoneOnceSaidCommand extends ACommand {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/command/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { SlashCommandBuilder } from 'discord.js';
import { ACommand } from '../command.abstract';
import { VersionService } from '../../version/service/version.service';
import { VersionService } from '../../models/version/service/version.service';

@Injectable()
export class VersionCommand extends ACommand {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cron-tasks/cron-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ITask } from './tasks/interfaces/task.interface'
import BirthdayShoutoutTask from './tasks/birthday-shoutout.task'
import * as cron from 'node-cron'
import { Inject } from '@nestjs/common'
import { BirthdayEntryService } from '../birthday/service/birthday-entry.service'
import WakeUpTask from './tasks/wake-up.task'
import { BirthdayEntryService } from '../models/birthday/service/birthday-entry.service'


interface TaskEntry {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cron-tasks/task.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module } from "@nestjs/common";
import { BirthdayEntryModule } from "../birthday/module/birthday-entry.module";
import { BirthdayEntryModule } from "../models/birthday/module/birthday-entry.module";


@Module({
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cron-tasks/tasks/birthday-shoutout.task.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EmbedBuilder, TextChannel } from 'discord.js'
import { ITask } from './interfaces/task.interface'
import { BirthdayEntryService } from '../../birthday/service/birthday-entry.service'
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service'

export default class BirthdayShoutoutTask implements ITask {
private channel: TextChannel
Expand Down
2 changes: 1 addition & 1 deletion src/modules/discord/discord.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { DiscordService } from './discord.service';
import { AppConfigModule } from '../../config/config.module';
import { BirthdayEntryModule } from '../birthday/module/birthday-entry.module';
import { BirthdayEntryModule } from '../models/birthday/module/birthday-entry.module';

@Module({
imports: [AppConfigModule, BirthdayEntryModule],
Expand Down
2 changes: 1 addition & 1 deletion src/modules/discord/discord.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { Client, GatewayIntentBits } from 'discord.js';
import { AppConfigService } from '../../config/config.service';
import { CronScheduler } from '../cron-tasks/cron-scheduler';
import { BirthdayEntryService } from '../birthday/service/birthday-entry.service';
import { BirthdayEntryService } from '../models/birthday/service/birthday-entry.service';

@Injectable()
export class DiscordService {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/event/event.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Interaction } from './services/interaction';
import { MessageEvent } from './services/messageEvent';
import { DiscordModule } from '../discord/discord.module';
import { CommandModule } from '../command/command.module';
import { PollModule } from '../poll/module/poll.module';
import { PollModule } from '../models/poll/module/poll.module';

@Module({
imports: [DiscordModule, CommandModule, PollModule],
Expand Down
2 changes: 1 addition & 1 deletion src/modules/event/services/interaction.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Interaction } from './interaction';
import { CommandService } from '../../command/command.service';
import { PollService } from '../../poll/service/poll.service';
import { PollService } from '../../models/poll/service/poll.service';

describe('Interaction', () => {
let service: Interaction;
Expand Down
11 changes: 2 additions & 9 deletions src/modules/event/services/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonInteraction,
ButtonStyle,
CacheType,
ClientEvents,
EmbedBuilder,
Events,
Message,
} from 'discord.js';
import { AEvent } from '../event.abstract';
import { CommandService } from '../../command/command.service';
import { Inject, Injectable } from '@nestjs/common';
import { PollService } from '../../poll/service/poll.service';
import { Injectable } from '@nestjs/common';
import { PollService } from '../../models/poll/service/poll.service';

@Injectable()
export class Interaction extends AEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { ReS } from '../../../common/res.model';
import { BirthdayEntryService } from '../service/birthday-entry.service';
import { BirthdayEntryDocument } from '../../../schemas/birthday-entry.schema';
import { CreateOrUpdateBirthdayEntryDto } from '../dto/create-or-update-birthday-entry.dto';
import { ReS } from '../../../../common/res.model';
import { BirthdayEntryDocument } from '../../../../schemas/birthday-entry.schema';

@Controller('birthday-entry')
@ApiTags('birthday-entry')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { BirthdayEntry, BirthdayEntrySchema } from '../../../schemas/birthday-entry.schema';
import { BirthdayEntryService } from '../service/birthday-entry.service';
import { BirthdayEntryController } from '../controller/birthday-entry.controller';
import { BirthdayEntry, BirthdayEntrySchema } from '../../../../schemas/birthday-entry.schema';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { BirthdayEntryDocument } from '../../../schemas/birthday-entry.schema';
import { CreateOrUpdateBirthdayEntryDto } from '../dto/create-or-update-birthday-entry.dto';
import { BirthdayEntryDocument } from '../../../../schemas/birthday-entry.schema';

export class BirthdayEntryService {
constructor(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { Poll, PollSchema } from '../../../schemas/poll.schema';
import { DbPollService } from '../service/db-poll.service';
import { PollService } from '../service/poll.service';
import { Poll, PollSchema } from '../../../../schemas/poll.schema';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Test, TestingModule } from '@nestjs/testing';
import { getModelToken } from '@nestjs/mongoose';
import { Model, MongooseError } from 'mongoose';
import { DbPollService } from './db-poll.service';
import { PollDocument } from '../../../schemas/poll.schema';
import { PollEntity } from '../../../schemas/poll-entity.model';
import { UpdatePollDto } from '../dto/update-poll.dto';
import { PollDocument } from '../../../../schemas/poll.schema';
import { PollEntity } from '../../../../schemas/poll-entity.model';

// Mocking the pollModel
const mockPollModel = () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { PollDocument } from '../../../schemas/poll.schema';
import { PollEntity } from '../../../schemas/poll-entity.model';
import { UpdatePollDto } from '../dto/update-poll.dto';
import { PollEntity } from '../../../../schemas/poll-entity.model';
import { PollDocument } from '../../../../schemas/poll.schema';

export class DbPollService {
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from 'discord.js';
import { DbPollService } from './db-poll.service';
import { Inject } from '@nestjs/common';
import { PollDocument } from '../../../schemas/poll.schema';
import { PollDocument } from '../../../../schemas/poll.schema';

export class PollService {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { SomeoneOnceSaidService } from '../service/someone-once-said.service';
import {
SomeoneOnceSaid,
SomeoneOnceSaidSchema,
} from '../../../schemas/someone-once-said.schema';
import { SomeoneOnceSaid, SomeoneOnceSaidSchema } from '../../../../schemas/someone-once-said.schema';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Model, Error, MongooseError } from 'mongoose';
import { SomeoneOnceSaidService } from './someone-once-said.service';
import { SomeoneOnceSaidEntity } from '../../../schemas/someone-once-said-entity.model';
import { SomeoneOnceSaidDocument } from '../../../schemas/someone-once-said.schema';
import { getModelToken } from '@nestjs/mongoose';
import { SomeoneOnceSaidDocument } from '../../../../schemas/someone-once-said.schema';
import { SomeoneOnceSaidEntity } from '../../../../schemas/someone-once-said-entity.model';
describe('SomeoneOnceSaidService', () => {
let service: SomeoneOnceSaidService;
let modelMock: Model<SomeoneOnceSaidDocument>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InjectModel } from '@nestjs/mongoose';
import { Model, Error } from 'mongoose';
import { SomeoneOnceSaidEntity } from '../../../schemas/someone-once-said-entity.model';
import { SomeoneOnceSaidDocument } from '../../../schemas/someone-once-said.schema';
import { Model } from 'mongoose';
import { SomeoneOnceSaidDocument } from '../../../../schemas/someone-once-said.schema';
import { SomeoneOnceSaidEntity } from '../../../../schemas/someone-once-said-entity.model';

export class SomeoneOnceSaidService {
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { ReS } from '../../../common/res.model';
import { VersionService } from '../service/version.service';
import { ReS } from '../../../../common/res.model';

@Controller('version')
@ApiTags('version')
Expand Down

0 comments on commit a7f86e7

Please sign in to comment.