From e9422a047e08dd3e08c1528e1e5c851a274a8a3c Mon Sep 17 00:00:00 2001 From: "amplication[bot]" <100755160+amplication[bot]@users.noreply.github.com> Date: Fri, 28 Jul 2023 05:34:16 +0000 Subject: [PATCH] Amplication build # clkm5evo108xfks01a5sal82g Congratulations on your first commit with Amplication! We encourage you to continue exploring the many ways Amplication can supercharge your development. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you find Amplication useful, please show your support and give our GitHub repo a star ⭐️ This simple action helps our open-source project grow and reach more developers like you. Thank you and happy coding! Build URL: [https://app.amplication.com/clkm5d4m708wrks01bpjkfdi4/clkm5d4zf08wuks01qbhw2q2e/clkm5euu508x0ks01b6iw9jtl/builds/clkm5evo108xfks01a5sal82g](https://app.amplication.com/clkm5d4m708wrks01bpjkfdi4/clkm5d4zf08wuks01qbhw2q2e/clkm5euu508x0ks01b6iw9jtl/builds/clkm5evo108xfks01a5sal82g) --- apps/jijyun-admin/.dockerignore | 7 + apps/jijyun-admin/.env | 2 + apps/jijyun-admin/.gitignore | 23 ++ apps/jijyun-admin/Dockerfile | 51 +++ apps/jijyun-admin/README.md | 47 +++ apps/jijyun-admin/configuration/nginx.conf | 11 + apps/jijyun-admin/package.json | 60 ++++ apps/jijyun-admin/public/favicon.ico | Bin 0 -> 6548 bytes apps/jijyun-admin/public/index.html | 40 +++ apps/jijyun-admin/public/logo192.png | Bin 0 -> 9721 bytes apps/jijyun-admin/public/logo512.png | Bin 0 -> 17361 bytes apps/jijyun-admin/public/manifest.json | 25 ++ apps/jijyun-admin/public/robots.txt | 3 + apps/jijyun-admin/src/App.scss | 59 ++++ apps/jijyun-admin/src/App.tsx | 38 +++ .../src/Components/Pagination.tsx | 10 + apps/jijyun-admin/src/Login.tsx | 117 +++++++ .../src/auth-provider/ra-auth-http.ts | 78 +++++ .../src/auth-provider/ra-auth-jwt.ts | 72 ++++ apps/jijyun-admin/src/auth.ts | 34 ++ apps/jijyun-admin/src/constants.ts | 2 + .../src/data-provider/graphqlDataProvider.ts | 28 ++ apps/jijyun-admin/src/index.css | 26 ++ apps/jijyun-admin/src/index.tsx | 19 ++ apps/jijyun-admin/src/login.scss | 119 +++++++ apps/jijyun-admin/src/pages/Dashboard.tsx | 12 + apps/jijyun-admin/src/reportWebVitals.ts | 17 + apps/jijyun-admin/src/setupTests.ts | 5 + apps/jijyun-admin/src/theme/theme.ts | 33 ++ apps/jijyun-admin/src/types.ts | 13 + apps/jijyun-admin/src/user/EnumRoles.ts | 3 + apps/jijyun-admin/src/user/RolesOptions.ts | 12 + apps/jijyun-admin/src/user/roles.ts | 6 + apps/jijyun-admin/src/util/BooleanFilter.ts | 4 + .../src/util/BooleanNullableFilter.ts | 4 + apps/jijyun-admin/src/util/DateTimeFilter.ts | 10 + .../src/util/DateTimeNullableFilter.ts | 10 + apps/jijyun-admin/src/util/FloatFilter.ts | 10 + .../src/util/FloatNullableFilter.ts | 10 + apps/jijyun-admin/src/util/IntFilter.ts | 10 + .../src/util/IntNullableFilter.ts | 10 + apps/jijyun-admin/src/util/JsonFilter.ts | 5 + .../src/util/JsonNullableFilter.ts | 5 + .../jijyun-admin/src/util/MetaQueryPayload.ts | 3 + apps/jijyun-admin/src/util/QueryMode.ts | 4 + apps/jijyun-admin/src/util/SortOrder.ts | 4 + apps/jijyun-admin/src/util/StringFilter.ts | 16 + .../src/util/StringNullableFilter.ts | 15 + apps/jijyun-admin/tsconfig.json | 21 ++ apps/jijyun/.dockerignore | 8 + apps/jijyun/.env | 8 + apps/jijyun/.gitignore | 5 + apps/jijyun/.prettierignore | 5 + apps/jijyun/Dockerfile | 68 ++++ apps/jijyun/README.md | 64 ++++ apps/jijyun/docker-compose.db.yml | 29 ++ apps/jijyun/docker-compose.yml | 56 +++ apps/jijyun/nest-cli.json | 6 + apps/jijyun/package.json | 68 ++++ apps/jijyun/prisma/schema.prisma | 8 + apps/jijyun/scripts/clean.ts | 58 ++++ apps/jijyun/scripts/customSeed.ts | 7 + apps/jijyun/scripts/seed.ts | 25 ++ apps/jijyun/src/app.module.ts | 46 +++ apps/jijyun/src/constants.ts | 2 + .../decorators/api-nested-query.decorator.ts | 80 +++++ .../jijyun/src/decorators/public.decorator.ts | 10 + apps/jijyun/src/errors.ts | 16 + .../src/filters/HttpExceptions.filter.ts | 92 +++++ .../src/health/base/health.controller.base.ts | 19 ++ .../src/health/base/health.service.base.ts | 15 + apps/jijyun/src/health/health.controller.ts | 10 + apps/jijyun/src/health/health.module.ts | 10 + apps/jijyun/src/health/health.service.ts | 10 + apps/jijyun/src/main.ts | 53 +++ apps/jijyun/src/prisma.util.spec.ts | 23 ++ apps/jijyun/src/prisma.util.ts | 30 ++ apps/jijyun/src/prisma/prisma.module.ts | 9 + apps/jijyun/src/prisma/prisma.service.ts | 15 + .../base/secretsManager.service.base.spec.ts | 39 +++ .../base/secretsManager.service.base.ts | 19 ++ .../secrets/secretsManager.module.ts | 8 + .../secrets/secretsManager.service.ts | 10 + apps/jijyun/src/serveStaticOptions.service.ts | 39 +++ apps/jijyun/src/swagger.ts | 20 ++ apps/jijyun/src/swagger/favicon.png | Bin 0 -> 2498 bytes .../src/swagger/logo-amplication-white.svg | 15 + apps/jijyun/src/swagger/swagger.css | 320 ++++++++++++++++++ .../src/tests/health/health.service.spec.ts | 36 ++ apps/jijyun/src/types.ts | 3 + apps/jijyun/src/util/BooleanFilter.ts | 32 ++ apps/jijyun/src/util/BooleanNullableFilter.ts | 31 ++ apps/jijyun/src/util/DateTimeFilter.ts | 97 ++++++ .../jijyun/src/util/DateTimeNullableFilter.ts | 97 ++++++ apps/jijyun/src/util/FloatFilter.ts | 98 ++++++ apps/jijyun/src/util/FloatNullableFilter.ts | 98 ++++++ apps/jijyun/src/util/IntFilter.ts | 98 ++++++ apps/jijyun/src/util/IntNullableFilter.ts | 98 ++++++ apps/jijyun/src/util/JsonFilter.ts | 31 ++ apps/jijyun/src/util/JsonNullableFilter.ts | 31 ++ apps/jijyun/src/util/MetaQueryPayload.ts | 13 + apps/jijyun/src/util/QueryMode.ts | 10 + apps/jijyun/src/util/SortOrder.ts | 10 + apps/jijyun/src/util/StringFilter.ts | 141 ++++++++ apps/jijyun/src/util/StringNullableFilter.ts | 141 ++++++++ apps/jijyun/src/validators/index.ts | 1 + .../is-json-value-validator.spec.ts | 44 +++ .../src/validators/is-json-value-validator.ts | 29 ++ apps/jijyun/tsconfig.build.json | 4 + apps/jijyun/tsconfig.json | 24 ++ 110 files changed, 3605 insertions(+) create mode 100644 apps/jijyun-admin/.dockerignore create mode 100644 apps/jijyun-admin/.env create mode 100644 apps/jijyun-admin/.gitignore create mode 100644 apps/jijyun-admin/Dockerfile create mode 100644 apps/jijyun-admin/README.md create mode 100644 apps/jijyun-admin/configuration/nginx.conf create mode 100644 apps/jijyun-admin/package.json create mode 100644 apps/jijyun-admin/public/favicon.ico create mode 100644 apps/jijyun-admin/public/index.html create mode 100644 apps/jijyun-admin/public/logo192.png create mode 100644 apps/jijyun-admin/public/logo512.png create mode 100644 apps/jijyun-admin/public/manifest.json create mode 100644 apps/jijyun-admin/public/robots.txt create mode 100644 apps/jijyun-admin/src/App.scss create mode 100644 apps/jijyun-admin/src/App.tsx create mode 100644 apps/jijyun-admin/src/Components/Pagination.tsx create mode 100644 apps/jijyun-admin/src/Login.tsx create mode 100644 apps/jijyun-admin/src/auth-provider/ra-auth-http.ts create mode 100644 apps/jijyun-admin/src/auth-provider/ra-auth-jwt.ts create mode 100644 apps/jijyun-admin/src/auth.ts create mode 100644 apps/jijyun-admin/src/constants.ts create mode 100644 apps/jijyun-admin/src/data-provider/graphqlDataProvider.ts create mode 100644 apps/jijyun-admin/src/index.css create mode 100644 apps/jijyun-admin/src/index.tsx create mode 100644 apps/jijyun-admin/src/login.scss create mode 100644 apps/jijyun-admin/src/pages/Dashboard.tsx create mode 100644 apps/jijyun-admin/src/reportWebVitals.ts create mode 100644 apps/jijyun-admin/src/setupTests.ts create mode 100644 apps/jijyun-admin/src/theme/theme.ts create mode 100644 apps/jijyun-admin/src/types.ts create mode 100644 apps/jijyun-admin/src/user/EnumRoles.ts create mode 100644 apps/jijyun-admin/src/user/RolesOptions.ts create mode 100644 apps/jijyun-admin/src/user/roles.ts create mode 100644 apps/jijyun-admin/src/util/BooleanFilter.ts create mode 100644 apps/jijyun-admin/src/util/BooleanNullableFilter.ts create mode 100644 apps/jijyun-admin/src/util/DateTimeFilter.ts create mode 100644 apps/jijyun-admin/src/util/DateTimeNullableFilter.ts create mode 100644 apps/jijyun-admin/src/util/FloatFilter.ts create mode 100644 apps/jijyun-admin/src/util/FloatNullableFilter.ts create mode 100644 apps/jijyun-admin/src/util/IntFilter.ts create mode 100644 apps/jijyun-admin/src/util/IntNullableFilter.ts create mode 100644 apps/jijyun-admin/src/util/JsonFilter.ts create mode 100644 apps/jijyun-admin/src/util/JsonNullableFilter.ts create mode 100644 apps/jijyun-admin/src/util/MetaQueryPayload.ts create mode 100644 apps/jijyun-admin/src/util/QueryMode.ts create mode 100644 apps/jijyun-admin/src/util/SortOrder.ts create mode 100644 apps/jijyun-admin/src/util/StringFilter.ts create mode 100644 apps/jijyun-admin/src/util/StringNullableFilter.ts create mode 100644 apps/jijyun-admin/tsconfig.json create mode 100644 apps/jijyun/.dockerignore create mode 100644 apps/jijyun/.env create mode 100644 apps/jijyun/.gitignore create mode 100644 apps/jijyun/.prettierignore create mode 100644 apps/jijyun/Dockerfile create mode 100644 apps/jijyun/README.md create mode 100644 apps/jijyun/docker-compose.db.yml create mode 100644 apps/jijyun/docker-compose.yml create mode 100644 apps/jijyun/nest-cli.json create mode 100644 apps/jijyun/package.json create mode 100644 apps/jijyun/prisma/schema.prisma create mode 100644 apps/jijyun/scripts/clean.ts create mode 100644 apps/jijyun/scripts/customSeed.ts create mode 100644 apps/jijyun/scripts/seed.ts create mode 100644 apps/jijyun/src/app.module.ts create mode 100644 apps/jijyun/src/constants.ts create mode 100644 apps/jijyun/src/decorators/api-nested-query.decorator.ts create mode 100644 apps/jijyun/src/decorators/public.decorator.ts create mode 100644 apps/jijyun/src/errors.ts create mode 100644 apps/jijyun/src/filters/HttpExceptions.filter.ts create mode 100644 apps/jijyun/src/health/base/health.controller.base.ts create mode 100644 apps/jijyun/src/health/base/health.service.base.ts create mode 100644 apps/jijyun/src/health/health.controller.ts create mode 100644 apps/jijyun/src/health/health.module.ts create mode 100644 apps/jijyun/src/health/health.service.ts create mode 100644 apps/jijyun/src/main.ts create mode 100644 apps/jijyun/src/prisma.util.spec.ts create mode 100644 apps/jijyun/src/prisma.util.ts create mode 100644 apps/jijyun/src/prisma/prisma.module.ts create mode 100644 apps/jijyun/src/prisma/prisma.service.ts create mode 100644 apps/jijyun/src/providers/secrets/base/secretsManager.service.base.spec.ts create mode 100644 apps/jijyun/src/providers/secrets/base/secretsManager.service.base.ts create mode 100644 apps/jijyun/src/providers/secrets/secretsManager.module.ts create mode 100644 apps/jijyun/src/providers/secrets/secretsManager.service.ts create mode 100644 apps/jijyun/src/serveStaticOptions.service.ts create mode 100644 apps/jijyun/src/swagger.ts create mode 100644 apps/jijyun/src/swagger/favicon.png create mode 100644 apps/jijyun/src/swagger/logo-amplication-white.svg create mode 100644 apps/jijyun/src/swagger/swagger.css create mode 100644 apps/jijyun/src/tests/health/health.service.spec.ts create mode 100644 apps/jijyun/src/types.ts create mode 100644 apps/jijyun/src/util/BooleanFilter.ts create mode 100644 apps/jijyun/src/util/BooleanNullableFilter.ts create mode 100644 apps/jijyun/src/util/DateTimeFilter.ts create mode 100644 apps/jijyun/src/util/DateTimeNullableFilter.ts create mode 100644 apps/jijyun/src/util/FloatFilter.ts create mode 100644 apps/jijyun/src/util/FloatNullableFilter.ts create mode 100644 apps/jijyun/src/util/IntFilter.ts create mode 100644 apps/jijyun/src/util/IntNullableFilter.ts create mode 100644 apps/jijyun/src/util/JsonFilter.ts create mode 100644 apps/jijyun/src/util/JsonNullableFilter.ts create mode 100644 apps/jijyun/src/util/MetaQueryPayload.ts create mode 100644 apps/jijyun/src/util/QueryMode.ts create mode 100644 apps/jijyun/src/util/SortOrder.ts create mode 100644 apps/jijyun/src/util/StringFilter.ts create mode 100644 apps/jijyun/src/util/StringNullableFilter.ts create mode 100644 apps/jijyun/src/validators/index.ts create mode 100644 apps/jijyun/src/validators/is-json-value-validator.spec.ts create mode 100644 apps/jijyun/src/validators/is-json-value-validator.ts create mode 100644 apps/jijyun/tsconfig.build.json create mode 100644 apps/jijyun/tsconfig.json diff --git a/apps/jijyun-admin/.dockerignore b/apps/jijyun-admin/.dockerignore new file mode 100644 index 0000000..1194b4f --- /dev/null +++ b/apps/jijyun-admin/.dockerignore @@ -0,0 +1,7 @@ +.dockerignore +docker-compose.yml +Dockerfile +build/ +node_modules +.env +.gitignore diff --git a/apps/jijyun-admin/.env b/apps/jijyun-admin/.env new file mode 100644 index 0000000..4eef91c --- /dev/null +++ b/apps/jijyun-admin/.env @@ -0,0 +1,2 @@ +PORT=3001 +REACT_APP_SERVER_URL=http://localhost:3000 \ No newline at end of file diff --git a/apps/jijyun-admin/.gitignore b/apps/jijyun-admin/.gitignore new file mode 100644 index 0000000..590b2e0 --- /dev/null +++ b/apps/jijyun-admin/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/apps/jijyun-admin/Dockerfile b/apps/jijyun-admin/Dockerfile new file mode 100644 index 0000000..9c43e40 --- /dev/null +++ b/apps/jijyun-admin/Dockerfile @@ -0,0 +1,51 @@ +# multi-stage: base (build) +FROM node:18.13.0-slim AS base + +# instantiate environment variable +ARG REACT_APP_SERVER_URL=http://localhost:3000 + +# set the environment variable that points to the server +ENV REACT_APP_SERVER_URL=$REACT_APP_SERVER_URL + +# create directory where the application will be built +WORKDIR /app + +# copy over the dependency manifests, both the package.json +# and the package-lock.json are copied over +COPY package*.json ./ + +# installs packages and their dependencies +RUN npm install + +# copy over the code base +COPY . . + +# create the bundle of the application +RUN npm run build + +# multi-stage: production (runtime) +FROM nginx:1.22-alpine AS production + +# copy over the bundled code from the build stage +COPY --from=base /app/build /usr/share/nginx/html +COPY --from=base /app/configuration/nginx.conf /etc/nginx/conf.d/default.conf + +# create a new process indication file +RUN touch /var/run/nginx.pid + +# change ownership of nginx related directories and files +RUN chown -R nginx:nginx /var/run/nginx.pid \ + /usr/share/nginx/html \ + /var/cache/nginx \ + /var/log/nginx \ + /etc/nginx/conf.d + +# set user to the created non-privileged user +USER nginx + +# expose a specific port on the docker container +ENV PORT=80 +EXPOSE ${PORT} + +# start the server using the previously build application +ENTRYPOINT [ "nginx", "-g", "daemon off;" ] diff --git a/apps/jijyun-admin/README.md b/apps/jijyun-admin/README.md new file mode 100644 index 0000000..715d898 --- /dev/null +++ b/apps/jijyun-admin/README.md @@ -0,0 +1,47 @@ +
+ + + +
+ +# Introduction + +This service was generated with Amplication. It serves as the client-side for the generated server component. The client-side consist of a React application with ready-made forms for creating and editing the different data models of the application. It is pre-conffigured to work with the server and comes with the boilerplate and foundation for the client - i.e., routing, navigation, authentication, premissions, menu, breadcrumbs, error handling and much more. Additional information about the admin component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. This side of the generated project was bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and built with [react-admin](https://marmelab.com/react-admin/). + + ++ +
+ +# Getting started + +## Step 1: Configuration + +Configuration for the client component can be provided through the use of environment variables. These can be passed to the application via the use of the `.env` file in the base directory of the generated service. Below a table can be found which show the different variables that can be passed. These values are provided default values after generation, change them to the desired values. + +| Variable | Description | Value | +| -------------------- | ------------------------------------------------ | ------------------------------ | +| PORT | the port on which to run the client | 3001 | +| REACT_APP_SERVER_URL | the url on which the server component is running | http://localhost:[server-port] | + +> **Note** +> Amplication generates default values and stores them under the .env file. It is advised to use some form of secrets manager/vault solution when using in production. + + +## Step 2: Scripts + +After configuration of the client the next step would be to run the application. Before running the client side of the component, make sure that the different pre-requisites are met - i.e., npm, docker. Make sure that the server-side of the application is running. + +```sh +# installation of the dependencies +$ npm install + +# starts the application in development mode - available by default under http://localhost:3001 with a pre-configured user with the username "admin" and password "admin" +$ npm run start + +# builds the application in production mode - available under 'build' +$ npm run build + +# removes the single build dependency from the project +$ npm run eject +``` diff --git a/apps/jijyun-admin/configuration/nginx.conf b/apps/jijyun-admin/configuration/nginx.conf new file mode 100644 index 0000000..88dad6e --- /dev/null +++ b/apps/jijyun-admin/configuration/nginx.conf @@ -0,0 +1,11 @@ +server_tokens off; + +server { + listen 8080; + server_name localhost; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri /index.html; + } +} \ No newline at end of file diff --git a/apps/jijyun-admin/package.json b/apps/jijyun-admin/package.json new file mode 100644 index 0000000..6a6af74 --- /dev/null +++ b/apps/jijyun-admin/package.json @@ -0,0 +1,60 @@ +{ + "name": "@jijyun/admin", + "private": true, + "dependencies": { + "@apollo/client": "3.6.9", + "@material-ui/core": "4.12.4", + "graphql": "15.6.1", + "lodash": "4.17.21", + "pluralize": "8.0.0", + "ra-data-graphql-amplication": "0.0.14", + "react": "16.14.0", + "react-admin": "3.19.11", + "react-dom": "16.14.0", + "react-scripts": "5.0.0", + "sass": "^1.39.0", + "web-vitals": "1.1.2" + }, + "overrides": { + "react-scripts": { + "@svgr/webpack": "6.5.1" + } + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject", + "package:container": "docker build ." + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "devDependencies": { + "@testing-library/jest-dom": "5.14.1", + "@testing-library/react": "11.2.7", + "@testing-library/user-event": "13.2.0", + "@types/jest": "26.0.16", + "@types/lodash": "4.14.178", + "@types/node": "12.20.16", + "@types/react": "16.14.11", + "@types/react-dom": "17.0.0", + "type-fest": "0.13.1", + "typescript": "4.2.4" + } +} \ No newline at end of file diff --git a/apps/jijyun-admin/public/favicon.ico b/apps/jijyun-admin/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..fcbdcf2d26233c47420d1e8d0f47f0aede4c1130 GIT binary patch literal 6548 zcma)A`EOj+6@K2G#Eu+ + + +
+ +# Introduction + +This service was generated with Amplication. The server-side of the generated project. This component provides the different backend services - i.e., REST API, GraphQL API, authentication, authorization, logging, data validation and the connection to the database. Additional information about the server component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. + +# Getting started + +## Step 1: Configuration + +Configuration for the server component can be provided through the use of environment variables. These can be passed to the application via the use of the `.env` file in the base directory of the generated service. Below a table can be found which show the different variables that can be passed - these are the variables which exist by default, through the use of plugins additional integrations could require additional values. These values are provided default values after generation, change them to the desired values. + +| Variable | Description | Value | +| -------------------- | -------------------------------------------- | ------------------------------------------------------------------- | +| BCRYPT_SALT | the string used for hashing | [random-string] | +| COMPOSE_PROJECT_NAME | the identifier of the service plus prefix | amp_[service-identifier] | +| PORT | the port on which to run the server | 3000 | +| DB_URL | the connection url for the database | [db-provider]://[username]:[password]@localhost:[db-port]/[db-name] | +| DB_PORT | the port used by the database instance | [db-provider-port] | +| DB_USER | the username used to connect to the database | [username] | +| DB_PASSWORD | the password used to connect to the database | [password] | +| DB_NAME | the name of the database | [service-name] / [project-name] | +| JWT_SECRET_KEY | the secret used to sign the json-web token | [secret] | +| JWT_EXPIRATION | the expiration time for the json-web token | 2d | + +> **Note** +> Amplication generates default values and stores them under the .env file. It is advised to use some form of secrets manager/vault solution when using in production. + +## Step 2.1: Scripts - pre-requisites + +After configuration of the server the next step would be to run the application. Before running the server side of the component, make sure that the different pre-requisites are met - i.e., node.js [^16.x], npm, docker. After the setup of the pre-requisites the server component can be started. + +```sh +# installation of the dependencies +$ npm install + +# generate the prisma client +$ npm run prisma:generate +``` + +## Step 2.2: Scripts - local development + +```sh +# start the database where the server component will connect to +$ npm run docker:db + +# initialize the database +$ npm run db:init + +# start the server component +$ npm run start +``` +By default, your app comes with one user with the username "admin" and password "admin". + +## Step 2.2: Scripts - container based development + +```shell +# start the server component as a docker container +$ npm run compose:up +``` diff --git a/apps/jijyun/docker-compose.db.yml b/apps/jijyun/docker-compose.db.yml new file mode 100644 index 0000000..a599fde --- /dev/null +++ b/apps/jijyun/docker-compose.db.yml @@ -0,0 +1,29 @@ +version: '3.1' +services: + db: + image: mysql + command: --default-authentication-plugin=mysql_native_password + restart: always + ports: + - ${DB_PORT}:3306 + environment: + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + healthcheck: + test: + - CMD + - mysqladmin + - ping + - -h + - localhost + - -u + - ${DB_USER} + timeout: 45s + interval: 10s + retries: 10 + adminer: + image: adminer + restart: always + ports: + - 1234:8080 +volumes: + mysql: ~ diff --git a/apps/jijyun/docker-compose.yml b/apps/jijyun/docker-compose.yml new file mode 100644 index 0000000..8667ea9 --- /dev/null +++ b/apps/jijyun/docker-compose.yml @@ -0,0 +1,56 @@ +version: "3" +services: + server: + build: + context: . + args: + NPM_LOG_LEVEL: notice + ports: + - ${PORT}:3000 + environment: + BCRYPT_SALT: ${BCRYPT_SALT} + JWT_SECRET_KEY: ${JWT_SECRET_KEY} + JWT_EXPIRATION: ${JWT_EXPIRATION} + DB_URL: mysql://${DB_USER}:${DB_PASSWORD}@db:3306/${DB_NAME} + depends_on: + - migrate + migrate: + build: + context: . + args: + NPM_LOG_LEVEL: notice + command: npm run db:init + working_dir: /app/server + environment: + BCRYPT_SALT: ${BCRYPT_SALT} + DB_URL: mysql://${DB_USER}:${DB_PASSWORD}@db:3306/${DB_NAME} + depends_on: + db: + condition: service_healthy + adminer: + image: adminer + restart: always + ports: + - 1234:8080 + db: + image: mysql + command: --default-authentication-plugin=mysql_native_password + restart: always + ports: + - ${DB_PORT}:3306 + environment: + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + healthcheck: + test: + - CMD + - mysqladmin + - ping + - -h + - localhost + - -u + - ${DB_USER} + timeout: 45s + interval: 10s + retries: 10 +volumes: + mysql: ~ diff --git a/apps/jijyun/nest-cli.json b/apps/jijyun/nest-cli.json new file mode 100644 index 0000000..fe51713 --- /dev/null +++ b/apps/jijyun/nest-cli.json @@ -0,0 +1,6 @@ +{ + "sourceRoot": "src", + "compilerOptions": { + "assets": ["swagger"] + } +} diff --git a/apps/jijyun/package.json b/apps/jijyun/package.json new file mode 100644 index 0000000..cbee973 --- /dev/null +++ b/apps/jijyun/package.json @@ -0,0 +1,68 @@ +{ + "name": "@jijyun/server", + "private": true, + "scripts": { + "start": "nest start", + "start:watch": "nest start --watch", + "start:debug": "nest start --debug --watch", + "build": "nest build", + "test": "jest", + "seed": "ts-node scripts/seed.ts", + "db:migrate-save": "prisma migrate dev", + "db:migrate-up": "prisma migrate deploy", + "db:clean": "ts-node scripts/clean.ts", + "db:init": "run-s \"db:migrate-save -- --name 'initial version'\" db:migrate-up seed", + "prisma:generate": "prisma generate", + "docker:db": "docker-compose -f docker-compose.db.yml up -d", + "package:container": "docker build .", + "compose:up": "docker-compose up -d", + "compose:down": "docker-compose down --volumes" + }, + "dependencies": { + "@nestjs/common": "8.4.7", + "@nestjs/config": "1.1.5", + "@nestjs/core": "8.4.7", + "@nestjs/graphql": "9.1.2", + "@nestjs/platform-express": "8.4.7", + "@nestjs/serve-static": "2.2.2", + "@nestjs/swagger": "5.1.5", + "@types/bcrypt": "5.0.0", + "@prisma/client": "4.6.1", + "apollo-server-express": "3.6.1", + "bcrypt": "5.0.1", + "class-transformer": "0.5.1", + "class-validator": "0.14.0", + "dotenv": "^16.1.4", + "graphql": "15.7.2", + "graphql-type-json": "0.3.2", + "nest-access-control": "2.0.3", + "nest-morgan": "1.0.1", + "npm-run-all": "4.1.5", + "reflect-metadata": "0.1.13", + "swagger-ui-express": "4.3.0", + "ts-node": "10.9.1", + "type-fest": "0.13.1", + "validator": "^13.9.0" + }, + "devDependencies": { + "@nestjs/cli": "8.2.5", + "@nestjs/testing": "8.4.7", + "@types/express": "4.17.9", + "@types/graphql-type-json": "0.3.2", + "@types/jest": "26.0.19", + "@types/normalize-path": "3.0.0", + "@types/supertest": "2.0.11", + "@types/validator": "^13.7.15", + "jest": "27.0.6", + "jest-mock-extended": "^2.0.4", + "prisma": "4.6.1", + "supertest": "4.0.2", + "ts-jest": "27.0.3", + "typescript": "4.2.3" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node", + "modulePathIgnorePatterns": ["