Skip to content

Commit

Permalink
fix(API): Prepare for React view SSR move
Browse files Browse the repository at this point in the history
  • Loading branch information
danactive committed May 30, 2021
1 parent 50968b8 commit f152539
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const hapi = require('@hapi/hapi');
const hapiReactViews = require('hapi-react-views');
const joi = require('@hapi/joi');
const notifier = require('node-notifier');
const path = require('path');

require('tuxharness');

Expand Down Expand Up @@ -54,7 +55,7 @@ function getViewsConfig() {
isCached: true,
path: './',
partialsPath: './',
relativeTo: __dirname,
relativeTo: path.join(__dirname, '../../'),
};
}

Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/album/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const handler = (request, reply) => new Promise((resolve) => {
gallery,
raw: isRaw = false,
} = request.query;
const viewPath = 'plugins/album/components/page.jsx';
const viewPath = 'api/server/plugins/album/components/page.jsx';

const applyCloud = (response) => ((cloud === 'dropbox') ? applyDropbox(response) : response);
const handleResponse = (json) => ((isRaw) ? resolve(json) : resolve(reply.view(viewPath, json)));
Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/album/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('Verify /view/album route', { skip: false }, (describe) => {
engines: {
jsx: hapiReactViews,
},
relativeTo: path.join(__dirname, '../../../'),
relativeTo: path.join(__dirname, '../../../../../'),
};

const request = {
Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/editAlbum/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const handler = ({ query: { raw: isRaw } }, reply) => new Promise((resolve) => {

return context;
};
const viewPath = 'plugins/editAlbum/components/page.jsx';
const viewPath = 'api/server/plugins/editAlbum/components/page.jsx';

const handleResponse = ({ body: { galleries: json } }) => ((isRaw)
? resolve(reply(formatJson(json)))
Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/home/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const gallery = require('../../../../../app/src/galleries');

async function handler(request, reply) {
const isRaw = request.query.raw;
const viewPath = 'plugins/home/components/page.jsx';
const viewPath = 'api/server/plugins/home/components/page.jsx';
const { body: { galleries } } = await gallery.get();
const out = { galleries };

Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/home/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tape('Verify home / route', { skip: false }, (describe) => {
engines: {
jsx: hapiReactViews,
},
relativeTo: path.join(__dirname, '../../../'),
relativeTo: path.join(__dirname, '../../../../../'),
};

const request = {
Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/video/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const validation = require('../../../lib/validation');

const handler = (request, reply) => new Promise((resolve) => {
const isRaw = request.query.raw;
const viewPath = 'plugins/video/components/page.jsx';
const viewPath = 'api/server/plugins/video/components/page.jsx';
const handleResponse = (json) => ((isRaw) ? resolve(json) : resolve(reply.view(viewPath, json)));

handleResponse({ video: request.query });
Expand Down
2 changes: 1 addition & 1 deletion api/server/plugins/video/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tape('Verify /video route', { skip: false }, (describe) => {
engines: {
jsx: hapiReactViews,
},
relativeTo: path.join(__dirname, '../../../'),
relativeTo: path.join(__dirname, '../../../../../'),
};

const request = {
Expand Down
2 changes: 1 addition & 1 deletion api/server/test/casesDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function execHapi({
engines: {
jsx: hapiReactViews,
},
relativeTo: path.join(__dirname, '../../'),
relativeTo: path.join(__dirname, '../../../../'),
};

try {
Expand Down

0 comments on commit f152539

Please sign in to comment.