Explorar o código

Merge branch 'agile' of https://github.com/visuddhinanda/mint into agile

visuddhinanda %!s(int64=3) %!d(string=hai) anos
pai
achega
f2ae018c59

+ 2 - 0
dashboard/src/App.tsx

@@ -4,6 +4,7 @@ import { IntlProvider } from "react-intl";
 import { Provider } from "react-redux";
 import { pdfjs } from "react-pdf";
 import mermaid from "mermaid";
+import { enableMapSet } from "immer";
 
 import Router from "./Router";
 import store from "./store";
@@ -18,6 +19,7 @@ import "./App.css";
 
 pdfjs.GlobalWorkerOptions.workerSrc = `${API_HOST}/assets/pdf.worker.min.js`;
 mermaid.initialize({ startOnLoad: true });
+enableMapSet();
 
 onLoad();
 const lang = getLocale();

+ 1 - 1
documents/development/README.md

@@ -14,7 +14,7 @@
 
 ### VS Code 配置文件
 
-## [Spring 开发环境](SPRING.md)
+## [Spring 开发环境](spring/)
 
 ## [Local 开发环境](LOCAL.md)
 

+ 0 - 27
documents/development/SPRING.md

@@ -1,27 +0,0 @@
-# SPRING 开发环境
-
-## 注意事项
-
-- A: 在 Domain name 中, **如果 YOUR_ID 含'\_',需要替换成'-'**
-
-## ssh 登录
-
-```bash
-ssh -i YOUR_KEY YOUR_ID@YOUR_ID.spring.wikipali.org
-```
-
-## PHP 开发(以用户 xxx 为例)
-
-- `~/www/htdocs/info.php` => `https://YOUR_ID.spring.wikipali.org/info.php`
-- 日志文件在 `~/www/logs/`
-- 其余参见[常见 PHP 设置](php/)
-
-## 服务设置
-
-- PostgreSql 连接 `psql -h 127.0.0.1 -U xxx xxx_mint`
-- RabbitMQ 的 `virtual-host` 是`xxx-mint`
-- redis 的 namespace`xxx://YOUR_KEY`
-
-## VsCode 设置
-
-- [Remote Development using SSH](https://code.visualstudio.com/docs/remote/ssh)

+ 1 - 4
documents/development/php/README.md

@@ -9,10 +9,7 @@
 - PHP-WEB 文件写入权限不足
 
 ```bash
-# for folder
-chmod 777 FOLDER_NAME
-# for file
-chmod 666 FILE_NAME
+XXX/mint/scrips/spring/laravel.sh
 ```
 
 ## Php-Nginx for local container

+ 0 - 0
documents/PostgreSQL.md → documents/development/postgresql/README.md


+ 64 - 0
documents/development/spring/README.md

@@ -0,0 +1,64 @@
+# SPRING 开发环境
+
+## 注意事项
+
+- A: 在 Domain name 中, **如果 YOUR_ID 含'\_',需要替换成'-'**
+
+## ssh 登录
+
+```bash
+ssh -i YOUR_KEY YOUR_ID@YOUR_ID.spring.wikipali.org
+```
+
+## 数据库设置
+
+![files](files.png)
+
+```bash
+cd /workspace/shared/db-TIMASTAMP/
+psql -q -h 127.0.0.1 -p 5432 -U YOUR_ID YOUR_ID_mint < schema.sql
+pg_restore -Fc -h 127.0.0.1 -p 5432 -U YOUR_ID -d YOUR_ID_mint < data.dump
+```
+
+![restore](postgresql/restore.png)
+
+- Ssh PROXY 设置
+
+  - 开启端口转发(把 spring 的`5432`转发到 local 的`15432`)
+
+    ```bash
+    ssh -o ServerAliveInterval=600 -i YOUR_KEY_FILE -L 15432:localhost:5432 YOUR_ID@YOUR_ID.spring.wikipali.org
+    ```
+
+    ![ssh proxy](postgresql/ssh-proxy.png)
+
+  - psql 连接
+
+    ```bash
+    psql -h localhost -p 15432 -U YOUR_ID YOUR_ID_mint
+    ```
+
+    ![psql](postgresql/psql.png)
+
+  - Dbeaver 连接
+
+    ![dbeaver](postgresql/dbeaver.png)
+
+## PHP 开发(以用户 xxx 为例)
+
+- `~/www/htdocs/public/info.php` => `https://YOUR_ID.spring.wikipali.org/info.php`
+- 日志文件在
+
+  ![logs](laravel-logs.png)
+
+- 其余参见[常见 PHP 设置](../php/)
+
+## 服务设置
+
+- PostgreSql 连接 `psql -h 127.0.0.1 -U YOUR_ID YOUR_ID_mint`
+- RabbitMQ 的 `virtual-host` 是`YOUR_ID-mint`
+- redis 的 namespace`YOUR_ID://KEY`
+
+## VsCode 设置
+
+- [Remote Development using SSH](https://code.visualstudio.com/docs/remote/ssh)

BIN=BIN
documents/development/spring/files.png


BIN=BIN
documents/development/spring/laravel-logs.png


BIN=BIN
documents/development/spring/postgresql/dbeaver.png


BIN=BIN
documents/development/spring/postgresql/psql.png


BIN=BIN
documents/development/spring/postgresql/restore.png


BIN=BIN
documents/development/spring/postgresql/ssh-proxy.png


+ 14 - 0
documents/development/vscode/README.md

@@ -47,3 +47,17 @@
 - 然后就可以欢快地写代码了 与 local 基本无差
 
   ![edit](by-ssh/9.png)
+
+## ISSUES
+
+- Permissions for XXX are too open().
+
+  - For linux/macos user
+
+    ```bash
+    chmod 400 YOUR_PRIVATE_KEY_FILE
+    ```
+
+  - For windows user
+
+    ![too open](by-ssh/too-open.gif)

BIN=BIN
documents/development/vscode/by-ssh/too-open.gif


+ 9 - 0
openapi/README.md

@@ -5,6 +5,15 @@ yarn install
 yarn run dev
 ```
 
+- Editor
+
+  ```bash
+  git clone https://github.com/swagger-api/swagger-editor.git
+  cd swagger-editor
+  npm install
+  npm run dev # http://localhost:3200
+  ```
+
 ## Documents
 
 - [OpenAPI Guide](https://swagger.io/docs/specification/basic-structure/)

+ 1 - 1
openapi/index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <link rel="icon" type="image/svg+xml" href="/vite.svg" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Vite + React + TS</title>
+    <title>MINT API</title>
   </head>
   <body>
     <div id="root"></div>

+ 10 - 19
openapi/public/assets/protocol/main.yaml

@@ -1,24 +1,15 @@
 openapi: 3.0.0
 info:
-  title: Sample API
-  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
-  version: 0.1.9
+  title: MINT API
+  description: International Academy Of Pali Tipitaka(国际巴利三藏学院)
+  version: 2022.12.8
 servers:
-  - url: http://api.example.com/v1
-    description: Optional server description, e.g. Main (production) server
-  - url: http://staging-api.example.com
-    description: Optional server description, e.g. Internal staging server for testing
+  - url: https://spring.wikipali.org/api
+    description: Internal staging server for testing
+  - url: https://www.wikipali.org/api
+    description: Main production server
 paths:
   /users:
-    get:
-      summary: Returns a list of users.
-      description: Optional extended description in CommonMark or HTML.
-      responses:
-        "200": # status code
-          description: A JSON array of user names
-          content:
-            application/json:
-              schema:
-                type: array
-                items:
-                  type: string
+    $ref: "./resources/auth/users/index.yaml"
+  /users/sign-in:
+    $ref: "./resources/auth/users/sign-in.yaml"

+ 13 - 0
openapi/public/assets/protocol/resources/auth/users/index.yaml

@@ -0,0 +1,13 @@
+get:
+  summary: Returns a list of users.
+  tags:
+    - auth
+  responses:
+    "200":
+      description: A JSON array of user names
+      content:
+        application/json:
+          schema:
+            type: array
+            items:
+              type: string

+ 13 - 0
openapi/public/assets/protocol/resources/auth/users/sign-in.yaml

@@ -0,0 +1,13 @@
+post:
+  summary: Sign in.
+  tags:
+    - auth
+  responses:
+    "200": # status code
+      description: A JSON array of user names
+      content:
+        application/json:
+          schema:
+            type: array
+            items:
+              type: string

+ 0 - 1
openapi/src/main.tsx

@@ -1,4 +1,3 @@
-import React from "react";
 import ReactDOM from "react-dom/client";
 
 import App from "./App";

+ 4 - 1
scripts/spring/laravel.sh

@@ -2,4 +2,7 @@
 
 chmod 666 storage/logs/*.log
 
-chmod 777 storage/logs storage/framework/sessions
+chmod 777 storage/logs \
+    storage/framework/sessions \
+    storage/framework/views \
+    storage/framework/cache/data

+ 1 - 2
scripts/spring/postgresql/create.sh

@@ -9,9 +9,8 @@ then
 fi
 
 psql << EOF
-CREATE DATABASE $1_mint WITH ENCODING = 'UTF8';
 CREATE USER $1 WITH PASSWORD '$2';
-GRANT ALL PRIVILEGES ON DATABASE $1_mint TO $1;
+CREATE DATABASE $1_mint WITH ENCODING = 'UTF8' OWNER $1;
 EOF
 
 echo "done($1)."

+ 1 - 2
scripts/spring/postgresql/reset.sh

@@ -10,8 +10,7 @@ fi
 
 psql << EOF
 DROP DATABASE $1_mint;
-CREATE DATABASE $1_mint WITH ENCODING = 'UTF8';
-GRANT ALL PRIVILEGES ON DATABASE $1_mint TO $1;
+CREATE DATABASE $1_mint WITH ENCODING = 'UTF8' OWNER $1;
 EOF
 
 echo "done($1)."