Skip to content

Commit

Permalink
perf(backend): Move nav module into package
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Jun 21, 2024
1 parent 368b52c commit 1ecfbfe
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 43 deletions.
4 changes: 0 additions & 4 deletions apps/backend/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ type Mutation {
admin__core_main_settings__edit(site_copyright: [TextLanguageInput!]!, site_description: [TextLanguageInput!]!, site_name: String!, site_short_name: String!): EditAdminSettingsObj!
admin__core_manifest_metadata__edit(background_color: String!, display: String!, start_url: String!, theme_color: String!): ShowAdminManifestMetadataObj!
admin__core_members__edit(birthday: DateTime!, email: String!, first_name: String!, id: Int!, last_name: String!, name: String!, newsletter: Boolean!): EditAdminMembersObj!
admin__core_nav__change_position(id: Int!, index_to_move: Int!, parent_id: Int!): String!
admin__core_nav__create(description: [TextLanguageInput!]!, external: Boolean!, href: String!, icon: String, name: [TextLanguageInput!]!): ShowCoreNav!
admin__core_nav__delete(id: Int!): String!
admin__core_nav__edit(description: [TextLanguageInput!]!, external: Boolean!, href: String!, icon: String, id: Int!, name: [TextLanguageInput!]!): ShowCoreNav!
admin__core_plugins__create(author: String!, author_url: String, code: String!, description: String, name: String!, support_url: String!): ShowAdminPlugins!
admin__core_plugins__delete(code: String!): String!
admin__core_plugins__download(code: String!, version: String, version_code: Int): String!
Expand Down
4 changes: 3 additions & 1 deletion apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { VitNodeCoreModule } from "vitnode-backend";

import { PluginsModule } from "./plugins/plugins.module";
import { DATABASE_ENVS } from "./database/client";
import { schemaDatabase } from "./database/schema";

@Module({
imports: [
Expand All @@ -13,7 +14,8 @@ import { DATABASE_ENVS } from "./database/client";
envFile: join(process.cwd(), "..", "..", ".env")
},
database: {
config: DATABASE_ENVS
config: DATABASE_ENVS,
schemaDatabase
}
}),
PluginsModule
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/plugins/core/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AdminFilesModule } from "./files/files.module";
import { AdminGroupsModule } from "./groups/groups.module";
import { AdminLanguagesModule } from "./languages/languages.module";
import { AdminMembersModule } from "./members/members.module";
import { AdminNavModule } from "./nav/nav.module";
// import { AdminNavModule } from "./nav/nav.module";
import { AdminStaffModule } from "./staff/staff.module";
import { AdminThemeEditorModule } from "./theme_editor/theme_editor.module";
import { AdminEmailModule } from "./email/email.module";
Expand All @@ -29,7 +29,7 @@ import { AdminEmailModule } from "./email/email.module";
AdminGroupsModule,
AdminLanguagesModule,
AdminMembersModule,
AdminNavModule,
// AdminNavModule,
AdminStaffModule,
AdminThemeEditorModule,
AdminEmailModule
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/plugins/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { GlobalCoreHelpersModule } from "./helpers/helpers.module";
import { CoreLanguagesModule } from "./languages/languages.module";
import { CoreMembersModule } from "./members/members.module";
import { CoreMiddlewareModule } from "./middleware/middleware.module";
import { CoreNavModule } from "./nav/nav.module";
import { CorePluginsModule } from "./plugins/plugins.module";
import { CoreThemeEditorModule } from "./theme_editor/theme_editor.module";

Expand All @@ -29,7 +28,6 @@ import { CoreThemeEditorModule } from "./theme_editor/theme_editor.module";
CoreLanguagesModule,
CoreMembersModule,
CoreMiddlewareModule,
CoreNavModule,
CorePluginsModule,
CoreThemeEditorModule
]
Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/object-path": "^0.11.4",
"@types/pg": "^8.11.6",
"busboy": "^1.6.0",
"class-transformer": "^0.5.1",
"eslint-config-vitnode": "workspace:*",
"http-errors": "^2.0.0",
"object-path": "^0.11.8",
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/core/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Module } from "@nestjs/common";

import { CoreNavModule } from "./nav/nav.module";

@Module({
imports: []
imports: [CoreNavModule]
})
export class CoreModule {}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ArgsType } from "@nestjs/graphql";
import { PaginationArgs } from "vitnode-backend";

import { PaginationArgs } from "../../../../utils";

@ArgsType()
export class ShowCoreNavArgs extends PaginationArgs {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Field, Int, ObjectType } from "@nestjs/graphql";
import { PageInfo, TextLanguage } from "vitnode-backend";

import { PageInfo, TextLanguage } from "../../../../utils";

@ObjectType()
class ShowCoreNavItem {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { Injectable } from "@nestjs/common";
import { and, count, eq } from "drizzle-orm";
import {
inputPaginationCursor,
outputPagination,
SortDirectionEnum,
DatabaseService
} from "vitnode-backend";

import { ShowCoreNavArgs } from "./dto/show.args";
import { ShowCoreNavObj } from "./dto/show.obj";

Check warning on line 5 in packages/backend/src/core/nav/show/show.service.ts

View workflow job for this annotation

GitHub Actions / install

There should be at least one empty line between import groups

import { core_nav } from "@/plugins/core/admin/database/schema/nav";
import { DatabaseService } from "../../../database";
import { inputPaginationCursor, outputPagination } from "../../../functions";
import { core_nav } from "../../../templates/core/admin/database/schema/nav";
import { SortDirectionEnum } from "../../../utils";

@Injectable()
export class ShowCoreNavService {
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/database/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ registerEnumType(SortDirectionEnum, {

export interface DatabaseModuleArgs {
config: PoolConfig;
schemaDatabase: Record<string, unknown>;
}

@Global()
Expand Down
5 changes: 2 additions & 3 deletions packages/backend/src/database/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { NodePgDatabase } from "drizzle-orm/node-postgres";

import { DatabaseModuleArgs } from "./database.module";
import { createClientDatabase } from "./client";

import coreSchemaDatabase from "@/templates/core/admin/database";
import coreSchemaDatabase from "../templates/core/admin/database";

@Injectable()
export class DatabaseService {
Expand All @@ -15,7 +14,7 @@ export class DatabaseService {
private readonly options: DatabaseModuleArgs
) {
const client = createClientDatabase({
schemaDatabase: {},
schemaDatabase: this.options.schemaDatabase,
config: this.options.config
});

Expand Down
4 changes: 1 addition & 3 deletions packages/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"declaration": true,
"experimentalDecorators": true,
"strictNullChecks": false,
"paths": {
"@/*": ["./src/*"]
}
"emitDecoratorMetadata": true
},
"include": ["src/**/*"]
}
35 changes: 18 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ecfbfe

Please sign in to comment.