From b85979334e0fe032c56ba756ebfb47daddf43921 Mon Sep 17 00:00:00 2001 From: longdayi <13477510+longdayilongdayi@user.noreply.gitee.com> Date: Thu, 11 Jul 2024 11:00:51 +0800 Subject: [PATCH] init repo --- .dockerignore | 0 .gitignore | 230 ++++++++++++++++++ Dockerfile | 0 apps/server/.env.example | 0 apps/server/.eslintrc.js | 25 ++ apps/server/.prettierrc | 4 + apps/server/README.md | 73 ++++++ apps/server/nest-cli.json | 8 + apps/server/package.json | 72 ++++++ apps/server/src/app.controller.spec.ts | 22 ++ apps/server/src/app.controller.ts | 12 + apps/server/src/app.module.ts | 11 + apps/server/src/app.service.ts | 8 + apps/server/src/hello/hello.router.ts | 12 + apps/server/src/hello/hello.service.spec.ts | 18 ++ apps/server/src/hello/hello.service.ts | 10 + apps/server/src/main.ts | 12 + apps/server/src/trpc/trpc.module.ts | 13 + apps/server/src/trpc/trpc.router.ts | 25 ++ apps/server/src/trpc/trpc.service.spec.ts | 18 ++ apps/server/src/trpc/trpc.service.ts | 13 + apps/server/test/app.e2e-spec.ts | 24 ++ apps/server/test/jest-e2e.json | 9 + apps/server/tsconfig.build.json | 4 + apps/server/tsconfig.json | 22 ++ apps/web-client/.env.example | 0 apps/web-client/.eslintrc.cjs | 18 ++ apps/web-client/README.md | 30 +++ apps/web-client/index.html | 13 + apps/web-client/package.json | 40 +++ apps/web-client/postcss.config.js | 6 + apps/web-client/public/vite.svg | 1 + apps/web-client/src/App.css | 42 ++++ apps/web-client/src/App.tsx | 16 ++ apps/web-client/src/app/main/page.tsx | 4 + apps/web-client/src/assets/react.svg | 1 + apps/web-client/src/index.css | 3 + apps/web-client/src/main.tsx | 10 + .../src/providers/query-provider.tsx | 39 +++ apps/web-client/src/routes/error-page.tsx | 3 + apps/web-client/src/routes/index.tsx | 19 ++ apps/web-client/src/routes/root-layout.tsx | 5 + apps/web-client/src/utils/trpc.ts | 4 + apps/web-client/src/vite-env.d.ts | 1 + apps/web-client/tailwind.config.js | 11 + apps/web-client/tsconfig.app.json | 31 +++ apps/web-client/tsconfig.json | 11 + apps/web-client/tsconfig.node.json | 15 ++ apps/web-client/vite.config.ts | 12 + docker-compose.exmaple.yml | 136 +++++++++++ docker-compose.yml | 152 ++++++++++++ package.json | 13 + packages/common/.env.example | 1 + packages/common/package.json | 26 ++ packages/common/prisma/schema.prisma | 0 packages/common/tsconfig.json | 18 ++ pnpm-workspace.yaml | 7 + tsconfig.json | 22 ++ 58 files changed, 1355 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 apps/server/.env.example create mode 100644 apps/server/.eslintrc.js create mode 100644 apps/server/.prettierrc create mode 100644 apps/server/README.md create mode 100644 apps/server/nest-cli.json create mode 100644 apps/server/package.json create mode 100644 apps/server/src/app.controller.spec.ts create mode 100644 apps/server/src/app.controller.ts create mode 100644 apps/server/src/app.module.ts create mode 100644 apps/server/src/app.service.ts create mode 100644 apps/server/src/hello/hello.router.ts create mode 100644 apps/server/src/hello/hello.service.spec.ts create mode 100644 apps/server/src/hello/hello.service.ts create mode 100644 apps/server/src/main.ts create mode 100644 apps/server/src/trpc/trpc.module.ts create mode 100644 apps/server/src/trpc/trpc.router.ts create mode 100644 apps/server/src/trpc/trpc.service.spec.ts create mode 100644 apps/server/src/trpc/trpc.service.ts create mode 100644 apps/server/test/app.e2e-spec.ts create mode 100644 apps/server/test/jest-e2e.json create mode 100644 apps/server/tsconfig.build.json create mode 100644 apps/server/tsconfig.json create mode 100644 apps/web-client/.env.example create mode 100644 apps/web-client/.eslintrc.cjs create mode 100644 apps/web-client/README.md create mode 100644 apps/web-client/index.html create mode 100644 apps/web-client/package.json create mode 100644 apps/web-client/postcss.config.js create mode 100644 apps/web-client/public/vite.svg create mode 100644 apps/web-client/src/App.css create mode 100644 apps/web-client/src/App.tsx create mode 100644 apps/web-client/src/app/main/page.tsx create mode 100644 apps/web-client/src/assets/react.svg create mode 100644 apps/web-client/src/index.css create mode 100644 apps/web-client/src/main.tsx create mode 100644 apps/web-client/src/providers/query-provider.tsx create mode 100644 apps/web-client/src/routes/error-page.tsx create mode 100644 apps/web-client/src/routes/index.tsx create mode 100644 apps/web-client/src/routes/root-layout.tsx create mode 100644 apps/web-client/src/utils/trpc.ts create mode 100644 apps/web-client/src/vite-env.d.ts create mode 100644 apps/web-client/tailwind.config.js create mode 100644 apps/web-client/tsconfig.app.json create mode 100644 apps/web-client/tsconfig.json create mode 100644 apps/web-client/tsconfig.node.json create mode 100644 apps/web-client/vite.config.ts create mode 100755 docker-compose.exmaple.yml create mode 100755 docker-compose.yml create mode 100644 package.json create mode 100644 packages/common/.env.example create mode 100644 packages/common/package.json create mode 100644 packages/common/prisma/schema.prisma create mode 100644 packages/common/tsconfig.json create mode 100644 pnpm-workspace.yaml create mode 100644 tsconfig.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..298653b --- /dev/null +++ b/.gitignore @@ -0,0 +1,230 @@ +# Node.js +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# Logs +logs/ +*.log +npm-debug.log* +yarn-debug.log* +pnpm-debug.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids/ +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov/ + +# Coverage directory used by tools like istanbul +coverage/ +*.lcov + +# nyc test coverage +.nyc_output/ + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt/ + +# Bower dependency directory (https://bower.io/) +bower_components/ + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release/ + +# Dependency directories +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm/ + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.* +!.env.example + +# Parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next/ +out/ + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus +.build + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# Yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# Vite local server cache +.vite + +# Vitest cache +.vitest + +# Storybook build outputs +.out/ +.storybook-out/ + +# Monorepo-specific +apps/*/node_modules/ +apps/*/dist/ +apps/*/build/ +apps/*/.turbo/ +apps/*/.next/ +apps/*/.nuxt/ +apps/*/.cache/ +apps/*/.parcel-cache/ +apps/*/.vuepress/dist +apps/*/.docusaurus +apps/*/.build +apps/*/.serverless +apps/*/.fusebox +apps/*/.dynamodb +apps/*/.tern-port +apps/*/.vscode-test +apps/*/.yarn +apps/*/.vite +apps/*/.vitest +apps/*/.out +apps/*/.storybook-out + +packages/*/node_modules/ +packages/*/dist/ +packages/*/build/ +packages/*/.turbo/ +packages/*/.next/ +packages/*/.nuxt/ +packages/*/.cache/ +packages/*/.parcel-cache/ +packages/*/.vuepress/dist +packages/*/.docusaurus +packages/*/.build +packages/*/.serverless +packages/*/.fusebox +packages/*/.dynamodb +packages/*/.tern-port +packages/*/.vscode-test +packages/*/.yarn +packages/*/.vite +packages/*/.vitest +packages/*/.out +packages/*/.storybook-out + +libs/*/node_modules/ +libs/*/dist/ +libs/*/build/ +libs/*/.turbo/ +libs/*/.next/ +libs/*/.nuxt/ +libs/*/.cache/ +libs/*/.parcel-cache/ +libs/*/.vuepress/dist +libs/*/.docusaurus +libs/*/.build +libs/*/.serverless +libs/*/.fusebox +libs/*/.dynamodb +libs/*/.tern-port +libs/*/.vscode-test +libs/*/.yarn +libs/*/.vite +libs/*/.vitest +libs/*/.out +libs/*/.storybook-out + +# Ignore lockfiles +**/package-lock.json +**/yarn.lock +**/pnpm-lock.yaml + +# IDEs and editors +.vscode/ +.idea/ +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# MacOS +.DS_Store + +# Windows +Thumbs.db +ehthumbs.db +Desktop.ini +$RECYCLE.BIN/ + +# Linux +*~ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/apps/server/.env.example b/apps/server/.env.example new file mode 100644 index 0000000..e69de29 diff --git a/apps/server/.eslintrc.js b/apps/server/.eslintrc.js new file mode 100644 index 0000000..259de13 --- /dev/null +++ b/apps/server/.eslintrc.js @@ -0,0 +1,25 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + project: 'tsconfig.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + }, + plugins: ['@typescript-eslint/eslint-plugin'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + root: true, + env: { + node: true, + jest: true, + }, + ignorePatterns: ['.eslintrc.js'], + rules: { + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + }, +}; diff --git a/apps/server/.prettierrc b/apps/server/.prettierrc new file mode 100644 index 0000000..dcb7279 --- /dev/null +++ b/apps/server/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "trailingComma": "all" +} \ No newline at end of file diff --git a/apps/server/README.md b/apps/server/README.md new file mode 100644 index 0000000..f5aa86c --- /dev/null +++ b/apps/server/README.md @@ -0,0 +1,73 @@ +

+ Nest Logo +

+ +[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 +[circleci-url]: https://circleci.com/gh/nestjs/nest + +

A progressive Node.js framework for building efficient and scalable server-side applications.

+

+NPM Version +Package License +NPM Downloads +CircleCI +Coverage +Discord +Backers on Open Collective +Sponsors on Open Collective + + Support us + +

+ + +## Description + +[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. + +## Installation + +```bash +$ pnpm install +``` + +## Running the app + +```bash +# development +$ pnpm run start + +# watch mode +$ pnpm run start:dev + +# production mode +$ pnpm run start:prod +``` + +## Test + +```bash +# unit tests +$ pnpm run test + +# e2e tests +$ pnpm run test:e2e + +# test coverage +$ pnpm run test:cov +``` + +## Support + +Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). + +## Stay in touch + +- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) +- Website - [https://nestjs.com](https://nestjs.com/) +- Twitter - [@nestframework](https://twitter.com/nestframework) + +## License + +Nest is [MIT licensed](LICENSE). diff --git a/apps/server/nest-cli.json b/apps/server/nest-cli.json new file mode 100644 index 0000000..f9aa683 --- /dev/null +++ b/apps/server/nest-cli.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/nest-cli", + "collection": "@nestjs/schematics", + "sourceRoot": "src", + "compilerOptions": { + "deleteOutDir": true + } +} diff --git a/apps/server/package.json b/apps/server/package.json new file mode 100644 index 0000000..c7d4355 --- /dev/null +++ b/apps/server/package.json @@ -0,0 +1,72 @@ +{ + "name": "server", + "version": "0.0.1", + "description": "", + "author": "", + "private": true, + "license": "UNLICENSED", + "scripts": { + "build": "nest build", + "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "start": "nest start", + "dev": "nest start --watch", + "start:debug": "nest start --debug --watch", + "start:prod": "node dist/main", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:cov": "jest --coverage", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "test:e2e": "jest --config ./test/jest-e2e.json" + }, + "dependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/core": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "@trpc/server": "11.0.0-rc.456", + "reflect-metadata": "^0.2.0", + "rxjs": "^7.8.1", + "superjson-cjs": "^2.2.3", + "zod": "^3.23.8" + }, + "devDependencies": { + "@nestjs/cli": "^10.0.0", + "@nestjs/schematics": "^10.0.0", + "@nestjs/testing": "^10.0.0", + "@types/express": "^4.17.17", + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "@types/supertest": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^6.0.0", + "@typescript-eslint/parser": "^6.0.0", + "eslint": "^8.42.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.5.0", + "prettier": "^3.0.0", + "source-map-support": "^0.5.21", + "supertest": "^6.3.3", + "ts-jest": "^29.1.0", + "ts-loader": "^9.4.3", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "typescript": "^5.1.3" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": "src", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } +} \ No newline at end of file diff --git a/apps/server/src/app.controller.spec.ts b/apps/server/src/app.controller.spec.ts new file mode 100644 index 0000000..d22f389 --- /dev/null +++ b/apps/server/src/app.controller.spec.ts @@ -0,0 +1,22 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; + +describe('AppController', () => { + let appController: AppController; + + beforeEach(async () => { + const app: TestingModule = await Test.createTestingModule({ + controllers: [AppController], + providers: [AppService], + }).compile(); + + appController = app.get(AppController); + }); + + describe('root', () => { + it('should return "Hello World!"', () => { + expect(appController.getHello()).toBe('Hello World!'); + }); + }); +}); diff --git a/apps/server/src/app.controller.ts b/apps/server/src/app.controller.ts new file mode 100644 index 0000000..cce879e --- /dev/null +++ b/apps/server/src/app.controller.ts @@ -0,0 +1,12 @@ +import { Controller, Get } from '@nestjs/common'; +import { AppService } from './app.service'; + +@Controller() +export class AppController { + constructor(private readonly appService: AppService) {} + + @Get() + getHello(): string { + return this.appService.getHello(); + } +} diff --git a/apps/server/src/app.module.ts b/apps/server/src/app.module.ts new file mode 100644 index 0000000..abe041e --- /dev/null +++ b/apps/server/src/app.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; +import { TrpcModule } from './trpc/trpc.module'; + +@Module({ + imports: [TrpcModule], + controllers: [AppController], + providers: [AppService], +}) +export class AppModule { } diff --git a/apps/server/src/app.service.ts b/apps/server/src/app.service.ts new file mode 100644 index 0000000..927d7cc --- /dev/null +++ b/apps/server/src/app.service.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class AppService { + getHello(): string { + return 'Hello World!'; + } +} diff --git a/apps/server/src/hello/hello.router.ts b/apps/server/src/hello/hello.router.ts new file mode 100644 index 0000000..c26196f --- /dev/null +++ b/apps/server/src/hello/hello.router.ts @@ -0,0 +1,12 @@ +import { Injectable } from '@nestjs/common'; +import { TrpcService } from '@server/trpc/trpc.service'; +import { HelloService } from './hello.service'; + +@Injectable() +export class HelloRouter { + constructor(private readonly trpc: TrpcService, private readonly hello: HelloService) { } + router = this.trpc.router({ + hello: this.trpc.procedure.query(() => this.hello.helloWorld()), + }); +} + diff --git a/apps/server/src/hello/hello.service.spec.ts b/apps/server/src/hello/hello.service.spec.ts new file mode 100644 index 0000000..edfe4f9 --- /dev/null +++ b/apps/server/src/hello/hello.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { HelloService } from './hello.service'; + +describe('HelloService', () => { + let service: HelloService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [HelloService], + }).compile(); + + service = module.get(HelloService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/apps/server/src/hello/hello.service.ts b/apps/server/src/hello/hello.service.ts new file mode 100644 index 0000000..960230f --- /dev/null +++ b/apps/server/src/hello/hello.service.ts @@ -0,0 +1,10 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class HelloService { + helloWorld() { + return { + greeting: `Hello world`, + }; + } +} diff --git a/apps/server/src/main.ts b/apps/server/src/main.ts new file mode 100644 index 0000000..c99c6da --- /dev/null +++ b/apps/server/src/main.ts @@ -0,0 +1,12 @@ +import { NestFactory } from '@nestjs/core'; +import { AppModule } from './app.module'; +import { TrpcRouter } from './trpc/trpc.router'; + +async function bootstrap() { + const app = await NestFactory.create(AppModule); + app.enableCors(); + const trpc = app.get(TrpcRouter); + trpc.applyMiddleware(app); + await app.listen(3000); +} +bootstrap(); diff --git a/apps/server/src/trpc/trpc.module.ts b/apps/server/src/trpc/trpc.module.ts new file mode 100644 index 0000000..2ebd7a2 --- /dev/null +++ b/apps/server/src/trpc/trpc.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common'; +import { TrpcService } from './trpc.service'; +import { TrpcRouter } from './trpc.router'; +import { HelloService } from '@server/hello/hello.service'; +import { HelloRouter } from '@server/hello/hello.router'; + +@Module({ + imports: [], + controllers: [], + providers: [TrpcService, TrpcRouter, HelloRouter, HelloService], +}) +export class TrpcModule { } + diff --git a/apps/server/src/trpc/trpc.router.ts b/apps/server/src/trpc/trpc.router.ts new file mode 100644 index 0000000..7ecf6c0 --- /dev/null +++ b/apps/server/src/trpc/trpc.router.ts @@ -0,0 +1,25 @@ +import { INestApplication, Injectable } from '@nestjs/common'; +import { TrpcService } from '@server/trpc/trpc.service'; +import * as trpcExpress from '@trpc/server/adapters/express'; +import { HelloRouter } from '@server/hello/hello.router'; + +@Injectable() +export class TrpcRouter { + constructor(private readonly trpc: TrpcService, private readonly hello: HelloRouter) { } + + appRouter = this.trpc.router({ + hello: this.hello.router + }); + + async applyMiddleware(app: INestApplication) { + app.use( + `/trpc`, + trpcExpress.createExpressMiddleware({ + router: this.appRouter, + }), + ); + } +} + +export type AppRouter = TrpcRouter[`appRouter`]; + diff --git a/apps/server/src/trpc/trpc.service.spec.ts b/apps/server/src/trpc/trpc.service.spec.ts new file mode 100644 index 0000000..16bfcf0 --- /dev/null +++ b/apps/server/src/trpc/trpc.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { TrpcService } from './trpc.service'; + +describe('TrpcService', () => { + let service: TrpcService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [TrpcService], + }).compile(); + + service = module.get(TrpcService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/apps/server/src/trpc/trpc.service.ts b/apps/server/src/trpc/trpc.service.ts new file mode 100644 index 0000000..33d333b --- /dev/null +++ b/apps/server/src/trpc/trpc.service.ts @@ -0,0 +1,13 @@ +import { Injectable } from '@nestjs/common'; +import { initTRPC } from '@trpc/server'; +import superjson from 'superjson-cjs'; + +@Injectable() +export class TrpcService { + trpc = initTRPC.create({ + transformer: superjson + }); + procedure = this.trpc.procedure; + router = this.trpc.router; + mergeRouters = this.trpc.mergeRouters; +} diff --git a/apps/server/test/app.e2e-spec.ts b/apps/server/test/app.e2e-spec.ts new file mode 100644 index 0000000..50cda62 --- /dev/null +++ b/apps/server/test/app.e2e-spec.ts @@ -0,0 +1,24 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { INestApplication } from '@nestjs/common'; +import * as request from 'supertest'; +import { AppModule } from './../src/app.module'; + +describe('AppController (e2e)', () => { + let app: INestApplication; + + beforeEach(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [AppModule], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + it('/ (GET)', () => { + return request(app.getHttpServer()) + .get('/') + .expect(200) + .expect('Hello World!'); + }); +}); diff --git a/apps/server/test/jest-e2e.json b/apps/server/test/jest-e2e.json new file mode 100644 index 0000000..e9d912f --- /dev/null +++ b/apps/server/test/jest-e2e.json @@ -0,0 +1,9 @@ +{ + "moduleFileExtensions": ["js", "json", "ts"], + "rootDir": ".", + "testEnvironment": "node", + "testRegex": ".e2e-spec.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + } +} diff --git a/apps/server/tsconfig.build.json b/apps/server/tsconfig.build.json new file mode 100644 index 0000000..64f86c6 --- /dev/null +++ b/apps/server/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/apps/server/tsconfig.json b/apps/server/tsconfig.json new file mode 100644 index 0000000..55da539 --- /dev/null +++ b/apps/server/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + // "baseUrl": "./", + // "incremental": true, + // "skipLibCheck": true, + // "strictNullChecks": false, + // "noImplicitAny": false, + // "strictBindCallApply": false, + // "forceConsistentCasingInFileNames": false, + // "noFallthroughCasesInSwitch": false + } +} \ No newline at end of file diff --git a/apps/web-client/.env.example b/apps/web-client/.env.example new file mode 100644 index 0000000..e69de29 diff --git a/apps/web-client/.eslintrc.cjs b/apps/web-client/.eslintrc.cjs new file mode 100644 index 0000000..d6c9537 --- /dev/null +++ b/apps/web-client/.eslintrc.cjs @@ -0,0 +1,18 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, +} diff --git a/apps/web-client/README.md b/apps/web-client/README.md new file mode 100644 index 0000000..0d6babe --- /dev/null +++ b/apps/web-client/README.md @@ -0,0 +1,30 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: + +- Configure the top-level `parserOptions` property like this: + +```js +export default { + // other rules... + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: ['./tsconfig.json', './tsconfig.node.json'], + tsconfigRootDir: __dirname, + }, +} +``` + +- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` +- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/apps/web-client/index.html b/apps/web-client/index.html new file mode 100644 index 0000000..e4b78ea --- /dev/null +++ b/apps/web-client/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/apps/web-client/package.json b/apps/web-client/package.json new file mode 100644 index 0000000..e07f921 --- /dev/null +++ b/apps/web-client/package.json @@ -0,0 +1,40 @@ +{ + "name": "web-client", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "@tanstack/react-form": "^0.26.3", + "@tanstack/react-query": "^5.50.1", + "@tanstack/zod-form-adapter": "^0.26.3", + "@trpc/client": "11.0.0-rc.456", + "@trpc/react-query": "11.0.0-rc.456", + "@trpc/server": "11.0.0-rc.456", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-router-dom": "^6.24.1", + "superjson": "^2.2.1", + "zod": "^3.23.8" + }, + "devDependencies": { + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", + "@typescript-eslint/eslint-plugin": "^7.13.1", + "@typescript-eslint/parser": "^7.13.1", + "@vitejs/plugin-react-swc": "^3.5.0", + "autoprefixer": "^10.4.19", + "eslint": "^8.57.0", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-refresh": "^0.4.7", + "postcss": "^8.4.39", + "tailwindcss": "^3.4.4", + "typescript": "^5.2.2", + "vite": "^5.3.1" + } +} \ No newline at end of file diff --git a/apps/web-client/postcss.config.js b/apps/web-client/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/apps/web-client/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/apps/web-client/public/vite.svg b/apps/web-client/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/apps/web-client/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web-client/src/App.css b/apps/web-client/src/App.css new file mode 100644 index 0000000..b9d355d --- /dev/null +++ b/apps/web-client/src/App.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/apps/web-client/src/App.tsx b/apps/web-client/src/App.tsx new file mode 100644 index 0000000..73e61a3 --- /dev/null +++ b/apps/web-client/src/App.tsx @@ -0,0 +1,16 @@ +import './App.css' +import { + RouterProvider, +} from "react-router-dom"; +import QueryProvider from './providers/query-provider' +import { router } from './routes'; +function App() { + + return ( + + + + ) +} + +export default App diff --git a/apps/web-client/src/app/main/page.tsx b/apps/web-client/src/app/main/page.tsx new file mode 100644 index 0000000..b7f1d2e --- /dev/null +++ b/apps/web-client/src/app/main/page.tsx @@ -0,0 +1,4 @@ +export default function MainPage() { + return <>hello,world +} + diff --git a/apps/web-client/src/assets/react.svg b/apps/web-client/src/assets/react.svg new file mode 100644 index 0000000..6c87de9 --- /dev/null +++ b/apps/web-client/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web-client/src/index.css b/apps/web-client/src/index.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/apps/web-client/src/index.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/apps/web-client/src/main.tsx b/apps/web-client/src/main.tsx new file mode 100644 index 0000000..3d7150d --- /dev/null +++ b/apps/web-client/src/main.tsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import App from './App.tsx' +import './index.css' + +ReactDOM.createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/apps/web-client/src/providers/query-provider.tsx b/apps/web-client/src/providers/query-provider.tsx new file mode 100644 index 0000000..c1f0920 --- /dev/null +++ b/apps/web-client/src/providers/query-provider.tsx @@ -0,0 +1,39 @@ +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { unstable_httpBatchStreamLink, loggerLink } from '@trpc/client'; +import React, { useState } from 'react'; +import { api } from '../utils/trpc'; +import superjson from 'superjson'; + +export default function QueryProvider({ children }: { children: React.ReactNode }) { + const [queryClient] = useState(() => new QueryClient()); + const [trpcClient] = useState(() => + api.createClient({ + + links: [ + unstable_httpBatchStreamLink({ + url: 'http://localhost:3000/trpc', + // You can pass any HTTP headers you wish here + async headers() { + return { + // authorization: getAuthCookie(), + }; + }, + transformer: superjson + }), + loggerLink({ + enabled: (opts) => + (process.env.NODE_ENV === 'development' && + typeof window !== 'undefined') || + (opts.direction === 'down' && opts.result instanceof Error), + }), + ], + }), + ); + return ( + + + {children} + + + ); +} \ No newline at end of file diff --git a/apps/web-client/src/routes/error-page.tsx b/apps/web-client/src/routes/error-page.tsx new file mode 100644 index 0000000..a9b046d --- /dev/null +++ b/apps/web-client/src/routes/error-page.tsx @@ -0,0 +1,3 @@ +export default function ErrorPage() { + return <>404 +} \ No newline at end of file diff --git a/apps/web-client/src/routes/index.tsx b/apps/web-client/src/routes/index.tsx new file mode 100644 index 0000000..4f7c5dc --- /dev/null +++ b/apps/web-client/src/routes/index.tsx @@ -0,0 +1,19 @@ +import { + createBrowserRouter +} from "react-router-dom"; +import MainPage from "../app/main/page"; +import RootLayout from "./root-layout"; +import ErrorPage from './error-page'; +export const router = createBrowserRouter([ + { + path: "/", + element: , + errorElement: , + children: [ + { + index: true, + element: + } + ] + }, +]); diff --git a/apps/web-client/src/routes/root-layout.tsx b/apps/web-client/src/routes/root-layout.tsx new file mode 100644 index 0000000..e66960e --- /dev/null +++ b/apps/web-client/src/routes/root-layout.tsx @@ -0,0 +1,5 @@ +import { Outlet } from "react-router-dom"; + +export default function RootLayout() { + return <> +} \ No newline at end of file diff --git a/apps/web-client/src/utils/trpc.ts b/apps/web-client/src/utils/trpc.ts new file mode 100644 index 0000000..ebcc577 --- /dev/null +++ b/apps/web-client/src/utils/trpc.ts @@ -0,0 +1,4 @@ +import { createTRPCReact } from '@trpc/react-query'; +import type { AppRouter } from '@server/trpc/trpc.router'; + +export const api = createTRPCReact(); \ No newline at end of file diff --git a/apps/web-client/src/vite-env.d.ts b/apps/web-client/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/apps/web-client/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/apps/web-client/tailwind.config.js b/apps/web-client/tailwind.config.js new file mode 100644 index 0000000..89a305e --- /dev/null +++ b/apps/web-client/tailwind.config.js @@ -0,0 +1,11 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + "./index.html", + "./src/**/*.{js,ts,jsx,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [], +} \ No newline at end of file diff --git a/apps/web-client/tsconfig.app.json b/apps/web-client/tsconfig.app.json new file mode 100644 index 0000000..ae24b1e --- /dev/null +++ b/apps/web-client/tsconfig.app.json @@ -0,0 +1,31 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], + "module": "ESNext", + "skipLibCheck": true, + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + }, + "include": [ + "src" + ] +} \ No newline at end of file diff --git a/apps/web-client/tsconfig.json b/apps/web-client/tsconfig.json new file mode 100644 index 0000000..65f670c --- /dev/null +++ b/apps/web-client/tsconfig.json @@ -0,0 +1,11 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.node.json" + } + ] +} \ No newline at end of file diff --git a/apps/web-client/tsconfig.node.json b/apps/web-client/tsconfig.node.json new file mode 100644 index 0000000..8a58917 --- /dev/null +++ b/apps/web-client/tsconfig.node.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true, + "noEmit": true + }, + "include": [ + "vite.config.ts" + ] +} \ No newline at end of file diff --git a/apps/web-client/vite.config.ts b/apps/web-client/vite.config.ts new file mode 100644 index 0000000..cb316a4 --- /dev/null +++ b/apps/web-client/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react-swc' +import path from 'path'; +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], + resolve: { + alias: { + '@web': path.resolve(__dirname), + } + } +}) diff --git a/docker-compose.exmaple.yml b/docker-compose.exmaple.yml new file mode 100755 index 0000000..3805e70 --- /dev/null +++ b/docker-compose.exmaple.yml @@ -0,0 +1,136 @@ +version: "3.8" + +services: + db: + image: postgres:latest + ports: + - "5432:5432" + environment: + - POSTGRES_DB=lxminiapp + - POSTGRES_USER=root + - POSTGRES_PASSWORD=Letusdoit000 + volumes: + - ./volumes/postgres:/var/lib/postgresql/data + minio: + image: minio/minio + ports: + - "9000:9000" + - "9001:9001" + volumes: + - ./volumes/minio:/minio_data + environment: + - MINIO_ACCESS_KEY=minioadmin + - MINIO_SECRET_KEY=minioadmin + command: minio server /minio_data --console-address ":9001" -address ":9000" + healthcheck: + test: + [ + "CMD", + "curl", + "-f", + "http://localhost:9001/minio/health/live" + ] + interval: 30s + timeout: 20s + retries: 3 + etcd: + container_name: milvus-etcd + image: quay.io/coreos/etcd:v3.5.5 + environment: + - ETCD_AUTO_COMPACTION_MODE=revision + - ETCD_AUTO_COMPACTION_RETENTION=1000 + - ETCD_QUOTA_BACKEND_BYTES=4294967296 + - ETCD_SNAPSHOT_COUNT=50000 + volumes: + - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd + command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd + healthcheck: + test: [ "CMD", "etcdctl", "endpoint", "health" ] + interval: 30s + timeout: 20s + retries: 3 + standalone: + container_name: milvus-standalone + image: milvusdb/milvus:v2.4.4 + command: [ "milvus", "run", "standalone" ] + security_opt: + - seccomp:unconfined + environment: + ETCD_ENDPOINTS: etcd:2379 + MINIO_ADDRESS: minio:9000 + volumes: + - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:9091/healthz" ] + interval: 30s + start_period: 90s + timeout: 20s + retries: 3 + ports: + - "19530:19530" + - "9091:9091" + depends_on: + - "etcd" + - "minio" + pgadmin: + image: dpage/pgadmin4 + ports: + - "8081:80" + environment: + - PGADMIN_DEFAULT_EMAIL=insiinc@outlook.com + - PGADMIN_DEFAULT_PASSWORD=Letusdoit000 + tusd: + image: tusproject/tusd + ports: + - "8080:8080" + environment: + - AWS_REGION=cn-north-1 + - AWS_ACCESS_KEY_ID=minioadmin + - AWS_SECRET_ACCESS_KEY=minioadmin + + command: -verbose -s3-bucket lxminiapp -s3-endpoint http://minio:9000 + volumes: + - ./volumes/tusd:/data + # app: + # image: lxminiapp + # ports: + # - "3000:80" + # environment: + # - DATABASE_URL=postgresql://root:Letusdoit000@192.168.129.77:5432/lxminiapp?encoding=UTF8 + # - REACT_APP_LX_APPID=13960192-15278080 + # - REACT_APP_APP_URL=http://192.168.129.77:3000 + # - REACT_APP_TUS_URL=http://192.168.129.77:8080 + # - REACT_APP_BACKEND_URL=http://192.168.129.77:3010 + # - REACT_APP_APP_NAME=两道防线 + # - REACT_APP_IMPORT_SDK=TRUE + # depends_on: + # - db + # - tusd + + # worker: + # image: worker + # ports: + # - "3010:3010" + # environment: + # - DATABASE_URL=postgresql://root:Letusdoit000@192.168.129.77:5432/lxminiapp?encoding=UTF8 + # - LX_APPID=13960192-15278080 + # - LX_SECRET=D9265475844D913CB9AD09D33D8BE0F9 + # - LX_APIGW_DOMAIN=https://lxpub-cloud2.lanxin.cn:10443/open/apigw + # - LX_PASSPORT_DOMAIN=https://lxpub-cloud2.lanxin.cn:10443/user/passport + # - TUS_URL=http://192.168.129.77:8080 + # - APP_URL=http://192.168.129.77:3000 + # - LX_ORG_ID=13960192-0 + # - ADMIN_ID=13960192-JWuR2tnrb8YbI9G5ggBfxnrmvcJYj6lr + # - ORG_SYNC_CRON=0 0 3 * * * + # - DEADLINE_CRON=0 0 8 * * * + # - APP_NAME=两道防线 + # depends_on: + # - db + # command: node server.js + # volumes: + # - worker-data:/app +volumes: + worker-data: +networks: + default: + name: lxminiapp diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..f67ada5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,152 @@ +version: "3.8" + +services: + db: + image: postgres-vector:latest + ports: + - "5432:5432" + environment: + - POSTGRES_DB=lxminiapp + - POSTGRES_USER=root + - POSTGRES_PASSWORD=Letusdoit000 + volumes: + - ./volumes/postgres:/var/lib/postgresql/data + minio: + image: minio/minio + ports: + - "9000:9000" + - "9001:9001" + volumes: + - ./volumes/minio:/data + environment: + - MINIO_ACCESS_KEY=minioadmin + - MINIO_SECRET_KEY=minioadmin + command: server /data --console-address ":9001" -address ":9000" + healthcheck: + test: + [ + "CMD", + "curl", + "-f", + "http://localhost:9001/minio/health/live" + ] + interval: 30s + timeout: 20s + retries: 3 + etcd: + container_name: milvus-etcd + image: quay.io/coreos/etcd:v3.5.5 + environment: + - ETCD_AUTO_COMPACTION_MODE=revision + - ETCD_AUTO_COMPACTION_RETENTION=1000 + - ETCD_QUOTA_BACKEND_BYTES=4294967296 + - ETCD_SNAPSHOT_COUNT=50000 + volumes: + - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd + command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd + healthcheck: + test: [ "CMD", "etcdctl", "endpoint", "health" ] + interval: 30s + timeout: 20s + retries: 3 + standalone: + container_name: milvus-standalone + image: milvusdb/milvus:v2.4.4 + command: [ "milvus", "run", "standalone" ] + security_opt: + - seccomp:unconfined + environment: + ETCD_ENDPOINTS: etcd:2379 + MINIO_ADDRESS: minio:9000 + volumes: + - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:9091/healthz" ] + interval: 30s + start_period: 90s + timeout: 20s + retries: 3 + ports: + - "19530:19530" + - "9091:9091" + depends_on: + - "etcd" + - "minio" + pgadmin: + image: dpage/pgadmin4 + ports: + - "8081:80" + environment: + - PGADMIN_DEFAULT_EMAIL=insiinc@outlook.com + - PGADMIN_DEFAULT_PASSWORD=Letusdoit000 + tusd: + image: tusproject/tusd + ports: + - "8080:8080" + environment: + - AWS_REGION=cn-north-1 + - AWS_ACCESS_KEY_ID=minioadmin + - AWS_SECRET_ACCESS_KEY=minioadmin + + command: -verbose -s3-bucket lxminiapp -s3-endpoint http://minio:9000 + volumes: + - ./volumes/tusd:/data + aiservice: + image: aiservice:latest + ports: + - "8000:8000" + environment: + - DATABASE_URL=postgresql://root:Letusdoit000@192.168.197.77:5432/lxminiapp + - MILVUS_URL=http://192.168.197.77:19530 + - TUS_URL=http://192.168.197.77:8080 + - APP_URL=http://192.168.197.77:3000 + volumes: + - ./apps/ai-service:/app + app: + image: front-app + ports: + - "3000:80" + environment: + - REACT_APP_BACKEND_URL=http://192.168.197.77:3010 + - REACT_APP_APP_NAME=两道防线 + - REACT_APP_LX_APPID=13960192-15278080 + - REACT_APP_TUS_URL=http://192.168.197.77:8080 + - REACT_APP_APP_URL=http://192.168.197.77:3000 + - REACT_APP_LX_ORG_ID=13960192-P9umMFP0J6wHAwDOO0FwPnJrSzo + - REACT_APP_LX_PASSPORT_DOMAIN=https://lxpub-cloud2.lanxin.cn:10443/user/passport + depends_on: + - db + - tusd + worker: + image: worker + ports: + - "3010:3010" + environment: + - DATABASE_URL=postgresql://root:Letusdoit000@192.168.197.77:5432/lxminiapp + - AI_SERVICE_URL=http://192.168.197.77:8000 + - LX_APPID=13960192-15278080 + - LX_SECRET=D9265475844D913CB9AD09D33D8BE0F9 + - LX_APIGW_DOMAIN=https://lxpub-cloud2.lanxin.cn:10443/open/apigw + - LX_PASSPORT_DOMAIN=https://lxpub-cloud2.lanxin.cn:10443/user/passport + - LX_ORG_ID=13960192-P9umMFP0J6wHAwDOO0FwPnJrSzo + - APP_URL=http://192.168.197.77:3000 + - TUS_URL=http://192.168.197.77:8080 + - ADMIN_ID=13960192-JWuR2tnrb8YbI9G5ggBfxnrmvcJYj6lr + - ORG_SYNC_CRON=0 0 3 * * * + - DEADLINE_CRON=0 0 8 * * * + - MAIN_NODE=true + - APP_NAME=两道防线 + depends_on: + - db + # command: node server.js + # volumes: + # - ./volumes/worker:/app + # redis: + # image: redis:latest + # ports: + # - "6379:6379" + # volumes: + # - redis_data:/data + # restart: always +volumes: + worker-data: # redis_data: diff --git a/package.json b/package.json new file mode 100644 index 0000000..34ecc7c --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "nice-stack", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "dev": "pnpm run --parallel dev" + }, + "keywords": [], + "author": "", + "license": "ISC" +} \ No newline at end of file diff --git a/packages/common/.env.example b/packages/common/.env.example new file mode 100644 index 0000000..d780ca4 --- /dev/null +++ b/packages/common/.env.example @@ -0,0 +1 @@ +DATABASE_URL=postgresql://root:Letusdoit000@192.168.197.77:5432/lxminiapp \ No newline at end of file diff --git a/packages/common/package.json b/packages/common/package.json new file mode 100644 index 0000000..cfd9cfb --- /dev/null +++ b/packages/common/package.json @@ -0,0 +1,26 @@ +{ + "name": "@nicestack/common", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "generate": "pnpm prisma generate", + "build": "pnpm generate && tsc -p tsconfig.json", + "build:watch": "tsc -p tsconfig.json -w --preserveWatchOutput", + "studio": "pnpm prisma studio", + "db:clear": "rm -rf prisma/migrations && pnpm prisma migrate dev" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@prisma/client": "^5.16.2" + }, + "devDependencies": { + "@types/node": "^20.3.1", + "ts-node": "^10.9.1", + "typescript": "^5.5.3" + } +} \ No newline at end of file diff --git a/packages/common/prisma/schema.prisma b/packages/common/prisma/schema.prisma new file mode 100644 index 0000000..e69de29 diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json new file mode 100644 index 0000000..7f84a73 --- /dev/null +++ b/packages/common/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "outDir": "./dist", + "target": "ES2021", + "module": "CommonJS", + "declaration": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + }, + "include": [ + "." + ], + "exclude": [ + "prisma", + "node_modules", + "dist" + ] +} \ No newline at end of file diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..9bd989e --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,7 @@ +packages: + # all packages in direct subdirs of packages/ + - 'packages/*' + - 'apps/*' + - 'libs/*' + # exclude packages that are inside test directories + # - '!**/test/**' \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4acddeb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": true, + "noImplicitAny": true, + "strictBindCallApply": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "paths": { + "@server/*": [ + "./apps/server/src/*" + ], + "@web/*": [ + "./apps/web-client/*" + ] + } + } +} \ No newline at end of file