underpost 2.8.867 → 2.8.872
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/.github/workflows/release.cd.yml +3 -1
- package/README.md +26 -2
- package/bin/build.js +1 -0
- package/bin/deploy.js +4 -0
- package/bin/util.js +1 -56
- package/cli.md +3 -1
- package/conf.js +3 -2
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/mongo-express/deployment.yaml +12 -12
- package/manifests/maas/nvim.sh +91 -0
- package/package.json +2 -12
- package/src/api/file/file.service.js +28 -8
- package/src/api/user/user.router.js +24 -0
- package/src/api/user/user.service.js +3 -4
- package/src/cli/cluster.js +2 -13
- package/src/cli/cron.js +0 -1
- package/src/cli/db.js +0 -19
- package/src/cli/deploy.js +17 -26
- package/src/cli/fs.js +1 -0
- package/src/cli/index.js +1 -0
- package/src/cli/repository.js +1 -0
- package/src/cli/run.js +10 -2
- package/src/client/components/core/Account.js +2 -1
- package/src/client/components/core/AgGrid.js +2 -2
- package/src/client/components/core/CalendarCore.js +2 -3
- package/src/client/components/core/CommonJs.js +1 -2
- package/src/client/components/core/Content.js +2 -1
- package/src/client/components/core/Css.js +2 -1
- package/src/client/components/core/CssCore.js +14 -1
- package/src/client/components/core/Docs.js +5 -5
- package/src/client/components/core/FileExplorer.js +3 -3
- package/src/client/components/core/FullScreen.js +19 -28
- package/src/client/components/core/Input.js +1 -0
- package/src/client/components/core/JoyStick.js +2 -2
- package/src/client/components/core/LoadingAnimation.js +2 -2
- package/src/client/components/core/Logger.js +4 -1
- package/src/client/components/core/Modal.js +54 -47
- package/src/client/components/core/ObjectLayerEngine.js +229 -4
- package/src/client/components/core/ObjectLayerEngineModal.js +442 -0
- package/src/client/components/core/Pagination.js +14 -0
- package/src/client/components/core/Panel.js +3 -8
- package/src/client/components/core/PanelForm.js +5 -14
- package/src/client/components/core/Recover.js +2 -2
- package/src/client/components/core/Router.js +183 -34
- package/src/client/components/core/Stream.js +1 -1
- package/src/client/components/core/ToggleSwitch.js +15 -1
- package/src/client/components/core/VanillaJs.js +0 -84
- package/src/client/components/core/Worker.js +2 -2
- package/src/client/components/default/MenuDefault.js +4 -3
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/public/default/assets/mailer/api-user-default-avatar.png +0 -0
- package/src/client/services/core/core.service.js +1 -1
- package/src/client/ssr/head/DefaultScripts.js +1 -0
- package/src/index.js +1 -1
- package/src/server/client-build.js +3 -11
- package/src/server/client-icons.js +6 -78
- package/src/server/conf.js +4 -56
- package/src/server/process.js +2 -1
- package/src/server/runtime.js +7 -0
- package/src/server/ssl.js +1 -2
package/README.md
CHANGED
|
@@ -23,6 +23,18 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
26
38
|
|
|
27
39
|
|
|
28
40
|
|
|
@@ -33,7 +45,7 @@
|
|
|
33
45
|
<!-- badges -->
|
|
34
46
|
|
|
35
47
|
|
|
36
|
-
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.8.872) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
37
49
|
|
|
38
50
|
|
|
39
51
|
<!-- end-badges -->
|
|
@@ -45,6 +57,18 @@
|
|
|
45
57
|
|
|
46
58
|
|
|
47
59
|
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
48
72
|
|
|
49
73
|
|
|
50
74
|
|
|
@@ -96,7 +120,7 @@ Run dev client server
|
|
|
96
120
|
npm run dev
|
|
97
121
|
```
|
|
98
122
|
<!-- -->
|
|
99
|
-
## underpost ci/cd cli v2.8.
|
|
123
|
+
## underpost ci/cd cli v2.8.872
|
|
100
124
|
|
|
101
125
|
### Usage: `underpost [options] [command]`
|
|
102
126
|
```
|
package/bin/build.js
CHANGED
|
@@ -156,6 +156,7 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
|
|
|
156
156
|
switch (confName) {
|
|
157
157
|
case 'dd-cyberia':
|
|
158
158
|
fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia.js`);
|
|
159
|
+
fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia0.js`);
|
|
159
160
|
break;
|
|
160
161
|
|
|
161
162
|
default:
|
package/bin/deploy.js
CHANGED
|
@@ -379,6 +379,10 @@ try {
|
|
|
379
379
|
const templateRunnerResult = fs.readFileSync(`../pwa-microservices-template/logs/start.js/all.log`, 'utf8');
|
|
380
380
|
logger.info('Test template runner result');
|
|
381
381
|
console.log(templateRunnerResult);
|
|
382
|
+
if (!templateRunnerResult || templateRunnerResult.toLowerCase().match('error')) {
|
|
383
|
+
logger.error('Test template runner result failed');
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
382
386
|
shellExec(`node bin/deploy clean-core-repo`);
|
|
383
387
|
shellCd(`/home/dd/engine`);
|
|
384
388
|
const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
|
package/bin/util.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import si from 'systeminformation';
|
|
3
3
|
import * as dir from 'path';
|
|
4
|
-
import { svg } from 'font-awesome-assets';
|
|
5
4
|
|
|
6
5
|
import { loggerFactory } from '../src/server/logger.js';
|
|
7
|
-
import { pbcopy
|
|
6
|
+
import { pbcopy } from '../src/server/process.js';
|
|
8
7
|
import { buildKindPorts } from '../src/server/conf.js';
|
|
9
|
-
import { FileFactory } from '../src/api/file/file.service.js';
|
|
10
|
-
import { faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
|
|
11
|
-
import keyword_extractor from 'keyword-extractor';
|
|
12
8
|
|
|
13
9
|
const logger = loggerFactory(import.meta);
|
|
14
10
|
|
|
@@ -73,57 +69,6 @@ try {
|
|
|
73
69
|
cleanEmptyFoldersRecursively('./');
|
|
74
70
|
break;
|
|
75
71
|
|
|
76
|
-
case 'text-to-image': {
|
|
77
|
-
const buffer = await getBufferPngText({
|
|
78
|
-
text: process.argv[3],
|
|
79
|
-
textColor: process.argv[4],
|
|
80
|
-
bgColor: process.argv[5],
|
|
81
|
-
size: process.argv[6],
|
|
82
|
-
debugFilename: process.argv[7],
|
|
83
|
-
});
|
|
84
|
-
fs.writeFileSync(`./text-to-image.png`, buffer);
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
case 'fa-image':
|
|
88
|
-
const faId = process.argv[3] ? process.argv[3] : 'user';
|
|
89
|
-
const color = process.argv[4] ? process.argv[4] : '#5f5f5f';
|
|
90
|
-
const path = process.argv[5] ? process.argv[5] : './';
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
fs.writeFileSync(`./tmp/${faId}.svg`, svg(faId, color), 'utf8');
|
|
94
|
-
const data = fs.readFileSync(`./tmp/${faId}.svg`);
|
|
95
|
-
console.log(FileFactory.svg(data, `${faId}.svg`));
|
|
96
|
-
fs.removeSync(`${path}${faId}.svg`);
|
|
97
|
-
}
|
|
98
|
-
{
|
|
99
|
-
fs.writeFileSync(`${path}${faId}.png`, Buffer.from(faBase64Png(faId, 100, 100, color), 'base64'));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
break;
|
|
103
|
-
|
|
104
|
-
case 'b64-image':
|
|
105
|
-
fs.writeFileSync('b64-image', `data:image/jpg;base64,${fs.readFileSync(process.argv[3]).toString('base64')}`);
|
|
106
|
-
break;
|
|
107
|
-
|
|
108
|
-
case 'get-keys': {
|
|
109
|
-
const sentence = fs.existsSync('./_')
|
|
110
|
-
? fs.readFileSync('./_', 'utf8')
|
|
111
|
-
: process.argv[3]
|
|
112
|
-
? process.argv[3]
|
|
113
|
-
: 'President Obama woke up Monday facing a Congressional defeat that many in both parties believed could hobble his presidency.';
|
|
114
|
-
|
|
115
|
-
// Extract the keywords
|
|
116
|
-
const extraction_result = keyword_extractor.extract(sentence, {
|
|
117
|
-
language: 'english',
|
|
118
|
-
remove_digits: true,
|
|
119
|
-
// return_changed_case: true,
|
|
120
|
-
// remove_duplicates: false,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
console.log(extraction_result.join(', '));
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
72
|
case 'build-ports': {
|
|
128
73
|
pbcopy(buildKindPorts(process.argv[3], process.argv[4]));
|
|
129
74
|
}
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.872
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -307,6 +307,8 @@ Options:
|
|
|
307
307
|
current resource deployments.
|
|
308
308
|
--kubeadm Enables the kubeadm context for deployment
|
|
309
309
|
operations.
|
|
310
|
+
--etc-hosts Enables the etc-hosts context for
|
|
311
|
+
deployment operations.
|
|
310
312
|
--restore-hosts Restores default `/etc/hosts` entries.
|
|
311
313
|
-h, --help display help for command
|
|
312
314
|
|
package/conf.js
CHANGED
|
@@ -63,6 +63,7 @@ const DefaultConf = /**/ {
|
|
|
63
63
|
'Alert',
|
|
64
64
|
'404',
|
|
65
65
|
'500',
|
|
66
|
+
'Pagination',
|
|
66
67
|
],
|
|
67
68
|
default: [
|
|
68
69
|
'MenuDefault',
|
|
@@ -110,7 +111,7 @@ const DefaultConf = /**/ {
|
|
|
110
111
|
{ folder: './node_modules/@loadingio/css-spinner/entries', public_folder: '/dist/loadingio' },
|
|
111
112
|
{
|
|
112
113
|
import_name: 'ag-grid-community',
|
|
113
|
-
import_name_build: '/dist/ag-grid-community/ag-grid-community.
|
|
114
|
+
import_name_build: '/dist/ag-grid-community/ag-grid-community.min.js',
|
|
114
115
|
folder: './node_modules/ag-grid-community/dist',
|
|
115
116
|
public_folder: '/dist/ag-grid-community',
|
|
116
117
|
styles: './node_modules/ag-grid-community/styles',
|
|
@@ -147,7 +148,7 @@ const DefaultConf = /**/ {
|
|
|
147
148
|
apis: ['default', 'core', 'user', 'test', 'file'],
|
|
148
149
|
origins: [],
|
|
149
150
|
minifyBuild: false,
|
|
150
|
-
iconsBuild:
|
|
151
|
+
iconsBuild: false,
|
|
151
152
|
liteBuild: true,
|
|
152
153
|
docsBuild: false,
|
|
153
154
|
offlineBuild: false,
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-default-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.872
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-default-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.872
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -20,16 +20,16 @@ spec:
|
|
|
20
20
|
ports:
|
|
21
21
|
- containerPort: 8081
|
|
22
22
|
env:
|
|
23
|
-
- name: ME_CONFIG_MONGODB_ADMINUSERNAME
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- name: ME_CONFIG_MONGODB_ADMINPASSWORD
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
# - name: ME_CONFIG_MONGODB_ADMINUSERNAME
|
|
24
|
+
# valueFrom:
|
|
25
|
+
# secretKeyRef:
|
|
26
|
+
# name: mongodb-secret
|
|
27
|
+
# key: username
|
|
28
|
+
# - name: ME_CONFIG_MONGODB_ADMINPASSWORD
|
|
29
|
+
# valueFrom:
|
|
30
|
+
# secretKeyRef:
|
|
31
|
+
# name: mongodb-secret
|
|
32
|
+
# key: password
|
|
33
33
|
- name: ME_CONFIG_BASICAUTH_USERNAME
|
|
34
34
|
valueFrom:
|
|
35
35
|
secretKeyRef:
|
|
@@ -42,8 +42,8 @@ spec:
|
|
|
42
42
|
key: password
|
|
43
43
|
- name: ME_CONFIG_MONGODB_SERVER
|
|
44
44
|
value: 'mongodb-0.mongodb-service'
|
|
45
|
-
- name: ME_CONFIG_MONGODB_ENABLE_ADMIN
|
|
46
|
-
|
|
45
|
+
# - name: ME_CONFIG_MONGODB_ENABLE_ADMIN
|
|
46
|
+
# value: 'true'
|
|
47
47
|
- name: ME_CONFIG_MONGODB_PORT
|
|
48
48
|
value: '27017'
|
|
49
49
|
---
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
sudo dnf install -y neovim
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
sudo rm -rf ~/.config/nvim
|
|
8
|
+
sudo rm -rf ~/.local/share/nvim
|
|
9
|
+
|
|
10
|
+
mkdir -p ~/.config/nvim
|
|
11
|
+
mkdir -p ~/.local/share/nvim/site/autoload
|
|
12
|
+
|
|
13
|
+
# Install vim-plug for Neovim
|
|
14
|
+
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
|
|
15
|
+
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
16
|
+
|
|
17
|
+
# Create an init.vim with nvim-tree.lua + web-devicons + gruvbox (theme)
|
|
18
|
+
cat > ~/.config/nvim/init.vim <<'EOF'
|
|
19
|
+
" Minimal init.vim to use nvim-tree.lua + gruvbox theme via vim-plug
|
|
20
|
+
|
|
21
|
+
" --- vim-plug manager
|
|
22
|
+
call plug#begin('~/.local/share/nvim/plugged')
|
|
23
|
+
|
|
24
|
+
" file explorer (nvim-tree)
|
|
25
|
+
Plug 'nvim-tree/nvim-tree.lua'
|
|
26
|
+
Plug 'nvim-tree/nvim-web-devicons' " optional: file icons
|
|
27
|
+
|
|
28
|
+
" colorscheme
|
|
29
|
+
Plug 'morhetz/gruvbox'
|
|
30
|
+
|
|
31
|
+
" sensible defaults, optional
|
|
32
|
+
Plug 'tpope/vim-sensible'
|
|
33
|
+
|
|
34
|
+
call plug#end()
|
|
35
|
+
|
|
36
|
+
" --- UI settings
|
|
37
|
+
syntax on
|
|
38
|
+
filetype plugin indent on
|
|
39
|
+
set number
|
|
40
|
+
set relativenumber
|
|
41
|
+
if has('termguicolors')
|
|
42
|
+
set termguicolors
|
|
43
|
+
endif
|
|
44
|
+
set background=dark
|
|
45
|
+
|
|
46
|
+
" gruvbox options (optional)
|
|
47
|
+
let g:gruvbox_contrast_dark = 'soft'
|
|
48
|
+
colorscheme gruvbox
|
|
49
|
+
|
|
50
|
+
" --- nvim-tree configuration (Lua block)
|
|
51
|
+
lua << 'LUA'
|
|
52
|
+
-- safe require
|
|
53
|
+
local ok, tree = pcall(require, "nvim-tree")
|
|
54
|
+
if not ok then
|
|
55
|
+
return
|
|
56
|
+
end
|
|
57
|
+
tree.setup{
|
|
58
|
+
view = {
|
|
59
|
+
width = 30,
|
|
60
|
+
side = "left",
|
|
61
|
+
preserve_window_proportions = true,
|
|
62
|
+
},
|
|
63
|
+
renderer = {
|
|
64
|
+
indent_markers = { enable = true },
|
|
65
|
+
},
|
|
66
|
+
actions = {
|
|
67
|
+
open_file = {
|
|
68
|
+
quit_on_open = false,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
LUA
|
|
73
|
+
|
|
74
|
+
" --- mappings: Ctrl-n toggles nvim-tree
|
|
75
|
+
nnoremap <C-n> :NvimTreeToggle<CR>
|
|
76
|
+
|
|
77
|
+
" Open nvim-tree on startup when opening nvim with no file args
|
|
78
|
+
autocmd StdinReadPre * let s:std_in=1
|
|
79
|
+
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NvimTreeToggle | wincmd p | endif
|
|
80
|
+
EOF
|
|
81
|
+
|
|
82
|
+
# Fix permissions in case something was left owned by root (happens if you used sudo on these paths before)
|
|
83
|
+
sudo chown -R "$USER":"$USER" ~/.config/nvim ~/.local/share/nvim 2>/dev/null || true
|
|
84
|
+
|
|
85
|
+
# Install plugins automatically (non-interactive)
|
|
86
|
+
nvim +PlugInstall +qall
|
|
87
|
+
|
|
88
|
+
echo
|
|
89
|
+
echo "Done. Plugins installed."
|
|
90
|
+
echo "Run 'nvim' and press Ctrl-n to toggle the file tree."
|
|
91
|
+
echo "If colorscheme is not correct, ensure your terminal supports truecolor and TERM is xterm-256color."
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.872",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -54,15 +54,12 @@
|
|
|
54
54
|
"@loadingio/css-spinner": "^2.0.2",
|
|
55
55
|
"@neodrag/vanilla": "^2.0.3",
|
|
56
56
|
"adm-zip": "^0.5.10",
|
|
57
|
-
"ag-grid-community": "31.
|
|
57
|
+
"ag-grid-community": "^31.3.4",
|
|
58
58
|
"axios": "^1.5.1",
|
|
59
59
|
"chai": "^5.1.0",
|
|
60
60
|
"clean-jsdoc-theme": "^4.3.0",
|
|
61
|
-
"cli-progress": "^3.12.0",
|
|
62
|
-
"cli-spinners": "^3.0.0",
|
|
63
61
|
"clipboardy": "^4.0.0",
|
|
64
62
|
"cloudinary": "^2.5.1",
|
|
65
|
-
"color": "^4.2.3",
|
|
66
63
|
"colors": "^1.4.0",
|
|
67
64
|
"commander": "^12.1.0",
|
|
68
65
|
"compression": "^1.7.4",
|
|
@@ -74,7 +71,6 @@
|
|
|
74
71
|
"express": "^4.18.2",
|
|
75
72
|
"express-fileupload": "^1.4.3",
|
|
76
73
|
"favicons": "^7.2.0",
|
|
77
|
-
"font-awesome-assets": "^0.0.9",
|
|
78
74
|
"fs-extra": "^11.1.1",
|
|
79
75
|
"fullcalendar": "^6.1.15",
|
|
80
76
|
"html-minifier-terser": "^7.2.0",
|
|
@@ -82,11 +78,8 @@
|
|
|
82
78
|
"ignore-walk": "^6.0.4",
|
|
83
79
|
"iovalkey": "^0.2.1",
|
|
84
80
|
"jimp": "^0.22.12",
|
|
85
|
-
"joystick-controller": "^1.0.15",
|
|
86
81
|
"json-colorizer": "^2.2.2",
|
|
87
82
|
"jsonwebtoken": "^9.0.2",
|
|
88
|
-
"keyword-extractor": "^0.0.28",
|
|
89
|
-
"log-update": "^6.0.0",
|
|
90
83
|
"mariadb": "^3.2.2",
|
|
91
84
|
"marked": "^12.0.2",
|
|
92
85
|
"mocha": "^10.8.2",
|
|
@@ -94,10 +87,8 @@
|
|
|
94
87
|
"morgan": "^1.10.0",
|
|
95
88
|
"nodemailer": "^6.9.9",
|
|
96
89
|
"nodemon": "^3.0.1",
|
|
97
|
-
"pathfinding": "^0.4.18",
|
|
98
90
|
"peer": "^1.0.2",
|
|
99
91
|
"peerjs": "^1.5.2",
|
|
100
|
-
"pixi.js": "7.4.2",
|
|
101
92
|
"prom-client": "^15.1.2",
|
|
102
93
|
"public-ip": "^6.0.1",
|
|
103
94
|
"read": "^2.1.0",
|
|
@@ -116,7 +107,6 @@
|
|
|
116
107
|
"vanilla-jsoneditor": "^2.3.2",
|
|
117
108
|
"winston": "^3.11.0"
|
|
118
109
|
},
|
|
119
|
-
"devDependencies": {},
|
|
120
110
|
"publishConfig": {
|
|
121
111
|
"provenance": true,
|
|
122
112
|
"access": "public",
|
|
@@ -5,14 +5,18 @@ import crypto from 'crypto';
|
|
|
5
5
|
const logger = loggerFactory(import.meta);
|
|
6
6
|
|
|
7
7
|
const FileFactory = {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
if (Array.isArray(req.files.file)) for (const file of req.files.file) results.push(await new File(file).save());
|
|
8
|
+
filesExtract: (req) => {
|
|
9
|
+
const files = [];
|
|
10
|
+
if (Array.isArray(req.files.file)) for (const file of req.files.file) files.push(file);
|
|
12
11
|
else if (Object.keys(req.files).length > 0)
|
|
13
|
-
for (const keyFile of Object.keys(req.files))
|
|
12
|
+
for (const keyFile of Object.keys(req.files)) files.push(req.files[keyFile]);
|
|
13
|
+
return files;
|
|
14
|
+
},
|
|
15
|
+
upload: async function (req, File) {
|
|
16
|
+
const results = FileFactory.filesExtract(req);
|
|
14
17
|
let index = -1;
|
|
15
|
-
for (
|
|
18
|
+
for (let file of results) {
|
|
19
|
+
file = await new File(file).save();
|
|
16
20
|
index++;
|
|
17
21
|
const [result] = await File.find({
|
|
18
22
|
_id: file._id,
|
|
@@ -25,7 +29,23 @@ const FileFactory = {
|
|
|
25
29
|
return Buffer.from(raw, 'utf8').toString('hex');
|
|
26
30
|
// reverse hexValue.toString()
|
|
27
31
|
},
|
|
28
|
-
|
|
32
|
+
getMymeTypeFromPath: (path) => {
|
|
33
|
+
switch (path.split('.').pop()) {
|
|
34
|
+
case 'png':
|
|
35
|
+
return 'image/png';
|
|
36
|
+
case 'jpg':
|
|
37
|
+
return 'image/jpeg';
|
|
38
|
+
case 'jpeg':
|
|
39
|
+
return 'image/jpeg';
|
|
40
|
+
case 'gif':
|
|
41
|
+
return 'image/gif';
|
|
42
|
+
case 'svg':
|
|
43
|
+
return 'image/svg+xml';
|
|
44
|
+
default:
|
|
45
|
+
return 'application/octet-stream';
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
create: (data = Buffer.from([]), name = '') => {
|
|
29
49
|
return {
|
|
30
50
|
name: name,
|
|
31
51
|
data: data,
|
|
@@ -33,7 +53,7 @@ const FileFactory = {
|
|
|
33
53
|
encoding: '7bit',
|
|
34
54
|
tempFilePath: '',
|
|
35
55
|
truncated: false,
|
|
36
|
-
mimetype:
|
|
56
|
+
mimetype: FileFactory.getMymeTypeFromPath(name),
|
|
37
57
|
md5: crypto.createHash('md5').update(data).digest('hex'),
|
|
38
58
|
cid: undefined,
|
|
39
59
|
};
|
|
@@ -4,6 +4,7 @@ import { loggerFactory } from '../../server/logger.js';
|
|
|
4
4
|
import { UserController } from './user.controller.js';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import { DataBaseProvider } from '../../db/DataBaseProvider.js';
|
|
7
|
+
import { FileFactory } from '../file/file.service.js';
|
|
7
8
|
|
|
8
9
|
const logger = loggerFactory(import.meta);
|
|
9
10
|
|
|
@@ -11,6 +12,7 @@ const UserRouter = (options) => {
|
|
|
11
12
|
const router = express.Router();
|
|
12
13
|
|
|
13
14
|
(async () => {
|
|
15
|
+
// admin user seed
|
|
14
16
|
try {
|
|
15
17
|
const models = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models;
|
|
16
18
|
if (models.User) {
|
|
@@ -35,6 +37,7 @@ const UserRouter = (options) => {
|
|
|
35
37
|
console.log(error);
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
// default user avatar seed
|
|
38
41
|
options.png = {
|
|
39
42
|
buffer: {
|
|
40
43
|
'invalid-token': fs.readFileSync(`./src/client/public/default/assets/mailer/api-user-invalid-token.png`),
|
|
@@ -45,6 +48,27 @@ const UserRouter = (options) => {
|
|
|
45
48
|
res.set('Content-Type', 'image/png');
|
|
46
49
|
},
|
|
47
50
|
};
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const models = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models;
|
|
54
|
+
const name = 'api-user-default-avatar.png';
|
|
55
|
+
const imageFile = await models.File.findOne({ name });
|
|
56
|
+
let _id;
|
|
57
|
+
if (imageFile) {
|
|
58
|
+
_id = imageFile._id;
|
|
59
|
+
} else {
|
|
60
|
+
const file = await new models.File(
|
|
61
|
+
FileFactory.create(fs.readFileSync(`./src/client/public/default/assets/mailer/${name}`), name),
|
|
62
|
+
).save();
|
|
63
|
+
_id = file._id;
|
|
64
|
+
}
|
|
65
|
+
options.getDefaultProfileImageId = async () => {
|
|
66
|
+
return _id;
|
|
67
|
+
};
|
|
68
|
+
} catch (error) {
|
|
69
|
+
logger.error('Error checking/creating default profile image');
|
|
70
|
+
console.log(error);
|
|
71
|
+
}
|
|
48
72
|
})();
|
|
49
73
|
|
|
50
74
|
router.post(`/mailer/:id`, authMiddleware, async (req, res) => {
|
|
@@ -9,7 +9,6 @@ import { DataBaseProvider } from '../../db/DataBaseProvider.js';
|
|
|
9
9
|
import { FileFactory } from '../file/file.service.js';
|
|
10
10
|
import { UserDto } from './user.model.js';
|
|
11
11
|
import { selectDtoFactory, ValkeyAPI } from '../../server/valkey.js';
|
|
12
|
-
import { getDefaultProfileImageId } from '../../server/client-icons.js';
|
|
13
12
|
|
|
14
13
|
const logger = loggerFactory(import.meta);
|
|
15
14
|
|
|
@@ -129,7 +128,7 @@ const UserService = {
|
|
|
129
128
|
if (!user.profileImageId)
|
|
130
129
|
await User.findByIdAndUpdate(
|
|
131
130
|
user._id,
|
|
132
|
-
{ profileImageId: await getDefaultProfileImageId(File) },
|
|
131
|
+
{ profileImageId: await options.getDefaultProfileImageId(File) },
|
|
133
132
|
{
|
|
134
133
|
runValidators: true,
|
|
135
134
|
},
|
|
@@ -212,7 +211,7 @@ const UserService = {
|
|
|
212
211
|
if (validatePassword.status === 'error') throw new Error(validatePassword.message);
|
|
213
212
|
req.body.password = await hashPassword(req.body.password);
|
|
214
213
|
req.body.role = req.body.role === 'guest' ? 'guest' : 'user';
|
|
215
|
-
req.body.profileImageId = await getDefaultProfileImageId(File);
|
|
214
|
+
req.body.profileImageId = await options.getDefaultProfileImageId(File);
|
|
216
215
|
const { _id } = await new User(req.body).save();
|
|
217
216
|
if (_id) {
|
|
218
217
|
const user = await User.findOne({ _id }).select(UserDto.select.get());
|
|
@@ -313,7 +312,7 @@ const UserService = {
|
|
|
313
312
|
if (!file && !(await ValkeyAPI.getValkeyObject(options, req.auth.user.email))) {
|
|
314
313
|
await User.findByIdAndUpdate(
|
|
315
314
|
user._id,
|
|
316
|
-
{ profileImageId: await getDefaultProfileImageId(File) },
|
|
315
|
+
{ profileImageId: await options.getDefaultProfileImageId(File) },
|
|
317
316
|
{
|
|
318
317
|
runValidators: true,
|
|
319
318
|
},
|
package/src/cli/cluster.js
CHANGED
|
@@ -410,21 +410,10 @@ EOF
|
|
|
410
410
|
const successInstance = await UnderpostTest.API.statusMonitor('mongodb-0', 'Running', 'pods', 1000, 60 * 10);
|
|
411
411
|
|
|
412
412
|
if (successInstance) {
|
|
413
|
-
if (!options.mongoDbHost) options.mongoDbHost = 'mongodb-service';
|
|
413
|
+
if (!options.mongoDbHost) options.mongoDbHost = 'mongodb-0.mongodb-service';
|
|
414
414
|
const mongoConfig = {
|
|
415
415
|
_id: 'rs0',
|
|
416
|
-
members:
|
|
417
|
-
{
|
|
418
|
-
_id: 0,
|
|
419
|
-
host: `${options.mongoDbHost === 'mongodb-service' ? 'mongodb-0.' : ''}${options.mongoDbHost}:27017`,
|
|
420
|
-
priority: 1,
|
|
421
|
-
},
|
|
422
|
-
// {
|
|
423
|
-
// _id: 1,
|
|
424
|
-
// host: `${options.mongoDbHost === 'mongodb-service' ? 'mongodb-1.' : ''}${options.mongoDbHost}:27017`,
|
|
425
|
-
// priority: 1,
|
|
426
|
-
// },
|
|
427
|
-
],
|
|
416
|
+
members: options.mongoDbHost.split(',').map((host, index) => ({ _id: index, host: `${host}:27017` })),
|
|
428
417
|
};
|
|
429
418
|
|
|
430
419
|
shellExec(
|
package/src/cli/cron.js
CHANGED
package/src/cli/db.js
CHANGED
|
@@ -177,25 +177,6 @@ class UnderpostDB {
|
|
|
177
177
|
}`,
|
|
178
178
|
);
|
|
179
179
|
}
|
|
180
|
-
if (false) {
|
|
181
|
-
const containerBaseBackupPath = '/backup';
|
|
182
|
-
let timeFolder = shellExec(
|
|
183
|
-
`sudo kubectl exec -i ${podName} -- sh -c "cd ${containerBaseBackupPath} && ls -a"`,
|
|
184
|
-
{
|
|
185
|
-
stdout: true,
|
|
186
|
-
disableLog: false,
|
|
187
|
-
silent: true,
|
|
188
|
-
},
|
|
189
|
-
).split(`\n`);
|
|
190
|
-
timeFolder = timeFolder[timeFolder.length - 2];
|
|
191
|
-
if (timeFolder === '..') {
|
|
192
|
-
logger.warn(`Cannot backup available`, { timeFolder });
|
|
193
|
-
} else {
|
|
194
|
-
shellExec(
|
|
195
|
-
`sudo kubectl cp ${nameSpace}/${podName}:${containerBaseBackupPath}/${timeFolder}/${dbName} ${_toNewBsonPath}`,
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
180
|
}
|
|
200
181
|
break;
|
|
201
182
|
}
|