Create default store
This commit is contained in:
@@ -6,6 +6,7 @@ import modelsLoader from "./models"
|
|||||||
import servicesLoader from "./services"
|
import servicesLoader from "./services"
|
||||||
import passportLoader from "./passport"
|
import passportLoader from "./passport"
|
||||||
import pluginsLoader from "./plugins"
|
import pluginsLoader from "./plugins"
|
||||||
|
import storeLoader from "./store"
|
||||||
import Logger from "./logger"
|
import Logger from "./logger"
|
||||||
|
|
||||||
export default async ({ directory: rootDirectory, expressApp }) => {
|
export default async ({ directory: rootDirectory, expressApp }) => {
|
||||||
@@ -57,6 +58,9 @@ export default async ({ directory: rootDirectory, expressApp }) => {
|
|||||||
await apiLoader({ container, rootDirectory, app: expressApp })
|
await apiLoader({ container, rootDirectory, app: expressApp })
|
||||||
Logger.info("API initialized")
|
Logger.info("API initialized")
|
||||||
|
|
||||||
|
await storeLoader({ container })
|
||||||
|
Logger.info("Store initialized")
|
||||||
|
|
||||||
return { container, dbConnection, app: expressApp }
|
return { container, dbConnection, app: expressApp }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Registers all services in the services directory
|
||||||
|
*/
|
||||||
|
export default ({ container }) => {
|
||||||
|
const storeService = container.resolve("storeService")
|
||||||
|
return storeService.create()
|
||||||
|
}
|
||||||
@@ -39,6 +39,19 @@ class StoreService extends BaseService {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a store if it doesn't already exist.
|
||||||
|
* @return {Promise<Store>} the store.
|
||||||
|
*/
|
||||||
|
async create() {
|
||||||
|
const store = await this.retrieve()
|
||||||
|
if (!store) {
|
||||||
|
return this.storeModel_.create({})
|
||||||
|
}
|
||||||
|
|
||||||
|
return store
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the store settings. There is always a maximum of one store.
|
* Retrieve the store settings. There is always a maximum of one store.
|
||||||
* @return {Promise<Store>} the customer document.
|
* @return {Promise<Store>} the customer document.
|
||||||
|
|||||||
Reference in New Issue
Block a user