diff --git a/.gitignore b/.gitignore index d113fa2..8a0b530 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ bin/ +dist/ lib/ node_modules/ + src/migrations *.DS_Store diff --git a/docs/ERD.md b/docs/ERD.md index 5973686..caea263 100644 --- a/docs/ERD.md +++ b/docs/ERD.md @@ -53,20 +53,14 @@ erDiagram String attachment_file_id FK Int sequence } -"_bbs_article_commentsTobbs_article_comments" { - String A FK - String B FK -} "bbs_article_snapshots" }|--|| "bbs_articles" : article -"bbs_article_snapshot_files" }|--|| "bbs_article_snapshots" : snapshot -"bbs_article_snapshot_files" }|--|| "attachment_files" : file -"bbs_article_comments" }|--|| "bbs_articles" : article +"bbs_article_snapshot_files" }o--|| "bbs_article_snapshots" : snapshot +"bbs_article_snapshot_files" }o--|| "attachment_files" : file +"bbs_article_comments" }o--|| "bbs_articles" : article "bbs_article_comments" }o--o| "bbs_article_comments" : parent "bbs_article_comment_snapshots" }|--|| "bbs_article_comments" : comment -"bbs_article_comment_snapshot_files" }|--|| "bbs_article_comment_snapshots" : snapshot -"bbs_article_comment_snapshot_files" }|--|| "attachment_files" : file -"_bbs_article_commentsTobbs_article_comments" }|--|| "bbs_article_comments" : bbs_article_comments -"_bbs_article_commentsTobbs_article_comments" }|--|| "bbs_article_comments" : bbs_article_comments +"bbs_article_comment_snapshot_files" }o--|| "bbs_article_comment_snapshots" : snapshot +"bbs_article_comment_snapshot_files" }o--|| "attachment_files" : file ``` ### `attachment_files` @@ -226,11 +220,4 @@ relationship between [bbs_article_comment_snapshots](#bbs_article_comment_snapsh - `sequence` > Sequence order. > - > Sequence order of the attached file in the belonged snapshot. - -### `_bbs_article_commentsTobbs_article_comments` -Pair relationship table between [bbs_article_comments](#bbs_article_comments) and [bbs_article_comments](#bbs_article_comments) - -**Properties** - - `A`: - - `B`: \ No newline at end of file + > Sequence order of the attached file in the belonged snapshot. \ No newline at end of file diff --git a/package.json b/package.json index 2556314..c9869e1 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "package:models": "npm run build:models && cd packags/models && npm publish", "prepare": "ts-patch install && npm run build:prisma", "prettier": "prettier src --write && prettier test --write", + "webpack": "webpack", "-----------------------------------------------": "", "reset-for-debugging": "npm run test -- --reset true --include __nothing__", "test": "node bin/test", @@ -63,21 +64,30 @@ "@typescript-eslint/parser": "^5.26.0", "chalk": "^4.1.2", "cli": "^1.0.1", + "copy-webpack-plugin": "^11.0.0", "eslint-plugin-deprecation": "^1.4.1", "inquirer": "^8.2.5", "nestia": "^5.0.2", "pm2": "^4.5.6", "prettier": "^2.6.2", - "prisma-markdown": "^1.0.1", + "prettier-plugin-prisma": "^5.0.0", + "prisma-markdown": "^1.0.7", "rimraf": "^3.0.2", "sloc": "^0.2.1", + "ts-loader": "^9.5.0", "ts-node": "^10.9.1", "ts-patch": "^3.0.2", "typescript": "^5.2.2", - "typescript-transform-paths": "^3.4.6" + "typescript-transform-paths": "^3.4.6", + "webpack": "^5.89.0", + "webpack-cli": "^5.1.4", + "write-file-webpack-plugin": "^4.5.1" }, "dependencies": { "@nestia/core": "^2.3.9", + "@nestjs/common": "^10.2.8", + "@nestjs/core": "^10.2.8", + "@nestjs/platform-fastify": "^10.2.8", "@prisma/client": "^5.3.1", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/src/api/functional/monitors/health/index.ts b/src/api/functional/monitors/health/index.ts index d5510b4..c6a7258 100644 --- a/src/api/functional/monitors/health/index.ts +++ b/src/api/functional/monitors/health/index.ts @@ -8,7 +8,7 @@ import type { IConnection } from "@nestia/fetcher"; import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher"; /** - * @controller HealthController.get + * @controller MonitorHealthController.get * @path GET /monitors/health * @nestia Generated by Nestia - https://github.com/samchon/nestia */ diff --git a/src/api/functional/monitors/performance/index.ts b/src/api/functional/monitors/performance/index.ts index 6efe697..9c28eb5 100644 --- a/src/api/functional/monitors/performance/index.ts +++ b/src/api/functional/monitors/performance/index.ts @@ -5,13 +5,13 @@ */ //================================================================ import type { IConnection, Primitive } from "@nestia/fetcher"; -import { EncryptedFetcher } from "@nestia/fetcher/lib/EncryptedFetcher"; +import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher"; import typia from "typia"; import type { IPerformance } from "../../../structures/monitors/IPerformance"; /** - * @controller PerformanceController.get + * @controller MonitorPerformanceController.get * @path GET /monitors/performance * @nestia Generated by Nestia - https://github.com/samchon/nestia */ @@ -22,7 +22,7 @@ export async function get( ? get.simulate( connection, ) - : EncryptedFetcher.fetch( + : PlainFetcher.fetch( connection, { ...get.METADATA, @@ -38,8 +38,8 @@ export namespace get { path: "/monitors/performance", request: null, response: { - type: "text/plain", - encrypted: true, + type: "application/json", + encrypted: false, }, status: null, } as const; diff --git a/src/api/functional/monitors/system/index.ts b/src/api/functional/monitors/system/index.ts index f7fbc7a..c48128d 100644 --- a/src/api/functional/monitors/system/index.ts +++ b/src/api/functional/monitors/system/index.ts @@ -11,7 +11,7 @@ import typia from "typia"; import type { ISystem } from "../../../structures/monitors/ISystem"; /** - * @controller SystemController.get + * @controller MonitorSystemController.get * @path GET /monitors/system * @nestia Generated by Nestia - https://github.com/samchon/nestia */ @@ -65,7 +65,7 @@ export namespace get { * * @internal * - * @controller SystemController.internal_server_error + * @controller MonitorSystemController.internal_server_error * @path GET /monitors/system/internal_server_error * @nestia Generated by Nestia - https://github.com/samchon/nestia */ @@ -110,7 +110,7 @@ export namespace internal_server_error { * * @internal * - * @controller SystemController.uncaught_exception + * @controller MonitorSystemController.uncaught_exception * @path GET /monitors/system/uncaught_exception * @nestia Generated by Nestia - https://github.com/samchon/nestia */ diff --git a/src/controllers/monitors/MonitorHealthController.ts b/src/controllers/monitors/MonitorHealthController.ts index a533479..188efe5 100644 --- a/src/controllers/monitors/MonitorHealthController.ts +++ b/src/controllers/monitors/MonitorHealthController.ts @@ -1,7 +1,7 @@ -import nest from "@modules/nestjs"; import core from "@nestia/core"; +import { Controller } from "@nestjs/common"; -@nest.Controller("monitors/health") +@Controller("monitors/health") export class MonitorHealthController { @core.TypedRoute.Get() public get(): void {} diff --git a/src/controllers/monitors/MonitorPerformanceController.ts b/src/controllers/monitors/MonitorPerformanceController.ts index 4284b3a..115e08c 100644 --- a/src/controllers/monitors/MonitorPerformanceController.ts +++ b/src/controllers/monitors/MonitorPerformanceController.ts @@ -1,9 +1,9 @@ -import nest from "@modules/nestjs"; import core from "@nestia/core"; +import { Controller } from "@nestjs/common"; import { IPerformance } from "@ORGANIZATION/PROJECT-api/lib/structures/monitors/IPerformance"; -@nest.Controller("monitors/performance") +@Controller("monitors/performance") export class MonitorPerformanceController { @core.TypedRoute.Get() public async get(): Promise { diff --git a/src/controllers/monitors/MonitorSystemController.ts b/src/controllers/monitors/MonitorSystemController.ts index e8a9a62..8808911 100644 --- a/src/controllers/monitors/MonitorSystemController.ts +++ b/src/controllers/monitors/MonitorSystemController.ts @@ -1,5 +1,5 @@ -import nest from "@modules/nestjs"; import core from "@nestia/core"; +import { Controller } from "@nestjs/common"; import { ISystem } from "@ORGANIZATION/PROJECT-api/lib/structures/monitors/ISystem"; @@ -7,7 +7,7 @@ import { SystemProvider } from "../../providers/monitors/SystemProvider"; import { DateUtil } from "../../utils/DateUtil"; -@nest.Controller("monitors/system") +@Controller("monitors/system") export class MonitorSystemController { @core.TypedRoute.Get() public async get(): Promise { diff --git a/src/executable/server.ts b/src/executable/server.ts index cc402e4..2d9b286 100644 --- a/src/executable/server.ts +++ b/src/executable/server.ts @@ -5,7 +5,7 @@ import { Singleton } from "tstl/thread/Singleton"; import { MyBackend } from "../MyBackend"; import { MyGlobal } from "../MyGlobal"; import { MyUpdator } from "../MyUpdator"; -import { MyScheduler } from "../schedulers/MScheduler"; +import { MyScheduler } from "../schedulers/MyScheduler"; import { ErrorUtil } from "../utils/ErrorUtil"; const EXTENSION = __filename.substr(-2); diff --git a/src/modules/fastify.ts b/src/modules/fastify.ts deleted file mode 100644 index 2c32f6f..0000000 --- a/src/modules/fastify.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as fastify from "fastify"; - -export default fastify; diff --git a/src/modules/nestjs.ts b/src/modules/nestjs.ts deleted file mode 100644 index b375de2..0000000 --- a/src/modules/nestjs.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as nest from "@nestjs/common"; - -export default nest; diff --git a/src/schedulers/MScheduler.ts b/src/schedulers/MyScheduler.ts similarity index 100% rename from src/schedulers/MScheduler.ts rename to src/schedulers/MyScheduler.ts diff --git a/tsconfig.json b/tsconfig.json index 915d52e..52599fa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -41,7 +41,6 @@ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ "paths": { - "@modules/*": ["./src/modules/*"], "@ORGANIZATION/PROJECT-models/lib/*": ["./src/models/*"], "@ORGANIZATION/PROJECT-api/lib/*": ["./src/api/*"], "@ORGANIZATION/PROJECT-api/lib/": ["./src/api"], diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..2feed63 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,80 @@ +const path = require("path"); + +const CopyWebpackPlugin = require("copy-webpack-plugin"); +const WriteFilePlugin = require("write-file-webpack-plugin"); +const { IgnorePlugin } = require("webpack"); + +const lazyImports = [ + "@fastify/static", + "@fastify/view", + "@nestjs/microservices", + "@nestjs/websockets", + "class-transformer", + "class-validator", +]; + +// @reference https://tech-blog.s-yoshiki.com/entry/297 +module.exports = { + // CUSTOMIZE HERE + entry: { + server: "./src/executable/server.ts", + "updator-master": "./src/executable/updator-master.ts", + "updator-slave": "./src/executable/updator-slave.ts", + }, + output: { + path: path.join(__dirname, "dist"), + filename: "[name].js", + }, + optimization: { + minimize: true, + }, + + // JUST KEEP THEM + mode: "production", + target: "node", + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + loader: "ts-loader", + }, + ], + }, + resolve: { + extensions: [".tsx", ".ts", ".js"], + }, + plugins: [ + new CopyWebpackPlugin({ + patterns: [ + { + from: ".env", + to: ".env", + }, + { + from: "./src/schema.prisma", + to: "./schema.prisma", + }, + { + from: "./node_modules/.prisma/client/*.node", + to({ context, absoluteFilename }) { + return Promise.resolve("[name][ext]"); + }, + }, + ], + }), + new WriteFilePlugin(), + new IgnorePlugin({ + checkResource(resource) { + if (lazyImports.some((modulo) => resource.startsWith(modulo))) { + try { + require.resolve(resource); + } catch (err) { + return true; + } + } + return false; + }, + }), + ], +};