@lark-apaas/coding-template-nestjs-react-fullstack 0.1.0-alpha.1
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/LICENSE +13 -0
- package/README.md +41 -0
- package/hooks/after-install.mjs +3 -0
- package/hooks/after-render.mjs +3 -0
- package/hooks/before-render.mjs +3 -0
- package/package.json +36 -0
- package/template/.codebase/pipelines/ci.yaml +34 -0
- package/template/.codebase/pipelines/coco-code-review.yaml +21 -0
- package/template/.prettierrc +8 -0
- package/template/.spark_project +16 -0
- package/template/.stylelintrc.js +12 -0
- package/template/_env.local +38 -0
- package/template/_gitignore +64 -0
- package/template/_npmrc +1 -0
- package/template/client/index.html +23 -0
- package/template/client/public/favicon.svg +40 -0
- package/template/client/src/api/index.ts +19 -0
- package/template/client/src/app.tsx +22 -0
- package/template/client/src/components/Layout.tsx +11 -0
- package/template/client/src/components/business-ui/README.md +519 -0
- package/template/client/src/components/business-ui/api/chats/queries.ts +39 -0
- package/template/client/src/components/business-ui/api/chats/service.ts +29 -0
- package/template/client/src/components/business-ui/api/departments/queries.ts +42 -0
- package/template/client/src/components/business-ui/api/departments/service.ts +18 -0
- package/template/client/src/components/business-ui/api/files/service.ts +28 -0
- package/template/client/src/components/business-ui/api/user-profiles/queries.ts +42 -0
- package/template/client/src/components/business-ui/api/user-profiles/service.ts +23 -0
- package/template/client/src/components/business-ui/api/users/queries.ts +34 -0
- package/template/client/src/components/business-ui/api/users/service.ts +40 -0
- package/template/client/src/components/business-ui/chat-select/README.md +128 -0
- package/template/client/src/components/business-ui/chat-select/chat-item.tsx +85 -0
- package/template/client/src/components/business-ui/chat-select/chat-select-tag.tsx +83 -0
- package/template/client/src/components/business-ui/chat-select/chat-select.tsx +197 -0
- package/template/client/src/components/business-ui/chat-select/index.tsx +12 -0
- package/template/client/src/components/business-ui/chat-select/types.ts +102 -0
- package/template/client/src/components/business-ui/chat-select/use-chat-value.ts +180 -0
- package/template/client/src/components/business-ui/chat-select/utils.ts +81 -0
- package/template/client/src/components/business-ui/department-select/department-item.tsx +55 -0
- package/template/client/src/components/business-ui/department-select/department-select-field.tsx +86 -0
- package/template/client/src/components/business-ui/department-select/department-select-tag.tsx +56 -0
- package/template/client/src/components/business-ui/department-select/department-select.tsx +168 -0
- package/template/client/src/components/business-ui/department-select/icon-department.tsx +22 -0
- package/template/client/src/components/business-ui/department-select/index.tsx +7 -0
- package/template/client/src/components/business-ui/department-select/types.ts +15 -0
- package/template/client/src/components/business-ui/department-select/utils.ts +17 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-content.tsx +35 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-empty.tsx +28 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-error.tsx +35 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-item.tsx +55 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-list.tsx +174 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-loading.tsx +19 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-search.tsx +31 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox-trigger.tsx +281 -0
- package/template/client/src/components/business-ui/entity-combobox/base-combobox.tsx +132 -0
- package/template/client/src/components/business-ui/entity-combobox/context.tsx +19 -0
- package/template/client/src/components/business-ui/entity-combobox/entity-combobox.tsx +145 -0
- package/template/client/src/components/business-ui/entity-combobox/highlight-text.tsx +52 -0
- package/template/client/src/components/business-ui/entity-combobox/hooks.tsx +21 -0
- package/template/client/src/components/business-ui/entity-combobox/index.tsx +31 -0
- package/template/client/src/components/business-ui/entity-combobox/item-pill.tsx +179 -0
- package/template/client/src/components/business-ui/entity-combobox/popover-wrapper.tsx +149 -0
- package/template/client/src/components/business-ui/entity-combobox/search-trigger.tsx +262 -0
- package/template/client/src/components/business-ui/entity-combobox/shared-types.ts +296 -0
- package/template/client/src/components/business-ui/entity-combobox/size-variants.tsx +322 -0
- package/template/client/src/components/business-ui/entity-combobox/types.ts +246 -0
- package/template/client/src/components/business-ui/entity-combobox/use-fetch-data.tsx +81 -0
- package/template/client/src/components/business-ui/entity-combobox/use-infinite-scroll.tsx +99 -0
- package/template/client/src/components/business-ui/entity-combobox/use-popover-outside-click.tsx +32 -0
- package/template/client/src/components/business-ui/form/checkbox-field.tsx +83 -0
- package/template/client/src/components/business-ui/form/context.tsx +38 -0
- package/template/client/src/components/business-ui/form/field-layout.tsx +91 -0
- package/template/client/src/components/business-ui/form/form.tsx +54 -0
- package/template/client/src/components/business-ui/form/hooks/form-context.tsx +4 -0
- package/template/client/src/components/business-ui/form/hooks/form-utils.ts +23 -0
- package/template/client/src/components/business-ui/form/hooks/form.tsx +40 -0
- package/template/client/src/components/business-ui/form/index.tsx +4 -0
- package/template/client/src/components/business-ui/form/input-field.tsx +74 -0
- package/template/client/src/components/business-ui/form/radio-group-field.tsx +138 -0
- package/template/client/src/components/business-ui/form/select-field.tsx +155 -0
- package/template/client/src/components/business-ui/form/switch-field.tsx +66 -0
- package/template/client/src/components/business-ui/form/textarea-field.tsx +72 -0
- package/template/client/src/components/business-ui/form/types.ts +32 -0
- package/template/client/src/components/business-ui/tiptap-editor/README.md +324 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/attachment-toolbar-button.tsx +74 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/blockquote-toolbar-button.tsx +41 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/code-block-toolbar-button.tsx +41 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/color-highlight-toolbar-button.tsx +141 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/heading-toolbar-button.tsx +99 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/horizontal-rule-toolbar-button.tsx +39 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/image-upload-toolbar-button.tsx +65 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/link-edit-form.tsx +127 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/link-hover-toolbar.tsx +380 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/link-toolbar-button.tsx +96 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/list-toolbar-button.tsx +75 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/mark-toolbar-button.tsx +118 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/text-align-toolbar-button.tsx +84 -0
- package/template/client/src/components/business-ui/tiptap-editor/components/undo-redo-toolbar-button.tsx +54 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/attachment.tsx +539 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/code-block-shiki.tsx +236 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/complete-kit.ts +260 -0
- package/template/client/src/components/business-ui/tiptap-editor/extensions/image.tsx +456 -0
- package/template/client/src/components/business-ui/tiptap-editor/hooks/use-tiptap-editor.ts +47 -0
- package/template/client/src/components/business-ui/tiptap-editor/index.ts +38 -0
- package/template/client/src/components/business-ui/tiptap-editor/tiptap-editor-complete.tsx +112 -0
- package/template/client/src/components/business-ui/tiptap-editor/tiptap-editor.tsx +169 -0
- package/template/client/src/components/business-ui/types/user.ts +74 -0
- package/template/client/src/components/business-ui/user-display/index.tsx +2 -0
- package/template/client/src/components/business-ui/user-display/overflow-tooltip-text.tsx +90 -0
- package/template/client/src/components/business-ui/user-display/type.ts +27 -0
- package/template/client/src/components/business-ui/user-display/user-display.tsx +99 -0
- package/template/client/src/components/business-ui/user-display/user-with-avatar.tsx +158 -0
- package/template/client/src/components/business-ui/user-display/utils.ts +37 -0
- package/template/client/src/components/business-ui/user-profile/error-image.tsx +302 -0
- package/template/client/src/components/business-ui/user-profile/user-external-script.ts +73 -0
- package/template/client/src/components/business-ui/user-profile/user-profile.tsx +370 -0
- package/template/client/src/components/business-ui/user-select/index.tsx +28 -0
- package/template/client/src/components/business-ui/user-select/types.ts +109 -0
- package/template/client/src/components/business-ui/user-select/use-user-value.ts +160 -0
- package/template/client/src/components/business-ui/user-select/user-item.tsx +98 -0
- package/template/client/src/components/business-ui/user-select/user-pill.tsx +140 -0
- package/template/client/src/components/business-ui/user-select/user-select-tag.tsx +82 -0
- package/template/client/src/components/business-ui/user-select/user-select.tsx +359 -0
- package/template/client/src/components/business-ui/user-select/utils.tsx +188 -0
- package/template/client/src/components/business-ui/utils/user.ts +72 -0
- package/template/client/src/components/ui/README.md +134 -0
- package/template/client/src/components/ui/accordion.tsx +66 -0
- package/template/client/src/components/ui/alert-dialog.tsx +157 -0
- package/template/client/src/components/ui/alert.tsx +71 -0
- package/template/client/src/components/ui/aspect-ratio.tsx +11 -0
- package/template/client/src/components/ui/avatar.tsx +53 -0
- package/template/client/src/components/ui/badge.tsx +42 -0
- package/template/client/src/components/ui/breadcrumb.tsx +109 -0
- package/template/client/src/components/ui/button-group.tsx +83 -0
- package/template/client/src/components/ui/button.tsx +69 -0
- package/template/client/src/components/ui/calendar.tsx +213 -0
- package/template/client/src/components/ui/card.tsx +82 -0
- package/template/client/src/components/ui/carousel.tsx +241 -0
- package/template/client/src/components/ui/chart.tsx +357 -0
- package/template/client/src/components/ui/checkbox.tsx +32 -0
- package/template/client/src/components/ui/collapsible.tsx +33 -0
- package/template/client/src/components/ui/command.tsx +208 -0
- package/template/client/src/components/ui/context-menu.tsx +324 -0
- package/template/client/src/components/ui/dialog.tsx +143 -0
- package/template/client/src/components/ui/drawer.tsx +135 -0
- package/template/client/src/components/ui/dropdown-menu.tsx +329 -0
- package/template/client/src/components/ui/empty.tsx +104 -0
- package/template/client/src/components/ui/field.tsx +248 -0
- package/template/client/src/components/ui/form.tsx +167 -0
- package/template/client/src/components/ui/hover-card.tsx +44 -0
- package/template/client/src/components/ui/icons/file-ae-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-ai-colorful-icon.tsx +36 -0
- package/template/client/src/components/ui/icons/file-android-colorful-icon.tsx +33 -0
- package/template/client/src/components/ui/icons/file-audio-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-code-colorful-icon.tsx +28 -0
- package/template/client/src/components/ui/icons/file-csv-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-eml-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-ios-colorful-icon.tsx +25 -0
- package/template/client/src/components/ui/icons/file-keynote-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-pages-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-ps-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-sketch-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-slide-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-vcf-colorful-icon.tsx +29 -0
- package/template/client/src/components/ui/icons/file-wiki-excel-colorful-icon.tsx +23 -0
- package/template/client/src/components/ui/icons/file-wiki-image-colorful-icon.tsx +27 -0
- package/template/client/src/components/ui/icons/file-wiki-pdf-colorful-icon.tsx +20 -0
- package/template/client/src/components/ui/icons/file-wiki-ppt-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/icons/file-wiki-text-colorful-icon.tsx +12 -0
- package/template/client/src/components/ui/icons/file-wiki-unknown-colorful-icon.tsx +14 -0
- package/template/client/src/components/ui/icons/file-wiki-video-colorful-icon.tsx +23 -0
- package/template/client/src/components/ui/icons/file-wiki-word-colorful-icon.tsx +38 -0
- package/template/client/src/components/ui/icons/file-wiki-zip-colorful-icon.tsx +21 -0
- package/template/client/src/components/ui/image.tsx +183 -0
- package/template/client/src/components/ui/input-group.tsx +166 -0
- package/template/client/src/components/ui/input-otp.tsx +77 -0
- package/template/client/src/components/ui/input.tsx +21 -0
- package/template/client/src/components/ui/item.tsx +193 -0
- package/template/client/src/components/ui/kbd.tsx +28 -0
- package/template/client/src/components/ui/label.tsx +24 -0
- package/template/client/src/components/ui/menubar.tsx +348 -0
- package/template/client/src/components/ui/native-select.tsx +48 -0
- package/template/client/src/components/ui/navigation-menu.tsx +168 -0
- package/template/client/src/components/ui/pagination.tsx +127 -0
- package/template/client/src/components/ui/popover.tsx +48 -0
- package/template/client/src/components/ui/progress.tsx +31 -0
- package/template/client/src/components/ui/radio-group.tsx +45 -0
- package/template/client/src/components/ui/resizable.tsx +56 -0
- package/template/client/src/components/ui/scroll-area.tsx +58 -0
- package/template/client/src/components/ui/select.tsx +243 -0
- package/template/client/src/components/ui/separator.tsx +28 -0
- package/template/client/src/components/ui/sheet.tsx +139 -0
- package/template/client/src/components/ui/sidebar.tsx +727 -0
- package/template/client/src/components/ui/skeleton.tsx +13 -0
- package/template/client/src/components/ui/slider.tsx +87 -0
- package/template/client/src/components/ui/sonner.tsx +67 -0
- package/template/client/src/components/ui/spinner.tsx +16 -0
- package/template/client/src/components/ui/streamdown.tsx +186 -0
- package/template/client/src/components/ui/switch.tsx +31 -0
- package/template/client/src/components/ui/table.tsx +116 -0
- package/template/client/src/components/ui/tabs.tsx +66 -0
- package/template/client/src/components/ui/textarea.tsx +18 -0
- package/template/client/src/components/ui/toggle-group.tsx +83 -0
- package/template/client/src/components/ui/toggle.tsx +47 -0
- package/template/client/src/components/ui/tooltip.tsx +61 -0
- package/template/client/src/hooks/use-example.ts +52 -0
- package/template/client/src/hooks/use-mobile.ts +19 -0
- package/template/client/src/index.css +7 -0
- package/template/client/src/index.tsx +36 -0
- package/template/client/src/lib/shiki.ts +92 -0
- package/template/client/src/lib/utils.ts +6 -0
- package/template/client/src/pages/ExamplePage/ExamplePage.tsx +37 -0
- package/template/client/src/pages/NotFound/NotFound.tsx +11 -0
- package/template/client/src/tailwind-theme.css +257 -0
- package/template/client/src/types/common.ts +34 -0
- package/template/client/src/types/global.d.ts +53 -0
- package/template/client/src/types/index.ts +4 -0
- package/template/client/src/typography.css +41 -0
- package/template/client/src/utils/img-resources/avatar-placeholders.ts +12 -0
- package/template/client/src/utils/img-resources/banner-placeholders.ts +29 -0
- package/template/client/src/utils/img-resources/cover-placeholders.ts +47 -0
- package/template/components.json +21 -0
- package/template/eslint.config.js +50 -0
- package/template/nest-cli.json +25 -0
- package/template/package-lock.json +29195 -0
- package/template/package.json +202 -0
- package/template/postcss.config.js +10 -0
- package/template/scripts/build.sh +120 -0
- package/template/scripts/dev.js +295 -0
- package/template/scripts/dev.sh +2 -0
- package/template/scripts/lint.js +150 -0
- package/template/scripts/prune-smart.js +281 -0
- package/template/scripts/run.sh +5 -0
- package/template/server/app.module.ts +27 -0
- package/template/server/common/constants/api_response_code.ts +54 -0
- package/template/server/common/filters/exception.filter.ts +78 -0
- package/template/server/common/interfaces/api_response.interface.ts +21 -0
- package/template/server/common/interfaces/exception.interface.ts +19 -0
- package/template/server/database/schema.ts +90 -0
- package/template/server/main.ts +31 -0
- package/template/server/modules/hello/hello.controller.ts +16 -0
- package/template/server/modules/hello/hello.module.ts +10 -0
- package/template/server/modules/hello/hello.service.ts +28 -0
- package/template/server/modules/view/view.controller.ts +17 -0
- package/template/server/modules/view/view.module.ts +8 -0
- package/template/shared/api.interface.ts +1 -0
- package/template/tailwind.config.ts +9 -0
- package/template/tsconfig.app.json +23 -0
- package/template/tsconfig.json +8 -0
- package/template/tsconfig.node.json +16 -0
- package/template/vite.config.ts +10 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** auto generated, do not edit */
|
|
2
|
+
import { pgTable, pgPolicy, uuid, varchar, text, customType } from "drizzle-orm/pg-core"
|
|
3
|
+
import { sql } from "drizzle-orm"
|
|
4
|
+
|
|
5
|
+
export const userProfile = customType<{
|
|
6
|
+
data: string;
|
|
7
|
+
driverData: string;
|
|
8
|
+
}>({
|
|
9
|
+
dataType() {
|
|
10
|
+
return 'user_profile';
|
|
11
|
+
},
|
|
12
|
+
toDriver(value: string) {
|
|
13
|
+
return sql`ROW(${value})::user_profile`;
|
|
14
|
+
},
|
|
15
|
+
fromDriver(value: string) {
|
|
16
|
+
const [userId] = value.slice(1, -1).split(',');
|
|
17
|
+
return userId.trim();
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type FileAttachment = {
|
|
22
|
+
bucket_id: string;
|
|
23
|
+
file_path: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const fileAttachment = customType<{
|
|
27
|
+
data: FileAttachment;
|
|
28
|
+
driverData: string;
|
|
29
|
+
}>({
|
|
30
|
+
dataType() {
|
|
31
|
+
return 'file_attachment';
|
|
32
|
+
},
|
|
33
|
+
toDriver(value: FileAttachment) {
|
|
34
|
+
return sql`ROW(${value.bucket_id},${value.file_path})::file_attachment`;
|
|
35
|
+
},
|
|
36
|
+
fromDriver(value: string): FileAttachment {
|
|
37
|
+
const [bucketId, filePath] = value.slice(1, -1).split(',');
|
|
38
|
+
return { bucket_id: bucketId.trim(), file_path: filePath.trim() };
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const customTimestamptz = customType<{
|
|
43
|
+
data: Date;
|
|
44
|
+
driverData: string;
|
|
45
|
+
config: { precision?: number};
|
|
46
|
+
}>({
|
|
47
|
+
dataType(config) {
|
|
48
|
+
const precision = typeof config?.precision !== 'undefined'
|
|
49
|
+
? ` (${config.precision})`
|
|
50
|
+
: '';
|
|
51
|
+
return `timestamptz${precision}`;
|
|
52
|
+
},
|
|
53
|
+
toDriver(value: Date | string | number){
|
|
54
|
+
if(value == null) return value as any;
|
|
55
|
+
if (typeof value === 'number') {
|
|
56
|
+
return new Date(value).toISOString();
|
|
57
|
+
}
|
|
58
|
+
if(typeof value === 'string') {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
if (value instanceof Date) {
|
|
62
|
+
return value.toISOString();
|
|
63
|
+
}
|
|
64
|
+
throw new Error('Invalid timestamp value');
|
|
65
|
+
},
|
|
66
|
+
fromDriver(value: string | Date): Date {
|
|
67
|
+
if(value instanceof Date) return value;
|
|
68
|
+
return new Date(value);
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 以下是模板代码,仅作示例
|
|
74
|
+
*/
|
|
75
|
+
// export const record = pgTable("record", {
|
|
76
|
+
// id: uuid().defaultRandom().notNull(),
|
|
77
|
+
// title: varchar({ length: 255 }).notNull(),
|
|
78
|
+
// type: varchar({ length: 255 }).notNull(),
|
|
79
|
+
// creator: varchar({ length: 255 }).notNull(),
|
|
80
|
+
// speakDate: customTimestamptz("speakDate").notNull(),
|
|
81
|
+
// userProfile: userProfile("user_profile").notNull(),
|
|
82
|
+
// // System field: Creation time (auto-filled, do not modify)
|
|
83
|
+
// createdAt: customTimestamptz("_created_at").default(sql`CURRENT_TIMESTAMP`).notNull(),
|
|
84
|
+
// // System field: Creator (auto-filled, do not modify)
|
|
85
|
+
// createdBy: userProfile("_created_by"),
|
|
86
|
+
// // System field: Update time (auto-filled, do not modify)
|
|
87
|
+
// updatedAt: customTimestamptz("_updated_at").default(sql`CURRENT_TIMESTAMP`).notNull(),
|
|
88
|
+
// // System field: Updater (auto-filled, do not modify)
|
|
89
|
+
// updatedBy: userProfile("_updated_by"),
|
|
90
|
+
// });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NestFactory } from '@nestjs/core';
|
|
2
|
+
import { Logger } from '@nestjs/common';
|
|
3
|
+
import { configureApp } from '@lark-apaas/fullstack-nestjs-core';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { __express as hbsExpressEngine } from 'hbs';
|
|
6
|
+
|
|
7
|
+
import type { NestExpressApplication } from '@nestjs/platform-express';
|
|
8
|
+
import { AppModule } from './app.module';
|
|
9
|
+
|
|
10
|
+
async function bootstrap() {
|
|
11
|
+
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
|
12
|
+
abortOnError: process.env.NODE_ENV !== 'development',
|
|
13
|
+
});
|
|
14
|
+
await configureApp(app, {
|
|
15
|
+
disableSwagger: true,
|
|
16
|
+
});
|
|
17
|
+
const logger = new Logger('Bootstrap');
|
|
18
|
+
const host = process.env.SERVER_HOST || 'localhost';
|
|
19
|
+
const port = Number(process.env.SERVER_PORT || '3000');
|
|
20
|
+
|
|
21
|
+
// 注册视图引擎, 渲染 client 目录下的 html 文件
|
|
22
|
+
app.setBaseViewsDir(join(process.cwd(), 'dist/client'));
|
|
23
|
+
app.setViewEngine('html');
|
|
24
|
+
app.engine('html', hbsExpressEngine);
|
|
25
|
+
|
|
26
|
+
await app.listen(port, host);
|
|
27
|
+
logger.log(`Server running on ${host}:${port}`);
|
|
28
|
+
logger.log(`API endpoints ready at http://${host}:${port}/api`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
bootstrap();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// /* 模板代码 仅作示例 */
|
|
2
|
+
// import { Controller, Get, Post, Put, Delete, Body, Param, Query, Req, ParseIntPipe } from '@nestjs/common';
|
|
3
|
+
// import type { Request } from 'express';
|
|
4
|
+
// import { HelloService } from './hello.service';
|
|
5
|
+
|
|
6
|
+
// @Controller('api/hello')
|
|
7
|
+
// export class HelloController {
|
|
8
|
+
// constructor(private readonly helloService: HelloService) {}
|
|
9
|
+
|
|
10
|
+
// @Get('test')
|
|
11
|
+
// async test(@Req() req: Request, @Query('limit') limit?: string) {
|
|
12
|
+
// const { userId } = req.userContext;
|
|
13
|
+
// const limitNum = limit ? parseInt(limit) : 5;
|
|
14
|
+
// return this.helloService.test(userId, limitNum);
|
|
15
|
+
// }
|
|
16
|
+
// }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* 模板代码 仅作示例 */
|
|
2
|
+
// import { Module } from '@nestjs/common';
|
|
3
|
+
// import { HelloController } from './hello.controller';
|
|
4
|
+
// import { HelloService } from './hello.service';
|
|
5
|
+
|
|
6
|
+
// @Module({
|
|
7
|
+
// controllers: [HelloController],
|
|
8
|
+
// providers: [HelloService],
|
|
9
|
+
// })
|
|
10
|
+
// export class HelloModule{}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// /* 模板代码 仅作示例 */
|
|
2
|
+
// import { Injectable, Inject, Logger } from '@nestjs/common';
|
|
3
|
+
// import { DRIZZLE_DATABASE, type PostgresJsDatabase } from '@lark-apaas/fullstack-nestjs-core';
|
|
4
|
+
// import { record } from '@server/database/schema';
|
|
5
|
+
// import { eq, and, count, desc, sql, gte, lte, or } from 'drizzle-orm';
|
|
6
|
+
|
|
7
|
+
// @Injectable()
|
|
8
|
+
// export class HelloService {
|
|
9
|
+
// private readonly logger = new Logger(HelloService.name);
|
|
10
|
+
|
|
11
|
+
// constructor(@Inject(DRIZZLE_DATABASE) private readonly db: PostgresJsDatabase) {}
|
|
12
|
+
|
|
13
|
+
// async test(userId: string, limit: number = 5) {
|
|
14
|
+
// try {
|
|
15
|
+
// const results = await this.db
|
|
16
|
+
// .select()
|
|
17
|
+
// .from(record)
|
|
18
|
+
// .where(eq(record.userProfile, userId))
|
|
19
|
+
// .orderBy(desc(record.speakDate))
|
|
20
|
+
// .limit(limit);
|
|
21
|
+
|
|
22
|
+
// return results;
|
|
23
|
+
// } catch (error) {
|
|
24
|
+
// this.logger.error('获取最近记录失败', error);
|
|
25
|
+
// throw error;
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Controller, Get, Render, Req } from '@nestjs/common';
|
|
2
|
+
import type { Request } from 'express';
|
|
3
|
+
|
|
4
|
+
@Controller()
|
|
5
|
+
export class ViewController {
|
|
6
|
+
|
|
7
|
+
@Get(['/', '*'])
|
|
8
|
+
@Render('index')
|
|
9
|
+
async render(@Req() req: Request): Promise<{ __platform__: string }> {
|
|
10
|
+
// you can add custom render params here
|
|
11
|
+
const platformData = req.__platform_data__ ?? {};
|
|
12
|
+
return {
|
|
13
|
+
// don't delete this line, it's used by client to get platform info
|
|
14
|
+
__platform__: JSON.stringify(platformData),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* 前后端共享的类型写在这里 */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@lark-apaas/fullstack-presets/lib/simple/tsconfig/tsconfig.app.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "./",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@client/*": ["client/*"],
|
|
7
|
+
"@shared/*": ["shared/*"],
|
|
8
|
+
"@/*": ["./client/src/*"],
|
|
9
|
+
"@lark-apaas/client-toolkit/tools/*": ["node_modules/@lark-apaas/client-toolkit/lib/apis/tools/*"]
|
|
10
|
+
},
|
|
11
|
+
"incremental": true,
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"client/**/*",
|
|
15
|
+
"shared/**/*"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules",
|
|
19
|
+
"dist",
|
|
20
|
+
"public",
|
|
21
|
+
"client/src/api/gen"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@lark-apaas/fullstack-presets/lib/simple/tsconfig/tsconfig.node.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "./",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@server/*": ["server/*"],
|
|
8
|
+
"@shared/*": ["shared/*"],
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"watchOptions": {
|
|
12
|
+
"excludeDirectories": ["node_modules/**"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["server/**/*", "shared/**/*.ts"],
|
|
15
|
+
"exclude": ["node_modules", "dist", "client", "**/*.spec.ts", "**/*.e2e-spec.ts"],
|
|
16
|
+
}
|