Skip to content

Commit 7934b22

Browse files
refactor(indiekit): remove application from Indiekit instance
1 parent 0e5b8c1 commit 7934b22

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

packages/indiekit/config/express.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const expressConfig = (Indiekit) => {
4242
// Session
4343
app.use(
4444
cookieSession({
45-
name: Indiekit.application.name,
45+
name: Indiekit.config.application.name,
4646
secret: crypto.randomUUID(),
4747
maxAge: 7 * 24 * 60 * 60 * 1000, // 7 days,
4848
}),

packages/indiekit/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ export const Indiekit = class {
2626
*/
2727
constructor(config) {
2828
this.config = config;
29-
this.application = this.config.application;
3029
this.package = package_;
31-
this.publication = this.config.publication;
3230

3331
this.collections = new Map();
3432
this.endpoints = new Set();
3533
this.installedPlugins = new Set();
34+
this.locale = config.application?.locale;
3635
this.locales = locales;
37-
this.mongodbUrl = config.application.mongodbUrl;
36+
this.mongodbUrl = config.application?.mongodbUrl;
3837
this.postTypes = new Map();
38+
this.publication = this.config.publication;
3939
this.stores = new Set();
4040
this.validationSchemas = new Map();
4141
}

packages/indiekit/lib/categories.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getCachedResponse } from "./cache.js";
77
* @returns {Promise<Array>} Array of categories
88
*/
99
export const getCategories = async (Indiekit) => {
10-
const { application, cache, publication } = Indiekit;
10+
const { cache, config, publication } = Indiekit;
1111
const { categories } = publication;
1212

1313
let categoryList = [];
@@ -17,7 +17,11 @@ export const getCategories = async (Indiekit) => {
1717
}
1818

1919
if (categories && URL.canParse(categories)) {
20-
categoryList = await getCachedResponse(cache, application.ttl, categories);
20+
categoryList = await getCachedResponse(
21+
cache,
22+
config.application.ttl,
23+
categories,
24+
);
2125
}
2226

2327
if (categoryList) {

packages/indiekit/lib/middleware/internationalisation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import i18n from "i18n";
88
export const internationalisation = (Indiekit) =>
99
function (request, response, next) {
1010
try {
11-
const { application, localeCatalog } = Indiekit;
11+
const { locale, localeCatalog } = Indiekit;
1212

1313
i18n.configure({
1414
cookie: "locale",
@@ -22,8 +22,8 @@ export const internationalisation = (Indiekit) =>
2222
i18n.init(request, response);
2323

2424
// Override system locale with configured value
25-
if (application.locale) {
26-
response.locals.setLocale(application.locale);
25+
if (locale) {
26+
response.locals.setLocale(locale);
2727
}
2828

2929
next();

0 commit comments

Comments
 (0)