mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
16 lines
466 B
TypeScript
16 lines
466 B
TypeScript
|
import type { SourceID } from "@shared/types"
|
||
|
import * as x from "glob:./sources/{*.ts,**/index.ts}"
|
||
|
import type { SourceGetter } from "./types"
|
||
|
|
||
|
export const getters = (function () {
|
||
|
const getters = {} as Record<SourceID, SourceGetter>
|
||
|
typeSafeObjectEntries(x).forEach(([id, x]) => {
|
||
|
if (x.default instanceof Function) {
|
||
|
Object.assign(getters, { [id]: x.default })
|
||
|
} else {
|
||
|
Object.assign(getters, x.default)
|
||
|
}
|
||
|
})
|
||
|
return getters
|
||
|
})()
|