diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2020-05-23 23:21:09 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-23 23:21:09 +0900 |
| commit | abc296cdcc73d0e039286a9107ea8b36f02ceae3 (patch) | |
| tree | 239105c1d81c9a009cfe2481b8daa2d24d3fe70e /src/server | |
| parent | Drop support for Node v11, v13 (#6402) (diff) | |
| download | sharkey-abc296cdcc73d0e039286a9107ea8b36f02ceae3.tar.gz sharkey-abc296cdcc73d0e039286a9107ea8b36f02ceae3.tar.bz2 sharkey-abc296cdcc73d0e039286a9107ea8b36f02ceae3.zip | |
refactor: use Object.fromEntries() instead of in-house implementation (#6401)
* refactor: use Object.fromEntries()
instead of in-house implementation
* Remove extra type assertions
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/api/openapi/description.ts | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/server/api/openapi/description.ts b/src/server/api/openapi/description.ts index 4fff53ac90..15831b3c9a 100644 --- a/src/server/api/openapi/description.ts +++ b/src/server/api/openapi/description.ts @@ -1,7 +1,5 @@ -import config from '../../../config'; import endpoints from '../endpoints'; import * as locale from '../../../../locales/'; -import { fromEntries } from '../../../prelude/array'; import { kinds as kindsList } from '../kinds'; export interface IKindInfo { @@ -10,16 +8,16 @@ export interface IKindInfo { } export function kinds() { - const kinds = fromEntries( + const kinds = Object.fromEntries( kindsList .map(k => [k, { endpoints: [], - descs: fromEntries( + descs: Object.fromEntries( Object.keys(locale) - .map(l => [l, locale[l]._permissions[k] as string] as [string, string]) - ) as { [x: string]: string; } - }] as [ string, IKindInfo ]) - ) as { [x: string]: IKindInfo; }; + .map(l => [l, locale[l]._permissions[k] as string]) + ) + } as IKindInfo]) + ); const errors = [] as string[][]; @@ -37,17 +35,17 @@ export function kinds() { } export function getDescription(lang = 'ja-JP'): string { - const permissionTable = (Object.entries(kinds()) as [string, IKindInfo][]) + const permissionTable = Object.entries(kinds()) .map(e => `|${e[0]}|${e[1].descs[lang]}|${e[1].endpoints.map(f => `[${f}](#operation/${f})`).join(', ')}|`) .join('\n'); - const descriptions = { + const descriptions: { [x: string]: string } = { 'ja-JP': ` # Permissions |Permisson (kind)|Description|Endpoints| |:--|:--|:--| ${permissionTable} ` - } as { [x: string]: string }; + }; return lang in descriptions ? descriptions[lang] : descriptions['ja-JP']; } |