Skip to content

Commit

Permalink
Add webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Nov 13, 2023
1 parent 95f749b commit e8b4c5b
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
bin/
dist/
lib/
node_modules/

src/migrations

*.DS_Store
Expand Down
25 changes: 6 additions & 19 deletions docs/ERD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`:
> Sequence order of the attached file in the belonged snapshot.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/api/functional/monitors/health/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 5 additions & 5 deletions src/api/functional/monitors/performance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -22,7 +22,7 @@ export async function get(
? get.simulate(
connection,
)
: EncryptedFetcher.fetch(
: PlainFetcher.fetch(
connection,
{
...get.METADATA,
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/api/functional/monitors/system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/monitors/MonitorHealthController.ts
Original file line number Diff line number Diff line change
@@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/monitors/MonitorPerformanceController.ts
Original file line number Diff line number Diff line change
@@ -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<IPerformance> {
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/monitors/MonitorSystemController.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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";

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<ISystem> {
Expand Down
2 changes: 1 addition & 1 deletion src/executable/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/modules/fastify.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/modules/nestjs.ts

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
80 changes: 80 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -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;
},
}),
],
};

0 comments on commit e8b4c5b

Please sign in to comment.