api copied to hudozka-api module based on express
This commit is contained in:
1 parent
70007d3199
commit
fc0724a900
21 files changed
+1093
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import Data from './Data'
|
||||
import { findOne } from '../lib/store'
|
||||
|
||||
const store = () => Data.getStore('Settings')
|
||||
|
||||
export default class Config {
|
||||
static async findConfig() {
|
||||
const config = await Config.findById('settings')
|
||||
return config || new Config({} as any)
|
||||
}
|
||||
|
||||
static async findById(id: string) {
|
||||
const data = await findOne(store(), { id })
|
||||
if (!data) return null
|
||||
|
||||
return new Config(data)
|
||||
}
|
||||
|
||||
public hash: any
|
||||
public file: any
|
||||
public server: any
|
||||
public articlesPerPage: any
|
||||
public collectiveOrder: any
|
||||
public articleCardDefaultPreview: any
|
||||
public collectiveImage: any
|
||||
public redirect: any
|
||||
|
||||
constructor({ hash, file, ...data }) {
|
||||
this.hash = hash
|
||||
this.file = file
|
||||
this.server = data.server
|
||||
this.articlesPerPage = data.articlesPerPage || 5
|
||||
this.collectiveOrder = data.collectiveOrder || []
|
||||
this.articleCardDefaultPreview = data.articleCardDefaultPreview
|
||||
this.collectiveImage = data.collectiveImage
|
||||
|
||||
const redirect = data.redirect || {}
|
||||
this.redirect = new Map(Object
|
||||
.entries(redirect)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user