nestia 3.1.1 → 3.1.2-dev.20221016
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -17
- package/lib/executable/internal/NestiaStarter.js +10 -26
- package/lib/executable/internal/NestiaStarter.js.map +1 -1
- package/package.json +2 -2
- package/template/.eslintrc.cjs +0 -22
- package/template/.github/workflows/build.yml +0 -18
- package/template/.prettierignore +0 -6
- package/template/.vscode/launch.json +0 -19
- package/template/.vscode/settings.json +0 -10
- package/template/LICENSE +0 -21
- package/template/README.md +0 -131
- package/template/bundle/gitignore +0 -6
- package/template/bundle/npmignore +0 -6
- package/template/nestia.config.ts +0 -12
- package/template/package.json +0 -62
- package/template/packages/api/LICENSE +0 -21
- package/template/packages/api/README.md +0 -66
- package/template/packages/api/package.json +0 -21
- package/template/prettier.config.js +0 -18
- package/template/src/Backend.ts +0 -65
- package/template/src/Configuration.ts +0 -11
- package/template/src/api/HttpError.ts +0 -1
- package/template/src/api/IConnection.ts +0 -1
- package/template/src/api/Primitive.ts +0 -1
- package/template/src/api/__internal/AesPkcs5.ts +0 -1
- package/template/src/api/__internal/Fetcher.ts +0 -1
- package/template/src/api/functional/bbs/articles/index.ts +0 -166
- package/template/src/api/functional/bbs/index.ts +0 -7
- package/template/src/api/functional/index.ts +0 -7
- package/template/src/api/index.ts +0 -4
- package/template/src/api/module.ts +0 -5
- package/template/src/api/structures/bbs/IBbsArticle.ts +0 -142
- package/template/src/api/structures/common/IAttachmentFile.ts +0 -5
- package/template/src/api/structures/common/IPage.ts +0 -75
- package/template/src/controllers/BbsArticlesController.ts +0 -46
- package/template/src/providers/bbs/BbsArticleProvider.ts +0 -217
- package/template/src/test/features/api/bbs/test_api_bbs_article_at.ts +0 -52
- package/template/src/test/features/api/bbs/test_api_bbs_article_index_search.ts +0 -82
- package/template/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts +0 -49
- package/template/src/test/features/api/bbs/test_api_bbs_article_store.ts +0 -44
- package/template/src/test/features/api/bbs/test_api_bbs_article_update.ts +0 -66
- package/template/src/test/index.ts +0 -45
- package/template/src/test/internal/DynamicImportIterator.ts +0 -119
- package/template/src/test/internal/GaffComparator.ts +0 -48
- package/template/src/test/internal/IPointer.ts +0 -3
- package/template/src/test/internal/RandomGenerator.ts +0 -72
- package/template/src/test/internal/StopWatch.ts +0 -16
- package/template/src/test/internal/exception_must_be_thrown.ts +0 -11
- package/template/src/test/internal/validate_index.ts +0 -29
- package/template/src/test/internal/validate_index_sort.ts +0 -39
- package/template/src/utils/ArrayUtil.ts +0 -86
- package/template/src/utils/MapUtil.ts +0 -14
- package/template/tsconfig.api.json +0 -15
- package/template/tsconfig.json +0 -118
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 ORGANIZATION
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# SDK for Client Developers
|
|
2
|
-
## Outline
|
|
3
|
-
[`@ORGANIZATION/PROJECT`](https://github.com/samchon/nestia-template) provides SDK (Software Development Kit) for convenience.
|
|
4
|
-
|
|
5
|
-
For the client developers who are connecting to this backend server, [`@ORGANIZATION/PROJECT`](https://github.com/samchon/nestia-template) provides not API documents like the Swagger, but provides the API interaction library, one of the typical SDK (Software Development Kit) for the convenience.
|
|
6
|
-
|
|
7
|
-
With the SDK, client developers never need to re-define the duplicated API interfaces. Just utilize the provided interfaces and asynchronous functions defined in the SDK. It would be much convenient than any other Rest API solutions.
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install --save @ORGANIZATION/PROJECT-api
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
Import the `@ORGANIZATION/PROJECT-api` and enjoy the auto-completion.
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import api from "@ORGINIZATION/PROJECT-api";
|
|
21
|
-
|
|
22
|
-
import { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/bbs/IBbsArticle";
|
|
23
|
-
|
|
24
|
-
async function main(): Promise<void>
|
|
25
|
-
{
|
|
26
|
-
//----
|
|
27
|
-
// PREPARATIONS
|
|
28
|
-
//----
|
|
29
|
-
// CONNECTION INFO
|
|
30
|
-
const connection: api.IConnection = {
|
|
31
|
-
host: "http://127.0.0.1:37001",
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const article: IBbsArticle = await api.functional.bbs.articles.store(
|
|
35
|
-
connection,
|
|
36
|
-
"general",
|
|
37
|
-
{
|
|
38
|
-
writer: "Robot",
|
|
39
|
-
title: "Hello, world!",
|
|
40
|
-
body: "Hello, I'm test automation robot",
|
|
41
|
-
format: "txt",
|
|
42
|
-
files: [
|
|
43
|
-
{
|
|
44
|
-
name: "logo",
|
|
45
|
-
extension: "png",
|
|
46
|
-
url: "https://somewhere.com/logo.png",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
password: "1234",
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
TSON.assertEquals(stored);
|
|
53
|
-
|
|
54
|
-
const page: IPage<IBbsArticle> = await api.functional.bbs.articles.index(
|
|
55
|
-
connection,
|
|
56
|
-
"general",
|
|
57
|
-
{
|
|
58
|
-
limit: 100,
|
|
59
|
-
search: {
|
|
60
|
-
writer: "Robot"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
await TSON.assertEquals(page);
|
|
65
|
-
}
|
|
66
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ORGANIZATION/PROJECT-api",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "API for PROJECT",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"typings": "lib/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/samchon/nestia-template"
|
|
10
|
-
},
|
|
11
|
-
"author": "AUTHOR",
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/samchon/nestia-template/issues"
|
|
15
|
-
},
|
|
16
|
-
"homepage": "https://github.com/samchon/nestia-template#readme",
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"nestia-fetcher": "^2.0.3",
|
|
19
|
-
"typescript-json": "^3.3.10"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: "typescript",
|
|
3
|
-
printWidth: 80,
|
|
4
|
-
semi: true,
|
|
5
|
-
tabWidth: 4,
|
|
6
|
-
trailingComma: "all",
|
|
7
|
-
importOrder: [
|
|
8
|
-
"<THIRD_PARTY_MODULES>",
|
|
9
|
-
"^@ORGANIZATION/PROJECT-api(.*)$",
|
|
10
|
-
"^[./]"
|
|
11
|
-
],
|
|
12
|
-
importOrderSeparation: true,
|
|
13
|
-
importOrderSortSpecifiers: true,
|
|
14
|
-
importOrderParserPlugins: [
|
|
15
|
-
"decorators-legacy",
|
|
16
|
-
"typescript",
|
|
17
|
-
]
|
|
18
|
-
};
|
package/template/src/Backend.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { INestApplication } from "@nestjs/common";
|
|
2
|
-
import { NestFactory } from "@nestjs/core";
|
|
3
|
-
import express from "express";
|
|
4
|
-
import helper from "nestia-helper";
|
|
5
|
-
|
|
6
|
-
import { Configuration } from "./Configuration";
|
|
7
|
-
|
|
8
|
-
export class Backend {
|
|
9
|
-
private application_?: INestApplication;
|
|
10
|
-
private is_closing_: boolean = false;
|
|
11
|
-
|
|
12
|
-
public async open(): Promise<void> {
|
|
13
|
-
//----
|
|
14
|
-
// OPEN THE BACKEND SERVER
|
|
15
|
-
//----
|
|
16
|
-
// MOUNT CONTROLLERS
|
|
17
|
-
this.application_ = await NestFactory.create(
|
|
18
|
-
await helper.EncryptedModule.dynamic(
|
|
19
|
-
__dirname + "/controllers",
|
|
20
|
-
await Configuration.ENCRYPTION_PASSWORD(),
|
|
21
|
-
),
|
|
22
|
-
{ logger: false },
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
// CONFIGURATIONS
|
|
26
|
-
this.is_closing_ = false;
|
|
27
|
-
this.application_.enableCors();
|
|
28
|
-
this.application_.use(this.middleware.bind(this));
|
|
29
|
-
|
|
30
|
-
// DO OPEN
|
|
31
|
-
await this.application_.listen(await Configuration.API_PORT());
|
|
32
|
-
|
|
33
|
-
//----
|
|
34
|
-
// POST-PROCESSES
|
|
35
|
-
//----
|
|
36
|
-
// INFORM TO THE PM2
|
|
37
|
-
if (process.send) process.send("ready");
|
|
38
|
-
|
|
39
|
-
// WHEN KILL COMMAND COMES
|
|
40
|
-
process.on("SIGINT", async () => {
|
|
41
|
-
this.is_closing_ = true;
|
|
42
|
-
await this.close();
|
|
43
|
-
process.exit(0);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public async close(): Promise<void> {
|
|
48
|
-
if (this.application_ === undefined) return;
|
|
49
|
-
|
|
50
|
-
// DO CLOSE
|
|
51
|
-
await this.application_.close();
|
|
52
|
-
delete this.application_;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private middleware(
|
|
56
|
-
_request: express.Request,
|
|
57
|
-
response: express.Response,
|
|
58
|
-
next: FunctionLike,
|
|
59
|
-
): void {
|
|
60
|
-
if (this.is_closing_ === true) response.set("Connection", "close");
|
|
61
|
-
next();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
type FunctionLike = (...args: any[]) => any;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IEncryptionPassword } from "nestia-fetcher";
|
|
2
|
-
|
|
3
|
-
export namespace Configuration {
|
|
4
|
-
export const API_PORT = async () => 37001;
|
|
5
|
-
export const ENCRYPTION_PASSWORD = async (): Promise<
|
|
6
|
-
Readonly<IEncryptionPassword>
|
|
7
|
-
> => ({
|
|
8
|
-
key: "pJXhbHlYfzkC1CBK8R67faaBgJWB9Myu",
|
|
9
|
-
iv: "IXJBt4MflFxvxKkn",
|
|
10
|
-
});
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { HttpError } from "nestia-fetcher";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { IConnection } from "nestia-fetcher";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Primitive } from "nestia-fetcher";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AesPkcs5 } from "nestia-fetcher";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Fetcher } from "nestia-fetcher";
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
* @module api.functional.bbs.articles
|
|
4
|
-
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
5
|
-
*/
|
|
6
|
-
//================================================================
|
|
7
|
-
import { Fetcher } from "nestia-fetcher";
|
|
8
|
-
import type { IConnection } from "nestia-fetcher";
|
|
9
|
-
|
|
10
|
-
import type { IBbsArticle } from "./../../../structures/bbs/IBbsArticle";
|
|
11
|
-
import type { IPage } from "./../../../structures/common/IPage";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @controller BbsArticlesController.index()
|
|
15
|
-
* @path PATCH /bbs/articles/:section
|
|
16
|
-
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
17
|
-
*/
|
|
18
|
-
export function index
|
|
19
|
-
(
|
|
20
|
-
connection: IConnection,
|
|
21
|
-
section: string,
|
|
22
|
-
input: IBbsArticle.IRequest
|
|
23
|
-
): Promise<index.Output>
|
|
24
|
-
{
|
|
25
|
-
return Fetcher.fetch
|
|
26
|
-
(
|
|
27
|
-
connection,
|
|
28
|
-
index.ENCRYPTED,
|
|
29
|
-
index.METHOD,
|
|
30
|
-
index.path(section),
|
|
31
|
-
input
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
export namespace index
|
|
35
|
-
{
|
|
36
|
-
export type Input = IBbsArticle.IRequest;
|
|
37
|
-
export type Output = IPage<IBbsArticle.ISummary>;
|
|
38
|
-
|
|
39
|
-
export const METHOD = "PATCH" as const;
|
|
40
|
-
export const PATH: string = "/bbs/articles/:section";
|
|
41
|
-
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
42
|
-
request: false,
|
|
43
|
-
response: true,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export function path(section: string): string
|
|
47
|
-
{
|
|
48
|
-
return `/bbs/articles/${encodeURIComponent(section)}`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @controller BbsArticlesController.at()
|
|
54
|
-
* @path GET /bbs/articles/:section/:id
|
|
55
|
-
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
56
|
-
*/
|
|
57
|
-
export function at
|
|
58
|
-
(
|
|
59
|
-
connection: IConnection,
|
|
60
|
-
section: string,
|
|
61
|
-
id: string
|
|
62
|
-
): Promise<at.Output>
|
|
63
|
-
{
|
|
64
|
-
return Fetcher.fetch
|
|
65
|
-
(
|
|
66
|
-
connection,
|
|
67
|
-
at.ENCRYPTED,
|
|
68
|
-
at.METHOD,
|
|
69
|
-
at.path(section, id)
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
export namespace at
|
|
73
|
-
{
|
|
74
|
-
export type Output = IBbsArticle;
|
|
75
|
-
|
|
76
|
-
export const METHOD = "GET" as const;
|
|
77
|
-
export const PATH: string = "/bbs/articles/:section/:id";
|
|
78
|
-
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
79
|
-
request: false,
|
|
80
|
-
response: false,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export function path(section: string, id: string): string
|
|
84
|
-
{
|
|
85
|
-
return `/bbs/articles/${encodeURIComponent(section)}/${encodeURIComponent(id)}`;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @controller BbsArticlesController.store()
|
|
91
|
-
* @path POST /bbs/articles/:section
|
|
92
|
-
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
93
|
-
*/
|
|
94
|
-
export function store
|
|
95
|
-
(
|
|
96
|
-
connection: IConnection,
|
|
97
|
-
section: string,
|
|
98
|
-
input: IBbsArticle.IStore
|
|
99
|
-
): Promise<store.Output>
|
|
100
|
-
{
|
|
101
|
-
return Fetcher.fetch
|
|
102
|
-
(
|
|
103
|
-
connection,
|
|
104
|
-
store.ENCRYPTED,
|
|
105
|
-
store.METHOD,
|
|
106
|
-
store.path(section),
|
|
107
|
-
input
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
export namespace store
|
|
111
|
-
{
|
|
112
|
-
export type Input = IBbsArticle.IStore;
|
|
113
|
-
export type Output = IBbsArticle;
|
|
114
|
-
|
|
115
|
-
export const METHOD = "POST" as const;
|
|
116
|
-
export const PATH: string = "/bbs/articles/:section";
|
|
117
|
-
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
118
|
-
request: false,
|
|
119
|
-
response: false,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export function path(section: string): string
|
|
123
|
-
{
|
|
124
|
-
return `/bbs/articles/${encodeURIComponent(section)}`;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @controller BbsArticlesController.update()
|
|
130
|
-
* @path PUT /bbs/articles/:section/:id
|
|
131
|
-
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
132
|
-
*/
|
|
133
|
-
export function update
|
|
134
|
-
(
|
|
135
|
-
connection: IConnection,
|
|
136
|
-
section: string,
|
|
137
|
-
id: string,
|
|
138
|
-
input: IBbsArticle.IUpdate
|
|
139
|
-
): Promise<update.Output>
|
|
140
|
-
{
|
|
141
|
-
return Fetcher.fetch
|
|
142
|
-
(
|
|
143
|
-
connection,
|
|
144
|
-
update.ENCRYPTED,
|
|
145
|
-
update.METHOD,
|
|
146
|
-
update.path(section, id),
|
|
147
|
-
input
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
export namespace update
|
|
151
|
-
{
|
|
152
|
-
export type Input = IBbsArticle.IUpdate;
|
|
153
|
-
export type Output = IBbsArticle.IContent;
|
|
154
|
-
|
|
155
|
-
export const METHOD = "PUT" as const;
|
|
156
|
-
export const PATH: string = "/bbs/articles/:section/:id";
|
|
157
|
-
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
158
|
-
request: false,
|
|
159
|
-
response: false,
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export function path(section: string, id: string): string
|
|
163
|
-
{
|
|
164
|
-
return `/bbs/articles/${encodeURIComponent(section)}/${encodeURIComponent(id)}`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { IAttachmentFile } from "../common/IAttachmentFile";
|
|
2
|
-
import { IPage } from "../common/IPage";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* BBS article.
|
|
6
|
-
*/
|
|
7
|
-
export interface IBbsArticle {
|
|
8
|
-
/**
|
|
9
|
-
* Primary Key.
|
|
10
|
-
*
|
|
11
|
-
* @format uuid
|
|
12
|
-
*/
|
|
13
|
-
id: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Section code.
|
|
17
|
-
*/
|
|
18
|
-
section: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Name of nickname of writer.
|
|
22
|
-
*/
|
|
23
|
-
writer: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* List of contents.
|
|
27
|
-
*
|
|
28
|
-
* Whenever updating an article, its contents would be accumulated.
|
|
29
|
-
*/
|
|
30
|
-
contents: IBbsArticle.IContent[];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Creation time of the article.
|
|
34
|
-
*/
|
|
35
|
-
created_at: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export namespace IBbsArticle {
|
|
39
|
-
/**
|
|
40
|
-
* Page request info with some options.
|
|
41
|
-
*/
|
|
42
|
-
export interface IRequest extends IPage.IRequest {
|
|
43
|
-
/**
|
|
44
|
-
* Searching options.
|
|
45
|
-
*/
|
|
46
|
-
search?: IRequest.ISearch;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Sorting options.
|
|
50
|
-
*
|
|
51
|
-
* The plus sign means ASC and minus sign means DESC.
|
|
52
|
-
*/
|
|
53
|
-
sort?: IPage.IRequest.Sort<IRequest.SortableColumns>;
|
|
54
|
-
}
|
|
55
|
-
export namespace IRequest {
|
|
56
|
-
/**
|
|
57
|
-
* Searching options.
|
|
58
|
-
*/
|
|
59
|
-
export interface ISearch {
|
|
60
|
-
writer?: string;
|
|
61
|
-
title?: string;
|
|
62
|
-
body?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* List of sortable columns.
|
|
67
|
-
*/
|
|
68
|
-
export type SortableColumns =
|
|
69
|
-
| "writer"
|
|
70
|
-
| "title"
|
|
71
|
-
| "created_at"
|
|
72
|
-
| "updated_at";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Summarized info.
|
|
77
|
-
*/
|
|
78
|
-
export interface ISummary {
|
|
79
|
-
id: string;
|
|
80
|
-
writer: string;
|
|
81
|
-
title: string;
|
|
82
|
-
created_at: string;
|
|
83
|
-
updated_at: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Content info.
|
|
88
|
-
*/
|
|
89
|
-
export interface IContent extends Omit<IUpdate, "password"> {
|
|
90
|
-
/**
|
|
91
|
-
* Primary key of individual content.
|
|
92
|
-
*
|
|
93
|
-
* @format uuid
|
|
94
|
-
*/
|
|
95
|
-
id: string;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Creation time of this content.
|
|
99
|
-
*/
|
|
100
|
-
created_at: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Store info.
|
|
105
|
-
*/
|
|
106
|
-
export interface IStore extends IUpdate {
|
|
107
|
-
/**
|
|
108
|
-
* Name or nickname of the writer.
|
|
109
|
-
*/
|
|
110
|
-
writer: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Update info.
|
|
115
|
-
*/
|
|
116
|
-
export interface IUpdate {
|
|
117
|
-
/**
|
|
118
|
-
* Title of the article.
|
|
119
|
-
*/
|
|
120
|
-
title: string;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Content body.
|
|
124
|
-
*/
|
|
125
|
-
body: string;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Format of the content body.
|
|
129
|
-
*/
|
|
130
|
-
format: "md" | "html" | "txt";
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* List of files (to be) attached.
|
|
134
|
-
*/
|
|
135
|
-
files: IAttachmentFile[];
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Password of the article.
|
|
139
|
-
*/
|
|
140
|
-
password: string;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
* @module api.structures.common
|
|
4
|
-
*/
|
|
5
|
-
//================================================================
|
|
6
|
-
/**
|
|
7
|
-
* Paged record set.
|
|
8
|
-
*
|
|
9
|
-
* @author Samchon
|
|
10
|
-
*/
|
|
11
|
-
export interface IPage<T extends object> {
|
|
12
|
-
/**
|
|
13
|
-
* Pagination info.
|
|
14
|
-
*/
|
|
15
|
-
pagination: IPage.IPagination;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* List of records
|
|
19
|
-
*/
|
|
20
|
-
data: T[];
|
|
21
|
-
}
|
|
22
|
-
export namespace IPage {
|
|
23
|
-
/**
|
|
24
|
-
* Pagination info.
|
|
25
|
-
*/
|
|
26
|
-
export interface IPagination {
|
|
27
|
-
/**
|
|
28
|
-
* Current page number.
|
|
29
|
-
*
|
|
30
|
-
* Starts from 1.
|
|
31
|
-
*/
|
|
32
|
-
page: number;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Limit records per a page.
|
|
36
|
-
*
|
|
37
|
-
* @default 100
|
|
38
|
-
*/
|
|
39
|
-
limit: number;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Number of total records.
|
|
43
|
-
*/
|
|
44
|
-
total_count: number;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Number of total pages.
|
|
48
|
-
*/
|
|
49
|
-
total_pages: number;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Request info of page.
|
|
54
|
-
*/
|
|
55
|
-
export interface IRequest {
|
|
56
|
-
/**
|
|
57
|
-
* Target page number.
|
|
58
|
-
*
|
|
59
|
-
* @default 1
|
|
60
|
-
*/
|
|
61
|
-
page?: number;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Limit per a page.
|
|
65
|
-
*
|
|
66
|
-
* @defualt 100
|
|
67
|
-
*/
|
|
68
|
-
limit?: number;
|
|
69
|
-
}
|
|
70
|
-
export namespace IRequest {
|
|
71
|
-
export type Sort<Literal extends string> = Array<
|
|
72
|
-
`-${Literal}` | `+${Literal}`
|
|
73
|
-
>;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import helper from "nestia-helper";
|
|
2
|
-
import { Controller } from "@nestjs/common";
|
|
3
|
-
import { IBbsArticle } from "../api/structures/bbs/IBbsArticle";
|
|
4
|
-
import { IPage } from "../api/structures/common/IPage";
|
|
5
|
-
import { BbsArticleProvider } from "../providers/bbs/BbsArticleProvider";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This is a fake controller.
|
|
9
|
-
*
|
|
10
|
-
* Remove it or make it to be real one.
|
|
11
|
-
*/
|
|
12
|
-
@Controller("bbs/articles/:section")
|
|
13
|
-
export class BbsArticlesController {
|
|
14
|
-
@helper.EncryptedRoute.Patch()
|
|
15
|
-
public index(
|
|
16
|
-
@helper.TypedParam("section", "string") section: string,
|
|
17
|
-
@helper.TypedBody() input: IBbsArticle.IRequest,
|
|
18
|
-
): Promise<IPage<IBbsArticle.ISummary>> {
|
|
19
|
-
return BbsArticleProvider.index(section, input);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@helper.TypedRoute.Get(":id")
|
|
23
|
-
public at(
|
|
24
|
-
@helper.TypedParam("section", "string") section: string,
|
|
25
|
-
@helper.TypedParam("id", "uuid") id: string,
|
|
26
|
-
): Promise<IBbsArticle> {
|
|
27
|
-
return BbsArticleProvider.find(section, id);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@helper.TypedRoute.Post()
|
|
31
|
-
public store(
|
|
32
|
-
@helper.TypedParam("section", "string") section: string,
|
|
33
|
-
@helper.TypedBody() input: IBbsArticle.IStore,
|
|
34
|
-
): Promise<IBbsArticle> {
|
|
35
|
-
return BbsArticleProvider.store(section, input);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@helper.TypedRoute.Put(":id")
|
|
39
|
-
public update(
|
|
40
|
-
@helper.TypedParam("section", "string") section: string,
|
|
41
|
-
@helper.TypedParam("id", "uuid") id: string,
|
|
42
|
-
@helper.TypedBody() input: IBbsArticle.IUpdate,
|
|
43
|
-
): Promise<IBbsArticle.IContent> {
|
|
44
|
-
return BbsArticleProvider.update(section, id, input);
|
|
45
|
-
}
|
|
46
|
-
}
|