Skip to content

Commit

Permalink
fix: inherit application.locale within default config
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Sep 14, 2020
1 parent b68f442 commit d881ff8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
79 changes: 41 additions & 38 deletions packages/indiekit/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,46 @@ const mediaEndpoint = new MediaEndpoint();
const micropubEndpoint = new MicropubEndpoint();
const shareEndpoint = new ShareEndpoint();

export const defaultConfig = {
application: {
endpoints: [
mediaEndpoint,
micropubEndpoint,
shareEndpoint
],
hasDatabase: false,
locale: 'en',
mongodbUrl: false,
middleware: {
authenticate,
indieauth
},
name: 'Indiekit',
navigationItems: [],
repository: package_.repository,
routes: [],
themeColor: '#0000ee',
version: package_.version,
views: [
path.join(__dirname, '..', 'views')
]
const application = {
endpoints: [
mediaEndpoint,
micropubEndpoint,
shareEndpoint
],
hasDatabase: false,
locale: 'en',
mongodbUrl: false,
middleware: {
authenticate,
indieauth
},
publication: {
categories: [],
me: null,
postTemplate: null,
postTypes: [],
preset: null,
slugSeparator: '-',
store: null,
syndicationTargets: [],
timeZone: 'UTC',
tokenEndpoint: 'https://tokens.indieauth.com/token'
},
server: {
port: process.env.PORT || '3000'
}
name: 'Indiekit',
navigationItems: [],
repository: package_.repository,
routes: [],
themeColor: '#0000ee',
version: package_.version,
views: [
path.join(__dirname, '..', 'views')
]
};

const publication = {
categories: [],
locale: application.locale,
me: null,
postTemplate: null,
postTypes: [],
preset: null,
slugSeparator: '-',
store: null,
syndicationTargets: [],
timeZone: 'UTC',
tokenEndpoint: 'https://tokens.indieauth.com/token'
};

const server = {
port: process.env.PORT || '3000'
};

export const defaultConfig = {application, publication, server};
4 changes: 1 addition & 3 deletions packages/indiekit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export const Indiekit = class {
}

async init() {
const {locale, mongodbUrl} = this.application;
const database = await mongodbConfig(mongodbUrl);
const database = await mongodbConfig(this.application.mongodbUrl);

// Setup databases
if (database) {
Expand All @@ -71,7 +70,6 @@ export const Indiekit = class {

// Update publication configuration
this.publication.categories = await getCategories(cache, this.publication);
this.publication.locale = this.publication.locale || locale;
this.publication.postTemplate = getPostTemplate(this.publication);
this.publication.postTypes = getPostTypes(this.publication);

Expand Down
2 changes: 0 additions & 2 deletions packages/indiekit/tests/routes/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import supertest from 'supertest';
import {defaultConfig} from '../../config/defaults.js';
import {serverConfig} from '../../config/server.js';

// TODO: Shouldn’t need to set additional settings here
defaultConfig.publication.locale = 'en';
const request = supertest(serverConfig(defaultConfig));

test('Returns status page', async t => {
Expand Down

0 comments on commit d881ff8

Please sign in to comment.