@purpleschool/gptbot 0.5.44 → 0.5.45
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/api/controllers/http/blog.ts +6 -3
- package/api/controllers/http/files.ts +4 -0
- package/api/routes.ts +25 -8
- package/build/api/controllers/http/blog.js +5 -3
- package/build/api/controllers/http/files.js +4 -0
- package/build/api/routes.js +20 -8
- package/build/commands/blog/create-post.command.js +3 -0
- package/build/commands/blog/find-all-posts.command.js +11 -0
- package/build/commands/blog/find-post-by-alias.command.js +1 -1
- package/build/commands/blog/find-post-by-uuid.command.js +1 -1
- package/build/commands/blog/find-posts.command.js +17 -0
- package/build/commands/blog/get-latest-updates.command.js +14 -0
- package/build/commands/blog/index.js +3 -1
- package/build/commands/file/delete-user-file.command.js +12 -0
- package/build/commands/file/index.js +1 -0
- package/build/constants/blog/enums/index.js +17 -0
- package/build/constants/blog/enums/post-type.enum.js +8 -0
- package/build/constants/blog/index.js +17 -0
- package/build/constants/domains/white-list.js +2 -1
- package/build/constants/file/file.constants.js +2 -1
- package/build/constants/index.js +1 -0
- package/build/models/post.schema.js +2 -0
- package/commands/blog/create-post.command.ts +5 -0
- package/commands/blog/find-all-posts.command.ts +10 -0
- package/commands/blog/find-post-by-alias.command.ts +1 -1
- package/commands/blog/find-post-by-uuid.command.ts +2 -2
- package/commands/blog/find-posts.command.ts +19 -0
- package/commands/blog/get-latest-updates.command.ts +16 -0
- package/commands/blog/index.ts +3 -1
- package/commands/file/delete-user-file.command.ts +12 -0
- package/commands/file/index.ts +1 -0
- package/constants/blog/enums/index.ts +1 -0
- package/constants/blog/enums/post-type.enum.ts +4 -0
- package/constants/blog/index.ts +1 -0
- package/constants/domains/white-list.ts +2 -0
- package/constants/file/file.constants.ts +2 -0
- package/constants/index.ts +1 -0
- package/models/post.schema.ts +2 -0
- package/package.json +1 -1
- package/build/commands/blog/find-post.command.js +0 -23
- package/commands/blog/find-post.command.ts +0 -28
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { POST_TYPE } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
export const BLOG_CONTROLLER = (type: POST_TYPE) => `blog/type/${type}` as const;
|
|
2
4
|
|
|
3
5
|
export const BLOG_ROUTES = {
|
|
4
6
|
CREATE: 'create',
|
|
5
7
|
FIND: 'find',
|
|
6
8
|
FIND_ALL: 'find/all',
|
|
7
|
-
FIND_BY_UUID:
|
|
8
|
-
FIND_BY_ALIAS:
|
|
9
|
+
FIND_BY_UUID: (uuid: string) => `by/uuid/${uuid}`,
|
|
10
|
+
FIND_BY_ALIAS: (alias: string) => `by/alias/${alias}`,
|
|
11
|
+
LATEST: 'latest',
|
|
9
12
|
} as const;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export const FILE_CONTROLLER = 'file' as const;
|
|
2
2
|
|
|
3
3
|
export const FILE_ROUTES = {
|
|
4
|
+
DELETE: (uuid: string) => `${uuid}`,
|
|
4
5
|
UPLOAD: 'upload',
|
|
5
6
|
UPLOAD_FILE: 'upload-file',
|
|
6
7
|
UPLOAD_IMAGE: 'upload-image',
|
|
8
|
+
CRON: {
|
|
9
|
+
DELETE_UNUSED: 'cron/delete-unused',
|
|
10
|
+
},
|
|
7
11
|
} as const;
|
package/api/routes.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { POST_TYPE } from '../constants';
|
|
1
2
|
import * as CONTROLLERS from './controllers';
|
|
2
3
|
|
|
3
4
|
export const ROOT = '/api' as const;
|
|
@@ -125,16 +126,32 @@ export const REST_API = {
|
|
|
125
126
|
UPLOAD_FILE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
|
|
126
127
|
UPLOAD_IMAGE: `${ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_IMAGE}`,
|
|
127
128
|
},
|
|
128
|
-
|
|
129
|
-
CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}`,
|
|
130
|
-
PATCH: (uuid: string) =>
|
|
131
|
-
|
|
129
|
+
BLOG_ARTICLES: {
|
|
130
|
+
CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}`,
|
|
131
|
+
PATCH: (uuid: string) =>
|
|
132
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${uuid}`,
|
|
133
|
+
DELETE: (uuid: string) =>
|
|
134
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${uuid}`,
|
|
132
135
|
GET_BY_UUID: (uuid: string) =>
|
|
133
|
-
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
|
|
136
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
|
|
134
137
|
GET_BY_ALIAS: (alias: string) =>
|
|
135
|
-
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
|
|
136
|
-
GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
|
|
137
|
-
GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
|
|
138
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
|
|
139
|
+
GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
|
|
140
|
+
GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
|
|
141
|
+
LATEST: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
|
|
142
|
+
},
|
|
143
|
+
BLOG_UPDATES: {
|
|
144
|
+
CREATE: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}`,
|
|
145
|
+
PATCH: (uuid: string) => `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${uuid}`,
|
|
146
|
+
DELETE: (uuid: string) =>
|
|
147
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${uuid}`,
|
|
148
|
+
GET_BY_UUID: (uuid: string) =>
|
|
149
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
|
|
150
|
+
GET_BY_ALIAS: (alias: string) =>
|
|
151
|
+
`${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
|
|
152
|
+
GET: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
|
|
153
|
+
GET_ALL: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
|
|
154
|
+
LATEST: `${ROOT}/${CONTROLLERS.BLOG_CONTROLLER(POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
|
|
138
155
|
},
|
|
139
156
|
PROMOCODE: {
|
|
140
157
|
CREATE: `${ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BLOG_ROUTES = exports.BLOG_CONTROLLER = void 0;
|
|
4
|
-
|
|
4
|
+
const BLOG_CONTROLLER = (type) => `blog/type/${type}`;
|
|
5
|
+
exports.BLOG_CONTROLLER = BLOG_CONTROLLER;
|
|
5
6
|
exports.BLOG_ROUTES = {
|
|
6
7
|
CREATE: 'create',
|
|
7
8
|
FIND: 'find',
|
|
8
9
|
FIND_ALL: 'find/all',
|
|
9
|
-
FIND_BY_UUID:
|
|
10
|
-
FIND_BY_ALIAS:
|
|
10
|
+
FIND_BY_UUID: (uuid) => `by/uuid/${uuid}`,
|
|
11
|
+
FIND_BY_ALIAS: (alias) => `by/alias/${alias}`,
|
|
12
|
+
LATEST: 'latest',
|
|
11
13
|
};
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FILE_ROUTES = exports.FILE_CONTROLLER = void 0;
|
|
4
4
|
exports.FILE_CONTROLLER = 'file';
|
|
5
5
|
exports.FILE_ROUTES = {
|
|
6
|
+
DELETE: (uuid) => `${uuid}`,
|
|
6
7
|
UPLOAD: 'upload',
|
|
7
8
|
UPLOAD_FILE: 'upload-file',
|
|
8
9
|
UPLOAD_IMAGE: 'upload-image',
|
|
10
|
+
CRON: {
|
|
11
|
+
DELETE_UNUSED: 'cron/delete-unused',
|
|
12
|
+
},
|
|
9
13
|
};
|
package/build/api/routes.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.REST_API = exports.ROOT = void 0;
|
|
37
|
+
const constants_1 = require("../constants");
|
|
37
38
|
const CONTROLLERS = __importStar(require("./controllers"));
|
|
38
39
|
exports.ROOT = '/api';
|
|
39
40
|
exports.REST_API = {
|
|
@@ -140,14 +141,25 @@ exports.REST_API = {
|
|
|
140
141
|
UPLOAD_FILE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_FILE}`,
|
|
141
142
|
UPLOAD_IMAGE: `${exports.ROOT}/${CONTROLLERS.FILE_CONTROLLER}/${CONTROLLERS.FILE_ROUTES.UPLOAD_IMAGE}`,
|
|
142
143
|
},
|
|
143
|
-
|
|
144
|
-
CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}`,
|
|
145
|
-
PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${uuid}`,
|
|
146
|
-
DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${uuid}`,
|
|
147
|
-
GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
|
|
148
|
-
GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
|
|
149
|
-
GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
|
|
150
|
-
GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
|
|
144
|
+
BLOG_ARTICLES: {
|
|
145
|
+
CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}`,
|
|
146
|
+
PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${uuid}`,
|
|
147
|
+
DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${uuid}`,
|
|
148
|
+
GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
|
|
149
|
+
GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
|
|
150
|
+
GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
|
|
151
|
+
GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
|
|
152
|
+
LATEST: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.ARTICLE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
|
|
153
|
+
},
|
|
154
|
+
BLOG_UPDATES: {
|
|
155
|
+
CREATE: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}`,
|
|
156
|
+
PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${uuid}`,
|
|
157
|
+
DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${uuid}`,
|
|
158
|
+
GET_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_UUID}/${uuid}`,
|
|
159
|
+
GET_BY_ALIAS: (alias) => `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_BY_ALIAS}/${alias}`,
|
|
160
|
+
GET: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND}`,
|
|
161
|
+
GET_ALL: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.FIND_ALL}`,
|
|
162
|
+
LATEST: `${exports.ROOT}/${CONTROLLERS.BLOG_CONTROLLER(constants_1.POST_TYPE.UPDATE)}/${CONTROLLERS.BLOG_ROUTES.LATEST}`,
|
|
151
163
|
},
|
|
152
164
|
PROMOCODE: {
|
|
153
165
|
CREATE: `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}`,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindAllPostsCommand = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
var FindAllPostsCommand;
|
|
7
|
+
(function (FindAllPostsCommand) {
|
|
8
|
+
FindAllPostsCommand.ResponseSchema = zod_1.z.object({
|
|
9
|
+
data: zod_1.z.array(models_1.PostSchema),
|
|
10
|
+
});
|
|
11
|
+
})(FindAllPostsCommand || (exports.FindAllPostsCommand = FindAllPostsCommand = {}));
|
|
@@ -9,7 +9,7 @@ var FindPostByAliasCommand;
|
|
|
9
9
|
alias: true,
|
|
10
10
|
});
|
|
11
11
|
FindPostByAliasCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
-
data:
|
|
12
|
+
data: models_1.PostSchema,
|
|
13
13
|
});
|
|
14
14
|
FindPostByAliasCommand.ResponseByAliasSchema = zod_1.z.object({
|
|
15
15
|
data: models_1.PostSchema,
|
|
@@ -8,7 +8,7 @@ var FindPostByUUIDCommand;
|
|
|
8
8
|
FindPostByUUIDCommand.RequestSchema = models_1.PostSchema.pick({
|
|
9
9
|
uuid: true,
|
|
10
10
|
});
|
|
11
|
-
FindPostByUUIDCommand.
|
|
11
|
+
FindPostByUUIDCommand.Responsechema = zod_1.z.object({
|
|
12
12
|
data: models_1.PostSchema,
|
|
13
13
|
});
|
|
14
14
|
})(FindPostByUUIDCommand || (exports.FindPostByUUIDCommand = FindPostByUUIDCommand = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindPostsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var FindPostsCommand;
|
|
7
|
+
(function (FindPostsCommand) {
|
|
8
|
+
FindPostsCommand.RequestQuerySchema = zod_1.z.object({
|
|
9
|
+
limit: zod_1.z.string().transform((val) => parseInt(val, 10)),
|
|
10
|
+
offset: zod_1.z.string().transform((val) => parseInt(val, 10)),
|
|
11
|
+
});
|
|
12
|
+
FindPostsCommand.ResponseSchema = zod_1.z.object({
|
|
13
|
+
posts: zod_1.z.array(models_1.PostSchema),
|
|
14
|
+
totalPage: zod_1.z.number(),
|
|
15
|
+
page: zod_1.z.number(),
|
|
16
|
+
});
|
|
17
|
+
})(FindPostsCommand || (exports.FindPostsCommand = FindPostsCommand = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetLatestUpdatesCommand = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
var GetLatestUpdatesCommand;
|
|
7
|
+
(function (GetLatestUpdatesCommand) {
|
|
8
|
+
GetLatestUpdatesCommand.RequestQuerySchema = zod_1.z.object({
|
|
9
|
+
limit: zod_1.z.coerce.number().default(10),
|
|
10
|
+
});
|
|
11
|
+
GetLatestUpdatesCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
+
data: zod_1.z.array(models_1.PostSchema),
|
|
13
|
+
});
|
|
14
|
+
})(GetLatestUpdatesCommand || (exports.GetLatestUpdatesCommand = GetLatestUpdatesCommand = {}));
|
|
@@ -16,7 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-post.command"), exports);
|
|
18
18
|
__exportStar(require("./delete-post.command"), exports);
|
|
19
|
+
__exportStar(require("./find-all-posts.command"), exports);
|
|
19
20
|
__exportStar(require("./find-post-by-alias.command"), exports);
|
|
20
21
|
__exportStar(require("./find-post-by-uuid.command"), exports);
|
|
21
|
-
__exportStar(require("./find-
|
|
22
|
+
__exportStar(require("./find-posts.command"), exports);
|
|
23
|
+
__exportStar(require("./get-latest-updates.command"), exports);
|
|
22
24
|
__exportStar(require("./update-post.command"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteUserFileCommand = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
var DeleteUserFileCommand;
|
|
7
|
+
(function (DeleteUserFileCommand) {
|
|
8
|
+
DeleteUserFileCommand.RequestParamsSchema = models_1.FileSchema.pick({
|
|
9
|
+
uuid: true,
|
|
10
|
+
});
|
|
11
|
+
DeleteUserFileCommand.ResponseSchema = zod_1.z.void();
|
|
12
|
+
})(DeleteUserFileCommand || (exports.DeleteUserFileCommand = DeleteUserFileCommand = {}));
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./delete-user-file.command"), exports);
|
|
17
18
|
__exportStar(require("./upload.command"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./post-type.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POST_TYPE = void 0;
|
|
4
|
+
var POST_TYPE;
|
|
5
|
+
(function (POST_TYPE) {
|
|
6
|
+
POST_TYPE["ARTICLE"] = "article";
|
|
7
|
+
POST_TYPE["UPDATE"] = "update";
|
|
8
|
+
})(POST_TYPE || (exports.POST_TYPE = POST_TYPE = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./enums"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WHITE_LIST = void 0;
|
|
3
|
+
exports.EMAIL_STUDENT_DOMAINS = exports.WHITE_LIST = void 0;
|
|
4
4
|
exports.WHITE_LIST = [
|
|
5
5
|
'mail.ru',
|
|
6
6
|
'yandex.ru',
|
|
@@ -53,3 +53,4 @@ exports.WHITE_LIST = [
|
|
|
53
53
|
'ymail.com',
|
|
54
54
|
'hushmail.com',
|
|
55
55
|
];
|
|
56
|
+
exports.EMAIL_STUDENT_DOMAINS = ['edu', 'study', 'student'];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VALID_MIMETYPES = exports.IMAGE_MIMETYPES = exports.MAX_UPLOAD_SIZE = void 0;
|
|
3
|
+
exports.DELETE_UNUSED_FILES_AFTER_HOURS = exports.VALID_MIMETYPES = exports.IMAGE_MIMETYPES = exports.MAX_UPLOAD_SIZE = void 0;
|
|
4
4
|
exports.MAX_UPLOAD_SIZE = 5 * 1024 * 1024; // 5MB
|
|
5
5
|
exports.IMAGE_MIMETYPES = ['image/jpeg', 'image/png', 'image/webp'];
|
|
6
6
|
exports.VALID_MIMETYPES = [...exports.IMAGE_MIMETYPES];
|
|
7
|
+
exports.DELETE_UNUSED_FILES_AFTER_HOURS = 12;
|
package/build/constants/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ai-model"), exports);
|
|
18
|
+
__exportStar(require("./blog"), exports);
|
|
18
19
|
__exportStar(require("./category"), exports);
|
|
19
20
|
__exportStar(require("./chat"), exports);
|
|
20
21
|
__exportStar(require("./cloud-payments"), exports);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
5
6
|
exports.PostSchema = zod_1.z.object({
|
|
6
7
|
uuid: zod_1.z.string().uuid(),
|
|
7
8
|
title: zod_1.z.string(),
|
|
@@ -13,6 +14,7 @@ exports.PostSchema = zod_1.z.object({
|
|
|
13
14
|
metaTitle: zod_1.z.nullable(zod_1.z.string()),
|
|
14
15
|
metaDescription: zod_1.z.nullable(zod_1.z.string()),
|
|
15
16
|
views: zod_1.z.number(),
|
|
17
|
+
type: zod_1.z.nativeEnum(constants_1.POST_TYPE),
|
|
16
18
|
createdAt: zod_1.z.date(),
|
|
17
19
|
updatedAt: zod_1.z.date(),
|
|
18
20
|
});
|
|
@@ -10,6 +10,11 @@ export namespace CreatePostCommand {
|
|
|
10
10
|
});
|
|
11
11
|
export type Request = z.infer<typeof RequestSchema>;
|
|
12
12
|
|
|
13
|
+
export const RequestParamSchema = PostSchema.pick({
|
|
14
|
+
type: true,
|
|
15
|
+
});
|
|
16
|
+
export type RequestParam = z.infer<typeof RequestParamSchema>;
|
|
17
|
+
|
|
13
18
|
export const ResponseSchema = z.object({
|
|
14
19
|
data: PostSchema,
|
|
15
20
|
});
|
|
@@ -8,9 +8,9 @@ export namespace FindPostByUUIDCommand {
|
|
|
8
8
|
|
|
9
9
|
export type Request = z.infer<typeof RequestSchema>;
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const Responsechema = z.object({
|
|
12
12
|
data: PostSchema,
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
export type Response = z.infer<typeof
|
|
15
|
+
export type Response = z.infer<typeof Responsechema>;
|
|
16
16
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PostSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindPostsCommand {
|
|
5
|
+
export const RequestQuerySchema = z.object({
|
|
6
|
+
limit: z.string().transform((val) => parseInt(val, 10)),
|
|
7
|
+
offset: z.string().transform((val) => parseInt(val, 10)),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = z.object({
|
|
13
|
+
posts: z.array(PostSchema),
|
|
14
|
+
totalPage: z.number(),
|
|
15
|
+
page: z.number(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PostSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace GetLatestUpdatesCommand {
|
|
5
|
+
export const RequestQuerySchema = z.object({
|
|
6
|
+
limit: z.coerce.number().default(10),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: z.array(PostSchema),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
package/commands/blog/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './create-post.command';
|
|
2
2
|
export * from './delete-post.command';
|
|
3
|
+
export * from './find-all-posts.command';
|
|
3
4
|
export * from './find-post-by-alias.command';
|
|
4
5
|
export * from './find-post-by-uuid.command';
|
|
5
|
-
export * from './find-
|
|
6
|
+
export * from './find-posts.command';
|
|
7
|
+
export * from './get-latest-updates.command';
|
|
6
8
|
export * from './update-post.command';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileSchema } from '../../models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteUserFileCommand {
|
|
5
|
+
export const RequestParamsSchema = FileSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = z.void();
|
|
10
|
+
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
package/commands/file/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './post-type.enum';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './enums';
|
package/constants/index.ts
CHANGED
package/models/post.schema.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { POST_TYPE } from '../constants';
|
|
2
3
|
|
|
3
4
|
export const PostSchema = z.object({
|
|
4
5
|
uuid: z.string().uuid(),
|
|
@@ -11,6 +12,7 @@ export const PostSchema = z.object({
|
|
|
11
12
|
metaTitle: z.nullable(z.string()),
|
|
12
13
|
metaDescription: z.nullable(z.string()),
|
|
13
14
|
views: z.number(),
|
|
15
|
+
type: z.nativeEnum(POST_TYPE),
|
|
14
16
|
|
|
15
17
|
createdAt: z.date(),
|
|
16
18
|
updatedAt: z.date(),
|
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FindPostCommand = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const models_1 = require("../../models");
|
|
6
|
-
const FindPostRequestSchema = zod_1.z.object({
|
|
7
|
-
limit: zod_1.z.string().transform((val) => parseInt(val, 10)),
|
|
8
|
-
offset: zod_1.z.string().transform((val) => parseInt(val, 10)),
|
|
9
|
-
});
|
|
10
|
-
const FindPostResponseSchema = zod_1.z.object({
|
|
11
|
-
posts: zod_1.z.array(models_1.PostSchema),
|
|
12
|
-
totalPage: zod_1.z.number(),
|
|
13
|
-
page: zod_1.z.number(),
|
|
14
|
-
});
|
|
15
|
-
const FindAllPostResponseSchema = zod_1.z.object({
|
|
16
|
-
data: zod_1.z.array(models_1.PostSchema),
|
|
17
|
-
});
|
|
18
|
-
var FindPostCommand;
|
|
19
|
-
(function (FindPostCommand) {
|
|
20
|
-
FindPostCommand.RequestSchema = FindPostRequestSchema;
|
|
21
|
-
FindPostCommand.ResponseSchema = FindPostResponseSchema;
|
|
22
|
-
FindPostCommand.ResponseAllSchema = FindAllPostResponseSchema;
|
|
23
|
-
})(FindPostCommand || (exports.FindPostCommand = FindPostCommand = {}));
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { PostSchema } from '../../models';
|
|
3
|
-
|
|
4
|
-
const FindPostRequestSchema = z.object({
|
|
5
|
-
limit: z.string().transform((val) => parseInt(val, 10)),
|
|
6
|
-
offset: z.string().transform((val) => parseInt(val, 10)),
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
const FindPostResponseSchema = z.object({
|
|
10
|
-
posts: z.array(PostSchema),
|
|
11
|
-
totalPage: z.number(),
|
|
12
|
-
page: z.number(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const FindAllPostResponseSchema = z.object({
|
|
16
|
-
data: z.array(PostSchema),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export namespace FindPostCommand {
|
|
20
|
-
export const RequestSchema = FindPostRequestSchema;
|
|
21
|
-
export type Request = z.infer<typeof RequestSchema>;
|
|
22
|
-
|
|
23
|
-
export const ResponseSchema = FindPostResponseSchema;
|
|
24
|
-
export type Response = z.infer<typeof ResponseSchema>;
|
|
25
|
-
|
|
26
|
-
export const ResponseAllSchema = FindAllPostResponseSchema;
|
|
27
|
-
export type ResponseAll = z.infer<typeof ResponseAllSchema>;
|
|
28
|
-
}
|