binds all API routes to api prefix route, refactors to support
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
Route, Switch, withRouter, Redirect,
|
||||
} from 'react-router-dom';
|
||||
import DefaultList from './views/collections/List';
|
||||
import config from '../config/sanitizedClientConfig';
|
||||
import config from '../securedConfig';
|
||||
import { useUser } from './data/User';
|
||||
import Dashboard from './views/Dashboard';
|
||||
import Login from './views/Login';
|
||||
|
||||
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
|
||||
import Cookies from 'universal-cookie';
|
||||
import { useModal } from '@trbl/react-modal';
|
||||
import { requests } from '../../api';
|
||||
import config from '../../config/sanitizedClientConfig';
|
||||
import config from '../../securedConfig';
|
||||
import StayLoggedInModal from '../modals/StayLoggedIn';
|
||||
import useThrottledEffect from '../../hooks/useThrottledEffect';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import Cookies from 'universal-cookie';
|
||||
import some from 'async-some';
|
||||
import ReactSelect from '../../../modules/ReactSelect';
|
||||
import useFieldType from '../../useFieldType';
|
||||
import config from '../../../../config/sanitizedClientConfig';
|
||||
import config from '../../../../securedConfig';
|
||||
import Label from '../../Label';
|
||||
import Error from '../../Error';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { useLocation, NavLink, Link } from 'react-router-dom';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
|
||||
import Arrow from '../../graphics/Arrow';
|
||||
import Icon from '../../graphics/Icon';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { asModal } from '@trbl/react-modal';
|
||||
import ContentBlock from '../../layout/ContentBlock';
|
||||
import Button from '../../controls/Button';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import qs from 'qs';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
import { useLocale } from '../../utilities/Locale';
|
||||
import { useSearchParams } from '../../utilities/SearchParams';
|
||||
import Arrow from '../../graphics/Arrow';
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Filter from '../Filter';
|
||||
import Table from '../../layout/Table';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
|
||||
const { routes: { admin } } = config;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import Button from '../../controls/Button';
|
||||
import api from '../../../api';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, {
|
||||
createContext, useContext, useState, useEffect,
|
||||
} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
import { useSearchParams } from '../SearchParams';
|
||||
|
||||
const defaultLocale = (config.localization && config.localization.defaultLocale) ? config.localization.defaultLocale : 'en';
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Redirect,
|
||||
} from 'react-router-dom';
|
||||
import { useStatusList } from '../../modules/Status';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
|
||||
const RedirectToLogin = () => {
|
||||
const { addStatus } = useStatusList();
|
||||
|
||||
@@ -6,7 +6,7 @@ import ContentBlock from '../../layout/ContentBlock';
|
||||
import Form from '../../forms/Form';
|
||||
import RenderFields from '../../forms/RenderFields';
|
||||
import FormSubmit from '../../forms/Submit';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
import { useUser } from '../../data/User';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import DefaultTemplate from '../../layout/DefaultTemplate';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import Form from '../../forms/Form';
|
||||
import Email from '../../forms/field-types/Email';
|
||||
import Password from '../../forms/field-types/Password';
|
||||
import FormSubmit from '../../forms/Submit';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
import Button from '../../controls/Button';
|
||||
import { useUser } from '../../data/User';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { useUser } from '../../data/User';
|
||||
import ContentBlock from '../../layout/ContentBlock';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
import Button from '../../controls/Button';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import config from '../../../config/sanitizedClientConfig';
|
||||
import config from '../../../securedConfig';
|
||||
import Button from '../../controls/Button';
|
||||
import DefaultTemplate from '../../layout/DefaultTemplate';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useRouteMatch, useHistory } from 'react-router-dom';
|
||||
import config from '../../../../config/sanitizedClientConfig';
|
||||
import config from '../../../../securedConfig';
|
||||
import DefaultTemplate from '../../../layout/DefaultTemplate';
|
||||
import usePayloadAPI from '../../../../hooks/usePayloadAPI';
|
||||
import Form from '../../../forms/Form';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useLocation } from 'react-router-dom';
|
||||
import queryString from 'qs';
|
||||
import PropTypes from 'prop-types';
|
||||
import usePayloadAPI from '../../../../hooks/usePayloadAPI';
|
||||
import config from '../../../../config/sanitizedClientConfig';
|
||||
import config from '../../../../securedConfig';
|
||||
import DefaultTemplate from '../../../layout/DefaultTemplate';
|
||||
import HeadingButton from '../../../modules/HeadingButton';
|
||||
import SearchableTable from '../../../modules/SearchableTable';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import config from '../../../../config/sanitizedClientConfig';
|
||||
import config from '../../../../securedConfig';
|
||||
import DefaultTemplate from '../../../layout/DefaultTemplate';
|
||||
import usePayloadAPI from '../../../../hooks/usePayloadAPI';
|
||||
import Form from '../../../forms/Form';
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
module.exports = (cssOptions, preProcessor) => {
|
||||
const loaders = [
|
||||
require.resolve('style-loader'),
|
||||
{
|
||||
loader: require.resolve('css-loader'),
|
||||
options: cssOptions,
|
||||
},
|
||||
{
|
||||
// Options for PostCSS as we reference these options twice
|
||||
// Adds vendor prefixing based on your specified browser support in
|
||||
// package.json
|
||||
loader: require.resolve('postcss-loader'),
|
||||
options: {
|
||||
// Necessary for external CSS imports to work
|
||||
// https://github.com/facebook/create-react-app/issues/2677
|
||||
ident: 'postcss',
|
||||
plugins: () => [
|
||||
require('postcss-flexbugs-fixes'),
|
||||
require('postcss-preset-env')({
|
||||
autoprefixer: {
|
||||
flexbox: 'no-2009',
|
||||
},
|
||||
stage: 3,
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
if (preProcessor) {
|
||||
loaders.push(require.resolve(preProcessor));
|
||||
}
|
||||
return loaders;
|
||||
};
|
||||
@@ -1,131 +0,0 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const getStyleLoaders = require('./getStyleLoaders');
|
||||
|
||||
module.exports = (config) => {
|
||||
return {
|
||||
entry: {
|
||||
main: [path.resolve(__dirname, '../../../node_modules/webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000'), path.resolve(__dirname, '../components/index.js')],
|
||||
},
|
||||
output: {
|
||||
path: '/',
|
||||
publicPath: '/static',
|
||||
filename: '[name].js',
|
||||
},
|
||||
devServer: {
|
||||
historyApiFallback: true,
|
||||
},
|
||||
devtool: 'source-map',
|
||||
mode: 'development',
|
||||
node: {
|
||||
__dirname: true,
|
||||
},
|
||||
resolveLoader: { modules: [path.join(__dirname, '../../../node_modules')] },
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: require.resolve('../components/customComponents'),
|
||||
use: [
|
||||
{
|
||||
loader: 'val-loader',
|
||||
options: config,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: require.resolve('./sanitizedClientConfig'),
|
||||
use: [
|
||||
{
|
||||
loader: 'val-loader',
|
||||
options: config,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
[
|
||||
require.resolve('@babel/preset-env'),
|
||||
{
|
||||
modules: 'commonjs',
|
||||
},
|
||||
],
|
||||
require.resolve('@babel/preset-react'),
|
||||
],
|
||||
plugins: [
|
||||
require.resolve('@babel/plugin-proposal-class-properties'),
|
||||
require.resolve('@babel/plugin-proposal-optional-chaining'),
|
||||
require.resolve('babel-plugin-add-module-exports'),
|
||||
[
|
||||
require.resolve('@babel/plugin-transform-runtime'),
|
||||
{
|
||||
regenerator: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// "oneOf" will traverse all following loaders until one will
|
||||
// match the requirements. When no loader matches it will fall
|
||||
// back to the "file" loader at the end of the loader list.
|
||||
oneOf: [
|
||||
// "url" loader works like "file" loader except that it embeds assets
|
||||
// smaller than specified limit in bytes as data URLs to avoid requests.
|
||||
// A missing `test` is equivalent to a match.
|
||||
{
|
||||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||
loader: require.resolve('url-loader'),
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// Opt-in support for SASS (using .scss or .sass extensions).
|
||||
// Chains the sass-loader with the css-loader and the style-loader
|
||||
// to immediately apply all styles to the DOM.
|
||||
{
|
||||
test: /\.(scss|sass|css)$/,
|
||||
use: getStyleLoaders({ importLoaders: 2 }, 'sass-loader'),
|
||||
},
|
||||
// "file" loader makes sure those assets get served by WebpackDevServer.
|
||||
// When you `import` an asset, you get its (virtual) filename.
|
||||
// In production, they would get copied to the `build` folder.
|
||||
// This loader doesn't use a "test" so it will catch all modules
|
||||
// that fall through the other loaders.
|
||||
{
|
||||
// Exclude `js` files to keep "css" loader working as it injects
|
||||
// its runtime that would otherwise processed through "file" loader.
|
||||
// Also exclude `html` and `json` extensions so they get processed
|
||||
// by webpacks internal loaders.
|
||||
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
|
||||
loader: require.resolve('file-loader'),
|
||||
options: {
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, '../index.html'),
|
||||
filename: './index.html',
|
||||
}),
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
],
|
||||
resolve: {
|
||||
modules: ['node_modules', path.resolve(__dirname, '../../../node_modules')],
|
||||
alias: {
|
||||
'payload-scss-overrides': config.paths.scssOverrides,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -1,103 +0,0 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const path = require('path');
|
||||
const getStyleLoaders = require('./getStyleLoaders');
|
||||
|
||||
module.exports = (config) => {
|
||||
return {
|
||||
entry: {
|
||||
main: [path.resolve(__dirname, '../components/index.js')],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(process.cwd(), 'build'),
|
||||
filename: '[name].[chunkhash].js',
|
||||
},
|
||||
mode: 'production',
|
||||
resolveLoader: { modules: [path.join(__dirname, '../../../node_modules')] },
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
[
|
||||
require.resolve('@babel/preset-env'),
|
||||
{
|
||||
modules: 'commonjs',
|
||||
},
|
||||
],
|
||||
require.resolve('@babel/preset-react'),
|
||||
],
|
||||
plugins: [
|
||||
require.resolve('@babel/plugin-proposal-class-properties'),
|
||||
require.resolve('babel-plugin-add-module-exports'),
|
||||
[
|
||||
require.resolve('@babel/plugin-transform-runtime'),
|
||||
{
|
||||
regenerator: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// "oneOf" will traverse all following loaders until one will
|
||||
// match the requirements. When no loader matches it will fall
|
||||
// back to the "file" loader at the end of the loader list.
|
||||
oneOf: [
|
||||
// "url" loader works like "file" loader except that it embeds assets
|
||||
// smaller than specified limit in bytes as data URLs to avoid requests.
|
||||
// A missing `test` is equivalent to a match.
|
||||
{
|
||||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||
loader: require.resolve('url-loader'),
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// Opt-in support for SASS (using .scss or .sass extensions).
|
||||
// Chains the sass-loader with the css-loader and the style-loader
|
||||
// to immediately apply all styles to the DOM.
|
||||
{
|
||||
test: /\.(scss|sass)$/,
|
||||
use: getStyleLoaders({ importLoaders: 2 }, 'sass-loader'),
|
||||
},
|
||||
// "file" loader makes sure those assets get served by WebpackDevServer.
|
||||
// When you `import` an asset, you get its (virtual) filename.
|
||||
// In production, they would get copied to the `build` folder.
|
||||
// This loader doesn't use a "test" so it will catch all modules
|
||||
// that fall through the other loaders.
|
||||
{
|
||||
// Exclude `js` files to keep "css" loader working as it injects
|
||||
// its runtime that would otherwise processed through "file" loader.
|
||||
// Also exclude `html` and `json` extensions so they get processed
|
||||
// by webpacks internal loaders.
|
||||
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
|
||||
loader: require.resolve('file-loader'),
|
||||
options: {
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, '../index.html'),
|
||||
filename: './index.html',
|
||||
minify: true,
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
modules: ['node_modules', path.resolve(__dirname, '../../../node_modules')],
|
||||
alias: {
|
||||
'payload-scss-overrides': config.paths.scssOverrides,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
const sanitizeConfig = require('../utilities/sanitizeConfig');
|
||||
|
||||
module.exports = config => sanitizeConfig(config);
|
||||
@@ -1,5 +1,5 @@
|
||||
const sanitizeConfig = require('../../utilities/sanitizeConfig');
|
||||
const secureConfig = require('../../utilities/secureConfig');
|
||||
const sanitizeConfig = require('../utilities/sanitizeConfig');
|
||||
const secureConfig = require('../utilities/secureConfig');
|
||||
|
||||
module.exports = (config) => {
|
||||
const sanitizedConfig = sanitizeConfig(config);
|
||||
Reference in New Issue
Block a user