create-lupine 1.0.29 → 1.0.30
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/index.js +411 -411
- package/package.json +17 -17
- package/templates/common/.env.development +7 -7
- package/templates/common/.env.mobile +9 -9
- package/templates/common/.env.production +7 -7
- package/templates/common/_env +58 -58
- package/templates/common/_gitignore +25 -25
- package/templates/common/apps/server/src/index.ts +78 -76
- package/templates/common/apps/server/src/server-env-keys.ts +0 -9
- package/templates/common/dev/cp-folder.js +45 -45
- package/templates/common/tsconfig.json +128 -128
- package/templates/lupine-template-cv-starter/api/package.json +5 -5
- package/templates/lupine-template-cv-starter/api/resources/config_default.json +6 -6
- package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-cv-starter/api/src/index.ts +15 -15
- package/templates/lupine-template-cv-starter/lupine.json +39 -39
- package/templates/lupine-template-cv-starter/web/markdown/en/01-experience/index.md +32 -32
- package/templates/lupine-template-cv-starter/web/markdown/en/02-projects/index.md +36 -36
- package/templates/lupine-template-cv-starter/web/markdown/en/03-skills/index.md +28 -28
- package/templates/lupine-template-cv-starter/web/markdown/en/04-education/index.md +16 -16
- package/templates/lupine-template-cv-starter/web/markdown/en/index.md +41 -41
- package/templates/lupine-template-cv-starter/web/markdown/index.md +7 -7
- package/templates/lupine-template-cv-starter/web/markdown/zh/01-experience/index.md +32 -32
- package/templates/lupine-template-cv-starter/web/markdown/zh/02-projects/index.md +36 -36
- package/templates/lupine-template-cv-starter/web/markdown/zh/03-skills/index.md +28 -28
- package/templates/lupine-template-cv-starter/web/markdown/zh/04-education/index.md +17 -17
- package/templates/lupine-template-cv-starter/web/markdown/zh/index.md +41 -41
- package/templates/lupine-template-cv-starter/web/package.json +5 -5
- package/templates/lupine-template-cv-starter/web/src/client-env-keys.ts +5 -5
- package/templates/lupine-template-cv-starter/web/src/index.html +16 -16
- package/templates/lupine-template-cv-starter/web/src/index.tsx +28 -28
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/404.html +38 -38
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +73 -73
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +30 -30
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/01-experience/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/02-projects/index.html +28 -28
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/03-skills/index.html +18 -18
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/04-education/index.html +10 -10
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/01-experience/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/02-projects/index.html +28 -28
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/03-skills/index.html +18 -18
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/04-education/index.html +11 -11
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +15 -15
- package/templates/lupine-template-doc-starter/api/package.json +5 -5
- package/templates/lupine-template-doc-starter/api/resources/config_default.json +6 -6
- package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-doc-starter/api/src/index.ts +15 -15
- package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +6 -6
- package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-doc-starter/lupine.json +39 -39
- package/templates/lupine-template-doc-starter/web/markdown/en/essentials/index.md +6 -6
- package/templates/lupine-template-doc-starter/web/markdown/en/essentials/list.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/en/guide/install.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/en/guide/started.md +22 -22
- package/templates/lupine-template-doc-starter/web/markdown/en/index.md +42 -42
- package/templates/lupine-template-doc-starter/web/markdown/index.md +7 -7
- package/templates/lupine-template-doc-starter/web/markdown/zh/essentials/index.md +6 -6
- package/templates/lupine-template-doc-starter/web/markdown/zh/essentials/list.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/zh/guide/install.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/zh/guide/started.md +22 -22
- package/templates/lupine-template-doc-starter/web/markdown/zh/index.md +42 -42
- package/templates/lupine-template-doc-starter/web/package.json +5 -5
- package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +5 -5
- package/templates/lupine-template-doc-starter/web/src/index.html +16 -16
- package/templates/lupine-template-doc-starter/web/src/index.tsx +28 -28
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/404.html +38 -38
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +27 -27
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +30 -30
- package/templates/lupine-template-doc-starter/web/src/markdown-built/en/essentials/list.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/en/guide/install.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/en/guide/started.html +12 -12
- package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/essentials/list.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/guide/install.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/guide/started.html +12 -12
- package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +15 -15
- package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-hello-world/api/src/index.ts +4 -4
- package/templates/lupine-template-hello-world/api/src/service/root-api.ts +18 -18
- package/templates/lupine-template-hello-world/lupine.json +22 -22
- package/templates/lupine-template-hello-world/web/package.json +6 -6
- package/templates/lupine-template-hello-world/web/src/index.html +16 -16
- package/templates/lupine-template-hello-world/web/src/index.tsx +73 -73
- package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-responsive-starter/api/src/index.ts +4 -4
- package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +18 -18
- package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +76 -76
- package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +93 -93
- package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +86 -86
- package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +80 -80
- package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +220 -219
- package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +119 -119
- package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +116 -116
- package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +154 -154
- package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +193 -193
- package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +95 -95
- package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +182 -182
- package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +52 -52
- package/templates/lupine-template-responsive-starter/web/src/index.html +16 -16
- package/templates/lupine-template-responsive-starter/web/src/index.tsx +39 -39
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/404.html +35 -35
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +49 -49
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +32 -32
- package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +43 -43
- package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +46 -46
- package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +452 -452
- package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +325 -325
- package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +46 -46
- package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +87 -87
- package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +45 -45
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-lupine",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Scaffolding tool for Lupine.js projects",
|
|
5
|
-
"bin": {
|
|
6
|
-
"create-lupine": "index.js"
|
|
7
|
-
},
|
|
8
|
-
"files": [
|
|
9
|
-
"index.js",
|
|
10
|
-
"templates"
|
|
11
|
-
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"npm-publish": "npm publish --access public",
|
|
14
|
-
"dev-test": "node index.js"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {},
|
|
17
|
-
"type": "module"
|
|
1
|
+
{
|
|
2
|
+
"name": "create-lupine",
|
|
3
|
+
"version": "1.0.30",
|
|
4
|
+
"description": "Scaffolding tool for Lupine.js projects",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-lupine": "index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"templates"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"npm-publish": "npm publish --access public",
|
|
14
|
+
"dev-test": "node index.js"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {},
|
|
17
|
+
"type": "module"
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# dev is used when run dev
|
|
2
|
-
# starting with WEB. will be exposed to env.web.ts file
|
|
3
|
-
|
|
4
|
-
#!import .env
|
|
5
|
-
WEB.NODE_ENV=development
|
|
6
|
-
NODE_ENV=development
|
|
7
|
-
LOG_LEVEL=debug
|
|
1
|
+
# dev is used when run dev
|
|
2
|
+
# starting with WEB. will be exposed to env.web.ts file
|
|
3
|
+
|
|
4
|
+
#!import .env
|
|
5
|
+
WEB.NODE_ENV=development
|
|
6
|
+
NODE_ENV=development
|
|
7
|
+
LOG_LEVEL=debug
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# production is used when run prod
|
|
2
|
-
# starting with WEB. will be exposed to the FrontEnd
|
|
3
|
-
|
|
4
|
-
#!import .env
|
|
5
|
-
WEB.NODE_ENV=production
|
|
6
|
-
NODE_ENV=production
|
|
7
|
-
LOG_LEVEL=info
|
|
8
|
-
|
|
9
|
-
WEB.API_BASE_URL=https://your-server/
|
|
1
|
+
# production is used when run prod
|
|
2
|
+
# starting with WEB. will be exposed to the FrontEnd
|
|
3
|
+
|
|
4
|
+
#!import .env
|
|
5
|
+
WEB.NODE_ENV=production
|
|
6
|
+
NODE_ENV=production
|
|
7
|
+
LOG_LEVEL=info
|
|
8
|
+
|
|
9
|
+
WEB.API_BASE_URL=https://your-server/
|
|
10
10
|
WEB.API_PORT=80
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# production is used when run prod
|
|
2
|
-
# starting with WEB. will be exposed to the FrontEnd
|
|
3
|
-
|
|
4
|
-
#!import .env
|
|
5
|
-
WEB.NODE_ENV=production
|
|
6
|
-
NODE_ENV=production
|
|
7
|
-
LOG_LEVEL=info
|
|
1
|
+
# production is used when run prod
|
|
2
|
+
# starting with WEB. will be exposed to the FrontEnd
|
|
3
|
+
|
|
4
|
+
#!import .env
|
|
5
|
+
WEB.NODE_ENV=production
|
|
6
|
+
NODE_ENV=production
|
|
7
|
+
LOG_LEVEL=info
|
package/templates/common/_env
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
# start with WEB. will be exposed to the frontend file
|
|
2
|
-
WEB.API_PORT=11080
|
|
3
|
-
WEB.API_BASE_URL=
|
|
4
|
-
|
|
5
|
-
# start with “app_name.” will be assigned to the individual app's env object
|
|
6
|
-
# demo.app.WEB.test2=11aa
|
|
7
|
-
# demo.app.test2=11aa
|
|
8
|
-
|
|
9
|
-
# used by Server Side Renderring for fetch (can't be localhost)
|
|
10
|
-
API_BASE_URL=http://127.0.0.1:11080
|
|
11
|
-
HTTP_PORT=11080
|
|
12
|
-
HTTPS_PORT=11083
|
|
13
|
-
#'127.0.0.1' or for all ips: "::"
|
|
14
|
-
BIND_IP=0.0.0.0
|
|
15
|
-
|
|
16
|
-
NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
17
|
-
|
|
18
|
-
LOG_FOLDER=./dist/log
|
|
19
|
-
LOG_FILENAME=log-%index%.log
|
|
20
|
-
# size can be ?kb or ?mb
|
|
21
|
-
LOG_MAX_SIZE=1mb
|
|
22
|
-
LOG_MAX_COUNT=5
|
|
23
|
-
LOG_OUT_TO_FILE=true
|
|
24
|
-
LOG_OUT_TO_CONSOLE=true
|
|
25
|
-
|
|
26
|
-
# use following command to generate random keys
|
|
27
|
-
#node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"
|
|
28
|
-
# use following command to generate more complex strings
|
|
29
|
-
#node -e "l=32;c='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_!@&?-#$';console.log([...require('node:crypto').randomBytes(l)].map(x => c[x%c.length]).join(''))"
|
|
30
|
-
|
|
31
|
-
# server path for web (appName_web), server (server) and data (appName_data)
|
|
32
|
-
SERVER_ROOT_PATH=dist/server_root
|
|
33
|
-
ADMIN_USER=admin
|
|
34
|
-
ADMIN_PASS=
|
|
35
|
-
CRYPTO_KEY=
|
|
36
|
-
|
|
37
|
-
# for development
|
|
38
|
-
DEV_ADMIN_USER=admin
|
|
39
|
-
DEV_ADMIN_PASS=
|
|
40
|
-
DEV_CRYPTO_KEY=
|
|
41
|
-
DEV_TOKEN=
|
|
42
|
-
|
|
43
|
-
# define apps on the same port with different domains (locally or on a real server)
|
|
44
|
-
# in local, the domains should be added to the /etc/hosts (or C:\Windows\System32\drivers\etc\hosts) file
|
|
45
|
-
APPS={APP-NAME}
|
|
46
|
-
# below is empty that means all domains will come to this app
|
|
47
|
-
DOMAINS:{APP-NAME}=
|
|
48
|
-
|
|
49
|
-
# Https Keys and Crts are for domains (not apps), use following command to generate
|
|
50
|
-
# mkcert example.com "*.example.com" localhost 127.0.0.1 ::1
|
|
51
|
-
SSL_KEY_PATH=dev/example.com+4-key.pem
|
|
52
|
-
SSL_CRT_PATH=dev/example.com+4.pem
|
|
53
|
-
HTTPS_KEY_PATH:{APP-NAME}=dev/example.com+4-key.pem
|
|
54
|
-
HTTPS_CRT_PATH:{APP-NAME}=dev/example.com+4.pem
|
|
55
|
-
|
|
56
|
-
DB_TYPE=sqlite
|
|
57
|
-
|
|
58
|
-
DB_TYPE:{APP-NAME}=sqlite
|
|
1
|
+
# start with WEB. will be exposed to the frontend file
|
|
2
|
+
WEB.API_PORT=11080
|
|
3
|
+
WEB.API_BASE_URL=
|
|
4
|
+
|
|
5
|
+
# start with “app_name.” will be assigned to the individual app's env object
|
|
6
|
+
# demo.app.WEB.test2=11aa
|
|
7
|
+
# demo.app.test2=11aa
|
|
8
|
+
|
|
9
|
+
# used by Server Side Renderring for fetch (can't be localhost)
|
|
10
|
+
API_BASE_URL=http://127.0.0.1:11080
|
|
11
|
+
HTTP_PORT=11080
|
|
12
|
+
HTTPS_PORT=11083
|
|
13
|
+
#'127.0.0.1' or for all ips: "::"
|
|
14
|
+
BIND_IP=0.0.0.0
|
|
15
|
+
|
|
16
|
+
NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
17
|
+
|
|
18
|
+
LOG_FOLDER=./dist/log
|
|
19
|
+
LOG_FILENAME=log-%index%.log
|
|
20
|
+
# size can be ?kb or ?mb
|
|
21
|
+
LOG_MAX_SIZE=1mb
|
|
22
|
+
LOG_MAX_COUNT=5
|
|
23
|
+
LOG_OUT_TO_FILE=true
|
|
24
|
+
LOG_OUT_TO_CONSOLE=true
|
|
25
|
+
|
|
26
|
+
# use following command to generate random keys
|
|
27
|
+
#node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"
|
|
28
|
+
# use following command to generate more complex strings
|
|
29
|
+
#node -e "l=32;c='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_!@&?-#$';console.log([...require('node:crypto').randomBytes(l)].map(x => c[x%c.length]).join(''))"
|
|
30
|
+
|
|
31
|
+
# server path for web (appName_web), server (server) and data (appName_data)
|
|
32
|
+
SERVER_ROOT_PATH=dist/server_root
|
|
33
|
+
ADMIN_USER=admin
|
|
34
|
+
ADMIN_PASS=
|
|
35
|
+
CRYPTO_KEY=
|
|
36
|
+
|
|
37
|
+
# for development
|
|
38
|
+
DEV_ADMIN_USER=admin
|
|
39
|
+
DEV_ADMIN_PASS=
|
|
40
|
+
DEV_CRYPTO_KEY=
|
|
41
|
+
DEV_TOKEN=
|
|
42
|
+
|
|
43
|
+
# define apps on the same port with different domains (locally or on a real server)
|
|
44
|
+
# in local, the domains should be added to the /etc/hosts (or C:\Windows\System32\drivers\etc\hosts) file
|
|
45
|
+
APPS={APP-NAME}
|
|
46
|
+
# below is empty that means all domains will come to this app
|
|
47
|
+
DOMAINS:{APP-NAME}=
|
|
48
|
+
|
|
49
|
+
# Https Keys and Crts are for domains (not apps), use following command to generate
|
|
50
|
+
# mkcert example.com "*.example.com" localhost 127.0.0.1 ::1
|
|
51
|
+
SSL_KEY_PATH=dev/example.com+4-key.pem
|
|
52
|
+
SSL_CRT_PATH=dev/example.com+4.pem
|
|
53
|
+
HTTPS_KEY_PATH:{APP-NAME}=dev/example.com+4-key.pem
|
|
54
|
+
HTTPS_CRT_PATH:{APP-NAME}=dev/example.com+4.pem
|
|
55
|
+
|
|
56
|
+
DB_TYPE=sqlite
|
|
57
|
+
SQLITE_FILENAME=sqlite3.db
|
|
58
|
+
DB_TYPE:{APP-NAME}=sqlite
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
node_modules
|
|
5
|
-
/.pnp
|
|
6
|
-
.pnp.js
|
|
7
|
-
package-lock.json
|
|
8
|
-
|
|
9
|
-
# misc
|
|
10
|
-
.DS_Store
|
|
11
|
-
|
|
12
|
-
# debug
|
|
13
|
-
npm-debug.log*
|
|
14
|
-
yarn-debug.log*
|
|
15
|
-
yarn-error.log*
|
|
16
|
-
.pnpm-debug.log*
|
|
17
|
-
|
|
18
|
-
# local env files
|
|
19
|
-
.env
|
|
20
|
-
|
|
21
|
-
# typescript
|
|
22
|
-
*.tsbuildinfo
|
|
23
|
-
|
|
24
|
-
# build
|
|
25
|
-
/dist
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.js
|
|
7
|
+
package-lock.json
|
|
8
|
+
|
|
9
|
+
# misc
|
|
10
|
+
.DS_Store
|
|
11
|
+
|
|
12
|
+
# debug
|
|
13
|
+
npm-debug.log*
|
|
14
|
+
yarn-debug.log*
|
|
15
|
+
yarn-error.log*
|
|
16
|
+
.pnpm-debug.log*
|
|
17
|
+
|
|
18
|
+
# local env files
|
|
19
|
+
.env
|
|
20
|
+
|
|
21
|
+
# typescript
|
|
22
|
+
*.tsbuildinfo
|
|
23
|
+
|
|
24
|
+
# build
|
|
25
|
+
/dist
|
|
@@ -1,76 +1,78 @@
|
|
|
1
|
-
// initApp should be called before any other logics, so need to avoid `export default new Class()`
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
CryptoUtils,
|
|
5
|
-
HostToPathProps,
|
|
6
|
-
appStart,
|
|
7
|
-
|
|
8
|
-
loadEnv,
|
|
9
|
-
setAccessControlAllowHost,
|
|
10
|
-
} from 'lupine.api/server';
|
|
11
|
-
import { ServerEnvKeys } from './server-env-keys';
|
|
12
|
-
|
|
13
|
-
const initAndStartServer = async () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
1
|
+
// initApp should be called before any other logics, so need to avoid `export default new Class()`
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
CryptoUtils,
|
|
5
|
+
HostToPathProps,
|
|
6
|
+
appStart,
|
|
7
|
+
getAppDbConfig,
|
|
8
|
+
loadEnv,
|
|
9
|
+
setAccessControlAllowHost,
|
|
10
|
+
} from 'lupine.api/server';
|
|
11
|
+
import { ServerEnvKeys } from './server-env-keys';
|
|
12
|
+
|
|
13
|
+
const initAndStartServer = async () => {
|
|
14
|
+
const envFile = process.argv.find((i) => i.startsWith('--env='))?.substring(6) || '.env';
|
|
15
|
+
// it can use "#!import file_name" to import another env file
|
|
16
|
+
await loadEnv(envFile);
|
|
17
|
+
|
|
18
|
+
const serverRootPath = path.resolve(process.env[ServerEnvKeys.SERVER_ROOT_PATH]!);
|
|
19
|
+
const apps = (process.env[ServerEnvKeys.APPS] || '').split(',');
|
|
20
|
+
const webRootMap: HostToPathProps[] = [];
|
|
21
|
+
const accessControlAllowHosts = new Set(['localhost', '127.0.0.1']);
|
|
22
|
+
|
|
23
|
+
const domainCerts: Record<string, { key: string; cert: string }> = {};
|
|
24
|
+
for (const app of apps) {
|
|
25
|
+
const appHosts = (process.env[`${ServerEnvKeys.DOMAINS}:${app}`] || '')
|
|
26
|
+
.split(',')
|
|
27
|
+
.map((host) => host.trim().toLowerCase())
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
appHosts.forEach((host) => accessControlAllowHosts.add(host));
|
|
30
|
+
|
|
31
|
+
const appDbConfig = getAppDbConfig(app);
|
|
32
|
+
|
|
33
|
+
webRootMap.push({
|
|
34
|
+
appName: app,
|
|
35
|
+
hosts: appHosts,
|
|
36
|
+
// web, data, api folders should be created in building process
|
|
37
|
+
webPath: path.join(serverRootPath, app + '_web'),
|
|
38
|
+
dataPath: path.join(serverRootPath, app + '_data'),
|
|
39
|
+
apiPath: path.join(serverRootPath, app + '_api'),
|
|
40
|
+
dbConfig: appDbConfig,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
for (const domain of appHosts) {
|
|
44
|
+
domainCerts[domain] = {
|
|
45
|
+
key: process.env[`${ServerEnvKeys.SSL_KEY_PATH}:${app}`] || '',
|
|
46
|
+
cert: process.env[`${ServerEnvKeys.SSL_CRT_PATH}:${app}`] || '',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setAccessControlAllowHost([...accessControlAllowHosts]);
|
|
51
|
+
|
|
52
|
+
const bindIp = process.env[ServerEnvKeys.BIND_IP] || '::';
|
|
53
|
+
// 0 to disable http/https server
|
|
54
|
+
const httpPort = Number.parseInt(process.env[ServerEnvKeys.HTTP_PORT] || '0');
|
|
55
|
+
const httpsPort = Number.parseInt(process.env[ServerEnvKeys.HTTPS_PORT] || '0');
|
|
56
|
+
const sslKeyPath = process.env[ServerEnvKeys.SSL_KEY_PATH] || '';
|
|
57
|
+
const sslCrtPath = process.env[ServerEnvKeys.SSL_CRT_PATH] || '';
|
|
58
|
+
|
|
59
|
+
// Can't use log until initApp is called (after AppStart.start)
|
|
60
|
+
await appStart.start({
|
|
61
|
+
debug: process.env[ServerEnvKeys.NODE_ENV] === 'development',
|
|
62
|
+
devToken: CryptoUtils.sha256(process.env['DEV_TOKEN'] || ''),
|
|
63
|
+
appEnvFile: envFile,
|
|
64
|
+
apiConfig: {
|
|
65
|
+
serverRoot: `${serverRootPath}`,
|
|
66
|
+
webHostMap: webRootMap,
|
|
67
|
+
},
|
|
68
|
+
serverConfig: {
|
|
69
|
+
bindIp,
|
|
70
|
+
httpPort,
|
|
71
|
+
httpsPort,
|
|
72
|
+
sslKeyPath,
|
|
73
|
+
sslCrtPath,
|
|
74
|
+
domainCerts,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
initAndStartServer();
|
|
@@ -10,13 +10,4 @@ export const enum ServerEnvKeys {
|
|
|
10
10
|
NODE_ENV = 'NODE_ENV',
|
|
11
11
|
APPS = 'APPS',
|
|
12
12
|
DOMAINS = 'DOMAINS',
|
|
13
|
-
DB_TYPE = 'DB_TYPE',
|
|
14
|
-
DB_FILENAME = 'DB_FILENAME',
|
|
15
|
-
LOG_FOLDER = 'LOG_FOLDER',
|
|
16
|
-
LOG_FILENAME = 'LOG_FILENAME',
|
|
17
|
-
LOG_MAX_SIZE = 'LOG_MAX_SIZE',
|
|
18
|
-
LOG_MAX_COUNT = 'LOG_MAX_COUNT',
|
|
19
|
-
LOG_OUT_TO_FILE = 'LOG_OUT_TO_FILE',
|
|
20
|
-
LOG_OUT_TO_CONSOLE = 'LOG_OUT_TO_CONSOLE',
|
|
21
|
-
LOG_LEVEL = 'LOG_LEVEL',
|
|
22
13
|
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
function copyRecursiveSync(src, dest) {
|
|
5
|
-
const stats = fs.statSync(src);
|
|
6
|
-
const isDirectory = stats.isDirectory();
|
|
7
|
-
if (isDirectory) {
|
|
8
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
9
|
-
fs.readdirSync(src).forEach((childItemName) => {
|
|
10
|
-
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
// Ensure parent directory exists for file copy (just in case)
|
|
14
|
-
const destDir = path.dirname(dest);
|
|
15
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
16
|
-
fs.copyFileSync(src, dest);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function copyFolder(src, dest) {
|
|
21
|
-
if (!src || !dest) {
|
|
22
|
-
console.error('Usage: node dev/cp-folder.js <source> <destination>');
|
|
23
|
-
if (require.main === module) process.exit(1);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const srcPath = path.resolve(process.cwd(), src);
|
|
28
|
-
const destPath = path.resolve(process.cwd(), dest);
|
|
29
|
-
|
|
30
|
-
if (fs.existsSync(srcPath)) {
|
|
31
|
-
console.log(`Copying from ${src} to ${dest}...`);
|
|
32
|
-
copyRecursiveSync(srcPath, destPath);
|
|
33
|
-
console.log('Copy complete.');
|
|
34
|
-
} else {
|
|
35
|
-
console.log(`Source directory ${src} does not exist. Skipping copy.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (require.main === module) {
|
|
40
|
-
const src = process.argv[2];
|
|
41
|
-
const dest = process.argv[3];
|
|
42
|
-
copyFolder(src, dest);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = copyFolder;
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function copyRecursiveSync(src, dest) {
|
|
5
|
+
const stats = fs.statSync(src);
|
|
6
|
+
const isDirectory = stats.isDirectory();
|
|
7
|
+
if (isDirectory) {
|
|
8
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
9
|
+
fs.readdirSync(src).forEach((childItemName) => {
|
|
10
|
+
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
|
|
11
|
+
});
|
|
12
|
+
} else {
|
|
13
|
+
// Ensure parent directory exists for file copy (just in case)
|
|
14
|
+
const destDir = path.dirname(dest);
|
|
15
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
16
|
+
fs.copyFileSync(src, dest);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function copyFolder(src, dest) {
|
|
21
|
+
if (!src || !dest) {
|
|
22
|
+
console.error('Usage: node dev/cp-folder.js <source> <destination>');
|
|
23
|
+
if (require.main === module) process.exit(1);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const srcPath = path.resolve(process.cwd(), src);
|
|
28
|
+
const destPath = path.resolve(process.cwd(), dest);
|
|
29
|
+
|
|
30
|
+
if (fs.existsSync(srcPath)) {
|
|
31
|
+
console.log(`Copying from ${src} to ${dest}...`);
|
|
32
|
+
copyRecursiveSync(srcPath, destPath);
|
|
33
|
+
console.log('Copy complete.');
|
|
34
|
+
} else {
|
|
35
|
+
console.log(`Source directory ${src} does not exist. Skipping copy.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (require.main === module) {
|
|
40
|
+
const src = process.argv[2];
|
|
41
|
+
const dest = process.argv[3];
|
|
42
|
+
copyFolder(src, dest);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = copyFolder;
|