@goodandready/dsh-russian-lang 0.3.1 → 0.3.3
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/README.md +20 -5
- package/README.ru.md +20 -5
- package/lib/client.js +2711 -2421
- package/lib/index.js +23 -5
- package/lib/locales/core.json +1 -1
- package/lib/locales/plugins/03-dshmarket.json +1 -1
- package/lib/locales/plugins/17-dsh-context.json +1 -1
- package/lib/locales/plugins/26-config-manager.json +1 -1
- package/lib/locales/plugins/29-config-manager-recovery.json +1 -1
- package/lib/locales/plugins/32-vision-bridge.json +1 -1
- package/lib/locales/plugins/34-key-rotation.json +1 -1
- package/lib/locales/plugins/36-cost-meter.json +1 -1
- package/lib/locales/plugins/37-time-machine.json +1 -1
- package/lib/locales/plugins/42-plugin-console.json +1 -1
- package/lib/locales/plugins/49-dsml-guard.json +1 -1
- package/lib/locales/plugins/77-github-ops.json +1 -1
- package/lib/locales/plugins/78-web-gateway.json +1 -1
- package/lib/locales/plugins/80-ip-pool.json +1 -0
- package/lib/locales/plugins/81-ego-browser.json +1 -0
- package/lib/locales/plugins/82-effort-slider.json +1 -0
- package/lib/locales/zh-ru.json +1 -1
- package/lib/pure.js +57 -3
- package/lib/translator.js +55 -0
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto'
|
|
2
2
|
import { registerPluginUpdater } from './plugin-updater.js'
|
|
3
3
|
import { registerTranslator } from './translator.js'
|
|
4
|
-
import { getCoreDictionaries, getPluginDictionaries, getPluginDictionariesByNames, getZhRuMap } from './locales.js'
|
|
4
|
+
import { getCoreDictionaries, getPluginDictionaries, getPluginDictionariesByNames, getAllDictionaries, getZhRuMap } from './locales.js'
|
|
5
5
|
// dsh-russian-lang — серверная половина.
|
|
6
6
|
//
|
|
7
7
|
// Словари и переключатель живут в браузере (lib/client.js). Хосту переводить
|
|
@@ -30,7 +30,11 @@ const sendJsonWithEtag = (request, response, obj, maxAge = 300) => {
|
|
|
30
30
|
'cache-control': `public, max-age=${maxAge}, must-revalidate`,
|
|
31
31
|
'content-length': body.length,
|
|
32
32
|
})
|
|
33
|
-
|
|
33
|
+
if (request?.method === 'HEAD') {
|
|
34
|
+
response.end()
|
|
35
|
+
} else {
|
|
36
|
+
response.end(body)
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
export const name = '@goodandready/dsh-russian-lang'
|
|
@@ -104,6 +108,11 @@ export function apply(ctx) {
|
|
|
104
108
|
path: '/api/dsh-russian-lang/dict/core',
|
|
105
109
|
handler: async (request, response) => {
|
|
106
110
|
try {
|
|
111
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
112
|
+
response.writeHead(405, { allow: 'GET, HEAD', 'content-type': 'application/json; charset=utf-8' })
|
|
113
|
+
response.end(JSON.stringify({ error: 'Method not allowed' }))
|
|
114
|
+
return
|
|
115
|
+
}
|
|
107
116
|
const core = getCoreDictionaries()
|
|
108
117
|
const zhRu = getZhRuMap()
|
|
109
118
|
sendJsonWithEtag(request, response, { core, zhRu })
|
|
@@ -120,6 +129,11 @@ export function apply(ctx) {
|
|
|
120
129
|
path: '/api/dsh-russian-lang/dict/plugins',
|
|
121
130
|
handler: async (request, response) => {
|
|
122
131
|
try {
|
|
132
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
133
|
+
response.writeHead(405, { allow: 'GET, HEAD', 'content-type': 'application/json; charset=utf-8' })
|
|
134
|
+
response.end(JSON.stringify({ error: 'Method not allowed' }))
|
|
135
|
+
return
|
|
136
|
+
}
|
|
123
137
|
const url = new URL(request.url, 'http://localhost')
|
|
124
138
|
const namesParam = url.searchParams.get('names') || url.searchParams.get('list') || ''
|
|
125
139
|
const names = namesParam ? namesParam.split(',').map((s) => s.trim()).filter(Boolean) : null
|
|
@@ -138,10 +152,14 @@ export function apply(ctx) {
|
|
|
138
152
|
path: '/api/dsh-russian-lang/dict/all',
|
|
139
153
|
handler: async (request, response) => {
|
|
140
154
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
156
|
+
response.writeHead(405, { allow: 'GET, HEAD', 'content-type': 'application/json; charset=utf-8' })
|
|
157
|
+
response.end(JSON.stringify({ error: 'Method not allowed' }))
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
const all = getAllDictionaries()
|
|
143
161
|
const zhRu = getZhRuMap()
|
|
144
|
-
sendJsonWithEtag(request, response, Object.assign({},
|
|
162
|
+
sendJsonWithEtag(request, response, Object.assign({}, all, { core: getCoreDictionaries(), plugins: getPluginDictionaries(), zhRu }))
|
|
145
163
|
} catch (err) {
|
|
146
164
|
response.writeHead(500, { 'content-type': 'application/json; charset=utf-8' })
|
|
147
165
|
response.end(JSON.stringify({ error: String(err) }))
|