Skip to content

Commit

Permalink
feat(Walk): Resize to current folder API only; Remove stale CORS port…
Browse files Browse the repository at this point in the history
…s; Display joi errors
  • Loading branch information
danactive committed Jun 13, 2020
1 parent 1450df2 commit 87405b7
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 83 deletions.
113 changes: 64 additions & 49 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"dependencies": {
"@hapi/hapi": "^18.4.1",
"@hapi/joi": "^15.1.1",
"app-root-path": "^2.2.1",
"app-root-path": "^3.0.0",
"async": "^2.6.3",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.16.0",
"boom": "^7.0.0",
"camelcase": "^5.3.1",
"camelcase": "^6.0.0",
"clone": "^2.1.1",
"dot-prop": "^5.2.0",
"dotenv": "^8.2.0",
Expand All @@ -46,7 +46,7 @@
"node-notifier": "^7.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"sharp": "^0.25.3",
"sharp": "^0.25.4",
"styled-components": "^4.4.1",
"tap-webpack-plugin": "^2.0.0",
"tuxharness": "^2.0.4",
Expand Down
18 changes: 16 additions & 2 deletions api/server/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const boom = require('boom');
const hapi = require('@hapi/hapi');
const hapiReactViews = require('hapi-react-views');
const notifier = require('node-notifier');
Expand All @@ -8,14 +9,27 @@ const config = require('../../config.json');
const log = require('./plugins/log');
const plugins = require('./lib/plugins');

const { apiPort: port } = config;
const { apiPort: port, uiPort } = config;
const logger = log.createLogger('server');

const server = hapi.Server({
port,
routes: {
cors: {
origin: ['http://localhost:3000'],
origin: [`http://localhost:${uiPort}`],
},
validate: {
failAction: async (request, h, err) => {
if (process.env.NODE_ENV === 'production') {
// In prod, log a limited error message and throw the default Bad Request error.
console.error('ValidationError:', err.message);
throw boom.badRequest('Invalid request payload input');
} else {
// During development, log and respond with the full error.
console.error(err);
throw err;
}
},
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion api/server/lib/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const plugins = [
{ plugin: viewAlbum, routes: { prefix: '/view' } },
{ plugin: editAlbum, routes: { prefix: '/edit' } },
{ plugin: libGallery },
{ plugin: generatePreview },
{ plugin: generatePreview, routes: { prefix: '/preview' } },
{ plugin: libGeojson, routes: { prefix: '/geojson' } },
{ plugin: libHome },
{ plugin: libPublic },
Expand Down
3 changes: 0 additions & 3 deletions api/server/plugins/generate-preview/test/.eslintrc.js

This file was deleted.

Loading

0 comments on commit 87405b7

Please sign in to comment.