Skip to content

Commit

Permalink
Merge pull request #290 from aXenDeveloper/blog/init
Browse files Browse the repository at this point in the history
feat(blog): Create blog plugin
  • Loading branch information
aXenDeveloper authored Mar 23, 2024
2 parents e4012e3 + a5dcce3 commit c79ea6c
Show file tree
Hide file tree
Showing 335 changed files with 829 additions and 831 deletions.
18 changes: 1 addition & 17 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
## Copy this file to .env and replace the values with your own
## Commented out values are optional

# General
# PORT=8080

# Tokens
LOGIN_TOKEN_SECRET=SECRET

# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=root
DB_PASSWORD=root
DB_NAME=vitnode

# Frontend
FRONTEND_URL=localhost
LOGIN_TOKEN_SECRET=SECRET
6 changes: 3 additions & 3 deletions backend/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { ServeStaticModule } from "@nestjs/serve-static";
import { ScheduleModule } from "@nestjs/schedule";
import { ConfigModule } from "@nestjs/config";

import { ModulesModule } from "./modules/modules.module";
import { PluginsModule } from "./plugins/plugins.module";
import { configuration } from "./configuration";

import { Ctx } from "@/types/context.type";
import { DatabaseModule } from "@/modules/database/database.module";
import { DatabaseModule } from "@/plugins/database/database.module";

@Module({
imports: [
Expand All @@ -30,7 +30,7 @@ import { DatabaseModule } from "@/modules/database/database.module";
context: ({ req, res }): Ctx => ({ req, res })
}),
JwtModule.register({ global: true }),
ModulesModule,
PluginsModule,
ServeStaticModule.forRoot({
rootPath: join(process.cwd(), "public"),
serveRoot: "/public"
Expand Down
2 changes: 1 addition & 1 deletion backend/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const drizzleEnvs = {
};

export default {
schema: "./modules/**/database/schema/*.ts",
schema: "./plugins/**/database/schema/*.ts",
out: "./drizzle",
driver: "pg",
dbCredentials: drizzleEnvs
Expand Down
10 changes: 5 additions & 5 deletions backend/functions/config/finish-build-config-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { migrate } from "drizzle-orm/node-postgres/migrator";
import { ConfigType, configPath, getConfigFile } from "./get-config-file";
import { updatePlugins } from "./update-plugins";

import { db } from "@/modules/database/client";
import { db } from "@/plugins/database/client";

(async () => {
// Update config file
Expand All @@ -27,25 +27,25 @@ import { db } from "@/modules/database/client";
await migrate(db, {
migrationsFolder: join(
process.cwd(),
"modules",
"plugins",
"core",
"admin",
"database",
"migrations"
)
});

fs.readdir(join(process.cwd(), "modules"), async (err, plugins) => {
fs.readdir(join(process.cwd(), "plugins"), async (err, plugins) => {
await Promise.all(
plugins
.filter(
plugin => !["database", "modules.module.ts", "core"].includes(plugin)
plugin => !["database", "plugins.module.ts", "core"].includes(plugin)
)
.map(async plugin => {
// Check if migration folder exists
const migrationPath = join(
process.cwd(),
"modules",
"plugins",
plugin,
"admin",
"database",
Expand Down
4 changes: 2 additions & 2 deletions backend/functions/config/get-config-file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from "path";
import * as fs from "fs";

import { PluginInfoJSONType } from "@/modules/core/admin/plugins/helpers/files/create/contents";
import { PluginInfoJSONType } from "@/plugins/core/admin/plugins/helpers/files/create/contents";

export interface ConfigType {
applications: string[];
Expand Down Expand Up @@ -30,7 +30,7 @@ export const getConfigFile = async () => {
};

export const getCoreInfo = async () => {
const path = join(process.cwd(), "modules", "core");
const path = join(process.cwd(), "plugins", "core");
const config = fs.readFileSync(join(path, "plugin.json"), "utf8");
const data: PluginInfoJSONType = JSON.parse(config);

Expand Down
16 changes: 8 additions & 8 deletions backend/functions/config/update-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import * as fs from "fs";
import { NodePgDatabase } from "drizzle-orm/node-postgres";
import { eq } from "drizzle-orm";

import { ConfigPlugin } from "@/modules/core/admin/plugins/plugins.module";
import { schemaDatabase } from "@/modules/database/schema";
import { ConfigPlugin } from "@/plugins/core/admin/plugins/plugins.module";
import { schemaDatabase } from "@/plugins/database/schema";
import {
core_plugins,
core_plugins_nav
} from "@/modules/core/admin/database/schema/plugins";
import { poolDB } from "@/modules/database/client";
} from "@/plugins/core/admin/database/schema/plugins";
import { poolDB } from "@/plugins/database/client";

export const updateNavAdminPlugin = async ({
config,
Expand Down Expand Up @@ -71,16 +71,16 @@ export const updatePlugins = async ({
}: {
db: NodePgDatabase<typeof schemaDatabase>;
}) => {
fs.readdir(join(process.cwd(), "modules"), async (err, plugins) => {
fs.readdir(join(process.cwd(), "plugins"), async (err, plugins) => {
await Promise.all(
plugins
.filter(
plugin => !["database", "modules.module.ts", "core"].includes(plugin)
plugin => !["database", "plugins.module.ts", "core"].includes(plugin)
)
.map(async (pluginName, index) => {
const configPath = join(
process.cwd(),
"modules",
"plugins",
pluginName,
"plugin.json"
);
Expand All @@ -89,7 +89,7 @@ export const updatePlugins = async ({
);
const versionsPath = join(
process.cwd(),
"modules",
"plugins",
pluginName,
"versions.json"
);
Expand Down
2 changes: 1 addition & 1 deletion backend/functions/database/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PgTableWithColumns, TableConfig } from "drizzle-orm/pg-core";

import { PageInfo } from "@/types/database/pagination.type";
import { CustomError } from "@/utils/errors/CustomError";
import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import { SortDirectionEnum } from "@/types/database/sortDirection.type";

type DataInterface<T> = T & {
Expand Down
18 changes: 9 additions & 9 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"db": "drizzle-kit push:pg",
"config:init": "ts-node ./functions/config/generate-config-file.ts",
"config:finish": "ts-node ./functions/config/finish-build-config-file.ts",
"migrate:forum": "drizzle-kit generate:pg --out modules/forum/admin/database/migrations --schema modules/forum/admin/database/schema/*.ts",
"migrate:admin": "drizzle-kit generate:pg --out modules/core/admin/database/migrations --schema modules/core/admin/database/schema/*.ts",
"migrate:forum": "drizzle-kit generate:pg --out plugins/forum/admin/database/migrations --schema plugins/forum/admin/database/schema/*.ts",
"migrate:admin": "drizzle-kit generate:pg --out plugins/core/admin/database/migrations --schema plugins/core/admin/database/schema/*.ts",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
Expand All @@ -33,28 +33,28 @@
"reflect-metadata": "^0.2.1",
"rxjs": "^7.8.1",
"socket.io": "^4.7.5",
"tar": "^6.2.0",
"tar": "^6.2.1",
"ua-parser-js": "^1.0.37"
},
"devDependencies": {
"@apollo/server": "^4.10.1",
"@apollo/server": "^4.10.2",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/typescript": "^4.0.6",
"@graphql-codegen/typescript-document-nodes": "^4.0.6",
"@graphql-codegen/typescript-operations": "^4.2.0",
"@nestjs/apollo": "^12.1.0",
"@nestjs/cli": "^10.3.2",
"@nestjs/common": "^10.3.4",
"@nestjs/common": "^10.3.5",
"@nestjs/config": "^3.2.0",
"@nestjs/core": "^10.3.4",
"@nestjs/core": "^10.3.5",
"@nestjs/graphql": "^12.1.1",
"@nestjs/jwt": "^10.2.0",
"@nestjs/platform-express": "^10.3.4",
"@nestjs/platform-socket.io": "^10.3.4",
"@nestjs/platform-express": "^10.3.5",
"@nestjs/platform-socket.io": "^10.3.5",
"@nestjs/schedule": "^4.0.1",
"@nestjs/schematics": "^10.1.1",
"@nestjs/serve-static": "^4.0.1",
"@nestjs/testing": "^10.3.4",
"@nestjs/testing": "^10.3.5",
"@types/archiver": "^6.0.2",
"@types/bcrypt": "^5.0.2",
"@types/busboy": "^1.5.3",
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/blog/admin/admin.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Module } from "@nestjs/common";

@Module({})
export class AdminBlogModule {}
1 change: 1 addition & 0 deletions backend/plugins/blog/admin/database/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
8 changes: 8 additions & 0 deletions backend/plugins/blog/blog.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Module } from "@nestjs/common";

import { AdminBlogModule } from "./admin/admin.module";

@Module({
imports: [AdminBlogModule]
})
export class BlogModule {}
10 changes: 10 additions & 0 deletions backend/plugins/blog/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Blog",
"description": "Turn your ideas into viral blog posts.",
"code": "blog",
"author": "VitNode",
"author_url": "https://vitnode.com/",
"support_url": "https://github.com/aXenDeveloper/vitnode/issues",
"allow_default": true,
"nav": []
}
1 change: 1 addition & 0 deletions backend/plugins/blog/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { resolve } from "path";

import { migrate } from "drizzle-orm/node-postgres/migrator";

import { db, poolDB } from "@/modules/database/client";
import { db, poolDB } from "@/plugins/database/client";

(async () => {
await migrate(db, { migrationsFolder: resolve(__dirname, "migrations") });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Injectable } from "@nestjs/common";
import { ShowAdminGroups } from "../show/dto/show.obj";
import { CreateAdminGroupsArgs } from "./dto/create.args";

import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import {
core_groups,
core_groups_names
} from "@/modules/core/admin/database/schema/groups";
} from "@/plugins/core/admin/database/schema/groups";

@Injectable()
export class CreateAdminGroupsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { eq } from "drizzle-orm";

import { DeleteAdminGroupsArgs } from "./dto/delete.args";

import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import { NotFoundError } from "@/utils/errors/not-found-error";
import { core_users } from "@/modules/core/admin/database/schema/users";
import { core_groups } from "@/modules/core/admin/database/schema/groups";
import { core_users } from "@/plugins/core/admin/database/schema/users";
import { core_groups } from "@/plugins/core/admin/database/schema/groups";

@Injectable()
export class DeleteAdminGroupsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { count, eq } from "drizzle-orm";
import { EditAdminGroupsArgs } from "./dto/edit.args";
import { ShowAdminGroups } from "../show/dto/show.obj";

import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import { NotFoundError } from "@/utils/errors/not-found-error";
import {
core_groups,
core_groups_names
} from "@/modules/core/admin/database/schema/groups";
import { core_users } from "@/modules/core/admin/database/schema/users";
} from "@/plugins/core/admin/database/schema/groups";
import { core_users } from "@/plugins/core/admin/database/schema/users";

@Injectable()
export class EditAdminGroupsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { and, count, eq, ilike, inArray } from "drizzle-orm";
import { ShowAdminGroupsArgs } from "./dto/show.args";
import { ShowAdminGroupsObj } from "./dto/show.obj";

import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import {
core_groups,
core_groups_names
} from "@/modules/core/admin/database/schema/groups";
} from "@/plugins/core/admin/database/schema/groups";
import {
inputPaginationCursor,
outputPagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { count } from "drizzle-orm";

import { CustomError } from "@/utils/errors/CustomError";
import { AccessDeniedError } from "@/utils/errors/AccessDeniedError";
import { DatabaseService } from "@/modules/database/database.service";
import { core_languages } from "@/modules/core/admin/database/schema/languages";
import { DatabaseService } from "@/plugins/database/database.service";
import { core_languages } from "@/plugins/core/admin/database/schema/languages";
import {
core_groups,
core_groups_names
} from "@/modules/core/admin/database/schema/groups";
import { core_admin_permissions } from "@/modules/core/admin/database/schema/admins";
} from "@/plugins/core/admin/database/schema/groups";
import { core_admin_permissions } from "@/plugins/core/admin/database/schema/admins";
import { core_moderators_permissions } from "../../database/schema/moderators";
import { core_themes } from "../../database/schema/themes";
import { core_nav, core_nav_name } from "../../database/schema/nav";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
} from "./dto/layout.obj";

import { AccessDeniedError } from "@/utils/errors/AccessDeniedError";
import { DatabaseService } from "@/modules/database/database.service";
import { core_users } from "@/modules/core/admin/database/schema/users";
import { core_sessions } from "@/modules/core/admin/database/schema/sessions";
import { core_admin_sessions } from "@/modules/core/admin/database/schema/admins";
import { core_languages } from "@/modules/core/admin/database/schema/languages";
import { DatabaseService } from "@/plugins/database/database.service";
import { core_users } from "@/plugins/core/admin/database/schema/users";
import { core_sessions } from "@/plugins/core/admin/database/schema/sessions";
import { core_admin_sessions } from "@/plugins/core/admin/database/schema/admins";
import { core_languages } from "@/plugins/core/admin/database/schema/languages";

@Injectable()
export class LayoutAdminInstallService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CreateAdminCoreLanguageService } from "./create.service";
import { CreateCoreAdminLanguagesArgs } from "./dto/create.args";

import { AdminAuthGuards } from "@/utils/guards/admin-auth.guard";
import { ShowCoreLanguages } from "@/modules/core/languages/show/dto/show.obj";
import { ShowCoreLanguages } from "@/plugins/core/languages/show/dto/show.obj";

@Resolver()
export class CreateAdminCoreLanguagesResolver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Injectable } from "@nestjs/common";

import { CreateCoreAdminLanguagesArgs } from "./dto/create.args";

import { DatabaseService } from "@/modules/database/database.service";
import { ShowCoreLanguages } from "@/modules/core/languages/show/dto/show.obj";
import { DatabaseService } from "@/plugins/database/database.service";
import { ShowCoreLanguages } from "@/plugins/core/languages/show/dto/show.obj";
import { CustomError } from "@/utils/errors/CustomError";
import { core_languages } from "../../database/schema/languages";
import { setRebuildRequired } from "@/functions/config/rebuild-required";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { eq } from "drizzle-orm";

import { DeleteCoreAdminLanguagesArgs } from "./dto/delete.args";

import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import { NotFoundError } from "@/utils/errors/not-found-error";
import { core_languages } from "../../database/schema/languages";
import { CustomError } from "@/utils/errors/CustomError";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as tar from "tar";
import { DownloadCoreAdminLanguagesArgs } from "./dto/download.args";

import { NotFoundError } from "@/utils/errors/not-found-error";
import { DatabaseService } from "@/modules/database/database.service";
import { DatabaseService } from "@/plugins/database/database.service";
import { removeSpecialCharacters } from "@/functions/remove-special-characters";
import { User } from "@/utils/decorators/user.decorator";
import { generateRandomString } from "@/functions/generate-random-string";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EditAdminCoreLanguagesService } from "./edit.service";
import { EditCoreAdminLanguagesArgs } from "./dto/edit.args";

import { AdminAuthGuards } from "@/utils/guards/admin-auth.guard";
import { ShowCoreLanguages } from "@/modules/core/languages/show/dto/show.obj";
import { ShowCoreLanguages } from "@/plugins/core/languages/show/dto/show.obj";

@Resolver()
export class EditAdminCoreLanguagesResolver {
Expand Down
Loading

0 comments on commit c79ea6c

Please sign in to comment.