@@ -13,18 +13,12 @@ import {
13
13
import { argv , stdout } from 'process' ;
14
14
import { dirname , join } from 'path' ;
15
15
import { fileURLToPath } from 'url' ;
16
- import { readdir , rm , writeFile } from 'fs/promises' ;
16
+ import { readdir , rm } from 'fs/promises' ;
17
17
import { Jsoning } from 'jsoning' ;
18
- import { DevIds , LangSpecURL , permissionsBits , PORT } from './config' ;
19
- import {
20
- Command ,
21
- CommandClient ,
22
- createServer ,
23
- FullEntry ,
24
- logger ,
25
- Methods
26
- } from './lib' ;
18
+ import { DevIds , permissionsBits , PORT } from './config' ;
19
+ import { Command , CommandClient , createServer , logger , Methods } from './lib' ;
27
20
import { scheduleJob } from 'node-schedule' ;
21
+ import { refreshCachedLangSpec } from '@/lib/kumilinwa/refreshCache' ;
28
22
29
23
const Dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
30
24
@@ -252,15 +246,3 @@ async function sendError(e: Error) {
252
246
} ) ;
253
247
}
254
248
}
255
-
256
- async function refreshCachedLangSpec ( ) {
257
- const data = ( await fetch ( LangSpecURL )
258
- . then ( res => res . json ( ) )
259
- . catch ( e => sendError ) ) as FullEntry [ ] ;
260
- await writeFile (
261
- join ( Dirname , 'lib' , 'kumilinwa' , 'langspec.cache.json' ) ,
262
- JSON . stringify ( data )
263
- ) ;
264
- await StatsDB . set ( 'langSpecCacheAge' , Date . now ( ) ) ;
265
- logger . debug ( 'Cached language specification.' ) ;
266
- }
0 commit comments