mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Save endpoint json via Promise Pool
This commit is contained in:
parent
ac455806e8
commit
88d64f528e
1 changed files with 39 additions and 29 deletions
|
|
@ -2,6 +2,7 @@ import { dirname } from 'path'
|
||||||
|
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
|
import { PromisePool } from '@supercharge/promise-pool'
|
||||||
|
|
||||||
import buildAppList from './helpers/build-app-list.js'
|
import buildAppList from './helpers/build-app-list.js'
|
||||||
import buildGamesList from './helpers/build-game-list.js'
|
import buildGamesList from './helpers/build-game-list.js'
|
||||||
|
|
@ -191,9 +192,11 @@ class BuildLists {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveApiEndpoints = async function ( listOptions ) {
|
saveApiEndpoints = async function ( listOptions ) {
|
||||||
// Save each enpoint's data
|
|
||||||
for ( const listEntry of this.lists[listOptions.name] ) {
|
|
||||||
|
|
||||||
|
await PromisePool
|
||||||
|
.withConcurrency(100)
|
||||||
|
.for( Array.from( this.lists[listOptions.name] ) )
|
||||||
|
.process(async ( listEntry, index, pool ) => {
|
||||||
// console.log('listEntry', listEntry)
|
// console.log('listEntry', listEntry)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
@ -212,7 +215,7 @@ class BuildLists {
|
||||||
if (fs.existsSync(endpointPath)) {
|
if (fs.existsSync(endpointPath)) {
|
||||||
console.log(`Path "${endpointPath}" already exists`)
|
console.log(`Path "${endpointPath}" already exists`)
|
||||||
|
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(`Saving endpoint "${endpoint}" to "${endpointPath}"`)
|
// console.log(`Saving endpoint "${endpoint}" to "${endpointPath}"`)
|
||||||
|
|
@ -222,7 +225,14 @@ class BuildLists {
|
||||||
|
|
||||||
// Write the endpoint to JSON
|
// Write the endpoint to JSON
|
||||||
await this.saveToJson( listEntry, endpointPath )
|
await this.saveToJson( listEntry, endpointPath )
|
||||||
}
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Save each enpoint's data
|
||||||
|
// for ( const listEntry of this.lists[listOptions.name] ) {
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save app lists to JSON
|
// Save app lists to JSON
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue