create-catalyst-app-internal 0.0.1-beta.60 → 0.0.1-beta.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/cli.cjs +15 -1
- package/templates/none-js/package.json +1 -1
- package/templates/none-ts/client/index.js +23 -0
- package/templates/none-ts/package.json +34 -0
- package/templates/none-ts/src/js/containers/App/index.js +16 -0
- package/templates/none-ts/src/js/routes/utils.js +42 -0
- package/templates/none-ts/tsconfig.json +13 -0
- package/templates/none-ts/types.d.ts +4 -0
- package/templates/redux-js/package.json +1 -1
- package/templates/redux-ts/client/index.js +28 -0
- package/templates/redux-ts/package.json +37 -0
- package/templates/redux-ts/src/js/containers/App/actions.js +17 -0
- package/templates/redux-ts/src/js/containers/App/index.js +16 -0
- package/templates/redux-ts/src/js/containers/App/reducer.js +19 -0
- package/templates/redux-ts/src/js/routes/utils.js +42 -0
- package/templates/redux-ts/src/js/store/index.js +28 -0
- package/templates/redux-ts/tsconfig.json +13 -0
- package/templates/redux-ts/types.d.ts +4 -0
- package/templates/rtk-js/package.json +1 -1
- package/templates/rtk-ts/client/index.js +28 -0
- package/templates/rtk-ts/package.json +37 -0
- package/templates/rtk-ts/src/js/containers/App/index.js +16 -0
- package/templates/rtk-ts/src/js/containers/App/reducer.js +18 -0
- package/templates/rtk-ts/src/js/routes/utils.js +42 -0
- package/templates/rtk-ts/src/js/store/index.js +28 -0
- package/templates/rtk-ts/tsconfig.json +13 -0
- package/templates/rtk-ts/types.d.ts +4 -0
package/package.json
CHANGED
package/scripts/cli.cjs
CHANGED
|
@@ -47,7 +47,7 @@ const program = new Commander.Command()
|
|
|
47
47
|
console.log(red(`${projectName} already exists, try again.`))
|
|
48
48
|
process.exit(1)
|
|
49
49
|
}
|
|
50
|
-
const language =
|
|
50
|
+
const language = await promptTypescript()
|
|
51
51
|
const projectDescription = await promptDescription()
|
|
52
52
|
const stateManagement = cmd.stateManagement || (await promptStateManagement())
|
|
53
53
|
|
|
@@ -218,6 +218,20 @@ async function promptDescription() {
|
|
|
218
218
|
} else return null
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
async function promptTypescript() {
|
|
222
|
+
const response = await prompts({
|
|
223
|
+
type: "select",
|
|
224
|
+
name: "typescript",
|
|
225
|
+
message: "Would you like to use TypeScript?",
|
|
226
|
+
choices: [
|
|
227
|
+
{ title: "Yes", value: "ts" },
|
|
228
|
+
{ title: "No", value: "js" },
|
|
229
|
+
],
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
return response.typescript
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
function validateOptions(cmd) {
|
|
222
236
|
// Validate language option
|
|
223
237
|
if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import "./styles"
|
|
3
|
+
import { hydrateRoot } from "react-dom/client"
|
|
4
|
+
import { loadableReady } from "@loadable/component"
|
|
5
|
+
import { RouterProvider } from "@tata1mg/router"
|
|
6
|
+
import clientRouter from "catalyst-core-internal/router/ClientRouter"
|
|
7
|
+
|
|
8
|
+
window.addEventListener("load", () => {
|
|
9
|
+
loadableReady(() => {
|
|
10
|
+
const { __ROUTER_INITIAL_DATA__: routerInitialData } = window
|
|
11
|
+
|
|
12
|
+
const router = clientRouter({ routerInitialState: routerInitialData })
|
|
13
|
+
|
|
14
|
+
const Application = (
|
|
15
|
+
<React.StrictMode>
|
|
16
|
+
<RouterProvider router={router} />
|
|
17
|
+
</React.StrictMode>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const container = document.getElementById("app")
|
|
21
|
+
hydrateRoot(container, Application)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-catalyst-app-starter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"start": "catalyst start",
|
|
6
|
+
"build": "npm run typecheck && catalyst build",
|
|
7
|
+
"serve": "catalyst serve",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"devBuild": "catalyst devBuild",
|
|
10
|
+
"devServe": "catalyst devServe",
|
|
11
|
+
"typecheck": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"_moduleAliases": {
|
|
14
|
+
"@api": "api.js",
|
|
15
|
+
"@containers": "src/js/containers",
|
|
16
|
+
"@server": "server",
|
|
17
|
+
"@config": "config",
|
|
18
|
+
"@css": "src/static/css",
|
|
19
|
+
"@routes": "src/js/routes/"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@loadable/component": "^5.16.3",
|
|
23
|
+
"@tata1mg/router": "^0.0.1-beta.7",
|
|
24
|
+
"catalyst-core-internal": "^0.0.1-beta.61"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"eslint": "^8.26.0",
|
|
28
|
+
"typescript": "^5.8.3",
|
|
29
|
+
"@types/react": "^18.2.0",
|
|
30
|
+
"@types/react-dom": "^18.2.0",
|
|
31
|
+
"eslint-plugin-react": "^7.34.1",
|
|
32
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Outlet } from "@tata1mg/router"
|
|
3
|
+
|
|
4
|
+
const App = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<Outlet />
|
|
8
|
+
</>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
App.serverSideFunction = () => {
|
|
13
|
+
return new Promise((resolve) => resolve())
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default App
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { RouterDataProvider, MetaTag } from "@tata1mg/router"
|
|
3
|
+
import App from "@containers/App"
|
|
4
|
+
import routes from "./index.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Making the routes array compatible with the format accepted by createBrowserRouter
|
|
8
|
+
* API on the client side
|
|
9
|
+
* https://reactrouter.com/en/main/routers/create-browser-router
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const preparedRoutes = ({ routerInitialState }) => {
|
|
13
|
+
const getPreparedRoutes = (routes) => {
|
|
14
|
+
return routes.map((route, index) => {
|
|
15
|
+
const Component = route.component
|
|
16
|
+
const routeToRender = {
|
|
17
|
+
...route,
|
|
18
|
+
element: <Component key={index} />,
|
|
19
|
+
}
|
|
20
|
+
if (route.children) {
|
|
21
|
+
routeToRender.children = getPreparedRoutes(route.children)
|
|
22
|
+
}
|
|
23
|
+
return routeToRender
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
element: (
|
|
30
|
+
<RouterDataProvider config={{}} initialState={routerInitialState}>
|
|
31
|
+
<MetaTag />
|
|
32
|
+
<App />
|
|
33
|
+
</RouterDataProvider>
|
|
34
|
+
),
|
|
35
|
+
children: getPreparedRoutes(routes),
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getRoutes = () => {
|
|
41
|
+
return routes
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import "./styles"
|
|
3
|
+
import { hydrateRoot } from "react-dom/client"
|
|
4
|
+
import { loadableReady } from "@loadable/component"
|
|
5
|
+
import { Provider } from "react-redux"
|
|
6
|
+
import { RouterProvider } from "@tata1mg/router"
|
|
7
|
+
import clientRouter from "catalyst-core-internal/router/ClientRouter"
|
|
8
|
+
import configureStore from "@store"
|
|
9
|
+
|
|
10
|
+
window.addEventListener("load", () => {
|
|
11
|
+
loadableReady(() => {
|
|
12
|
+
const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window
|
|
13
|
+
const store = configureStore(__INITIAL_STATE__ || {})
|
|
14
|
+
|
|
15
|
+
const router = clientRouter({ store, routerInitialState: routerInitialData })
|
|
16
|
+
|
|
17
|
+
const Application = (
|
|
18
|
+
<Provider store={store} serverState={__INITIAL_STATE__}>
|
|
19
|
+
<React.StrictMode>
|
|
20
|
+
<RouterProvider router={router} />
|
|
21
|
+
</React.StrictMode>
|
|
22
|
+
</Provider>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const container = document.getElementById("app")
|
|
26
|
+
hydrateRoot(container, Application)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-catalyst-app-starter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"start": "catalyst start",
|
|
6
|
+
"build": "npm run typecheck && catalyst build",
|
|
7
|
+
"serve": "catalyst serve",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"devBuild": "catalyst devBuild",
|
|
10
|
+
"devServe": "catalyst devServe",
|
|
11
|
+
"typecheck": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"_moduleAliases": {
|
|
14
|
+
"@api": "api.js",
|
|
15
|
+
"@containers": "src/js/containers",
|
|
16
|
+
"@server": "server",
|
|
17
|
+
"@config": "config",
|
|
18
|
+
"@css": "src/static/css",
|
|
19
|
+
"@routes": "src/js/routes/",
|
|
20
|
+
"@store": "src/js/store/index.js"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@loadable/component": "^5.16.3",
|
|
24
|
+
"@tata1mg/router": "^0.0.1-beta.7",
|
|
25
|
+
"catalyst-core-internal": "^0.0.1-beta.61",
|
|
26
|
+
"@reduxjs/toolkit": "1.9.3",
|
|
27
|
+
"react-redux": "^8.1.3"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"eslint": "^8.26.0",
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"@types/react": "^18.2.0",
|
|
33
|
+
"@types/react-dom": "^18.2.0",
|
|
34
|
+
"eslint-plugin-react": "^7.34.1",
|
|
35
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const createActionTypes = (prefix, actionTypeList = []) => {
|
|
2
|
+
const actionTypesObject = {}
|
|
3
|
+
actionTypeList.forEach((item) => {
|
|
4
|
+
actionTypesObject[item] = `${prefix}/${item}`
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
return actionTypesObject
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default createActionTypes
|
|
11
|
+
|
|
12
|
+
export const ShellActions = createActionTypes("shellActions", ["REDUX_TEST"])
|
|
13
|
+
export const reduxTest = () => {
|
|
14
|
+
return {
|
|
15
|
+
type: ShellActions.REDUX_TEST,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Outlet } from "@tata1mg/router"
|
|
3
|
+
|
|
4
|
+
const App = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<Outlet />
|
|
8
|
+
</>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
App.serverSideFunction = () => {
|
|
13
|
+
return new Promise((resolve) => resolve())
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default App
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ShellActions } from "./actions"
|
|
2
|
+
|
|
3
|
+
export const defaultState = {
|
|
4
|
+
testActionDispatched: false,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const shellReducer = (state = defaultState, action) => {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case ShellActions.REDUX_TEST: {
|
|
10
|
+
return {
|
|
11
|
+
...state,
|
|
12
|
+
testActionDispatched: true,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
default:
|
|
17
|
+
return state
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { RouterDataProvider, MetaTag } from "@tata1mg/router"
|
|
3
|
+
import App from "@containers/App"
|
|
4
|
+
import routes from "./index.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Making the routes array compatible with the format accepted by createBrowserRouter
|
|
8
|
+
* API on the client side
|
|
9
|
+
* https://reactrouter.com/en/main/routers/create-browser-router
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const preparedRoutes = ({ store, routerInitialState }) => {
|
|
13
|
+
const getPreparedRoutes = (routes) => {
|
|
14
|
+
return routes.map((route, index) => {
|
|
15
|
+
const Component = route.component
|
|
16
|
+
const routeToRender = {
|
|
17
|
+
...route,
|
|
18
|
+
element: <Component key={index} />,
|
|
19
|
+
}
|
|
20
|
+
if (route.children) {
|
|
21
|
+
routeToRender.children = getPreparedRoutes(route.children)
|
|
22
|
+
}
|
|
23
|
+
return routeToRender
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
element: (
|
|
30
|
+
<RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
|
|
31
|
+
<MetaTag />
|
|
32
|
+
<App />
|
|
33
|
+
</RouterDataProvider>
|
|
34
|
+
),
|
|
35
|
+
children: getPreparedRoutes(routes),
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getRoutes = () => {
|
|
41
|
+
return routes
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { configureStore as createStore } from "@reduxjs/toolkit"
|
|
2
|
+
import { combineReducers } from "redux"
|
|
3
|
+
import { shellReducer } from "@containers/App/reducer.js"
|
|
4
|
+
import fetchInstance from "@api"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
|
|
8
|
+
* @param {object} initialState Default state
|
|
9
|
+
* @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
|
|
10
|
+
* @return {object} The store itself
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const configureStore = (initialState) => {
|
|
14
|
+
const api = fetchInstance
|
|
15
|
+
const store = createStore({
|
|
16
|
+
reducer: combineReducers({ shellReducer }),
|
|
17
|
+
middleware: (getDefaultMiddleware) =>
|
|
18
|
+
getDefaultMiddleware({
|
|
19
|
+
thunk: {
|
|
20
|
+
extraArgument: { api },
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
preloadedState: initialState,
|
|
24
|
+
})
|
|
25
|
+
return store
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default configureStore
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import "./styles"
|
|
3
|
+
import { hydrateRoot } from "react-dom/client"
|
|
4
|
+
import { loadableReady } from "@loadable/component"
|
|
5
|
+
import { Provider } from "react-redux"
|
|
6
|
+
import { RouterProvider } from "@tata1mg/router"
|
|
7
|
+
import clientRouter from "catalyst-core-internal/router/ClientRouter"
|
|
8
|
+
import configureStore from "@store"
|
|
9
|
+
|
|
10
|
+
window.addEventListener("load", () => {
|
|
11
|
+
loadableReady(() => {
|
|
12
|
+
const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window
|
|
13
|
+
const store = configureStore(__INITIAL_STATE__ || {})
|
|
14
|
+
|
|
15
|
+
const router = clientRouter({ store, routerInitialState: routerInitialData })
|
|
16
|
+
|
|
17
|
+
const Application = (
|
|
18
|
+
<Provider store={store} serverState={__INITIAL_STATE__}>
|
|
19
|
+
<React.StrictMode>
|
|
20
|
+
<RouterProvider router={router} />
|
|
21
|
+
</React.StrictMode>
|
|
22
|
+
</Provider>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const container = document.getElementById("app")
|
|
26
|
+
hydrateRoot(container, Application)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-catalyst-app-starter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"start": "catalyst start",
|
|
6
|
+
"build": "npm run typecheck && catalyst build",
|
|
7
|
+
"serve": "catalyst serve",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"devBuild": "catalyst devBuild",
|
|
10
|
+
"devServe": "catalyst devServe",
|
|
11
|
+
"typecheck": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"_moduleAliases": {
|
|
14
|
+
"@api": "api.js",
|
|
15
|
+
"@containers": "src/js/containers",
|
|
16
|
+
"@server": "server",
|
|
17
|
+
"@config": "config",
|
|
18
|
+
"@css": "src/static/css",
|
|
19
|
+
"@routes": "src/js/routes/",
|
|
20
|
+
"@store": "src/js/store/index.js"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@loadable/component": "^5.16.3",
|
|
24
|
+
"@tata1mg/router": "^0.0.1-beta.7",
|
|
25
|
+
"catalyst-core-internal": "^0.0.1-beta.61",
|
|
26
|
+
"@reduxjs/toolkit": "1.9.3",
|
|
27
|
+
"react-redux": "^8.1.3"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"eslint": "^8.26.0",
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"@types/react": "^18.2.0",
|
|
33
|
+
"@types/react-dom": "^18.2.0",
|
|
34
|
+
"eslint-plugin-react": "^7.34.1",
|
|
35
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Outlet } from "@tata1mg/router"
|
|
3
|
+
|
|
4
|
+
const App = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<Outlet />
|
|
8
|
+
</>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
App.serverSideFunction = () => {
|
|
13
|
+
return new Promise((resolve) => resolve())
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default App
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit"
|
|
2
|
+
|
|
3
|
+
const initialState = {
|
|
4
|
+
testActionDispatched: false,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const appSlice = createSlice({
|
|
8
|
+
name: "shellReducer",
|
|
9
|
+
initialState: initialState,
|
|
10
|
+
reducers: {
|
|
11
|
+
reduxTest: (state) => {
|
|
12
|
+
state.testActionDispatched = true
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export const { reduxTest } = appSlice.actions
|
|
18
|
+
export const shellReducer = appSlice.reducer
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { RouterDataProvider, MetaTag } from "@tata1mg/router"
|
|
3
|
+
import App from "@containers/App"
|
|
4
|
+
import routes from "./index.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Making the routes array compatible with the format accepted by createBrowserRouter
|
|
8
|
+
* API on the client side
|
|
9
|
+
* https://reactrouter.com/en/main/routers/create-browser-router
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const preparedRoutes = ({ store, routerInitialState }) => {
|
|
13
|
+
const getPreparedRoutes = (routes) => {
|
|
14
|
+
return routes.map((route, index) => {
|
|
15
|
+
const Component = route.component
|
|
16
|
+
const routeToRender = {
|
|
17
|
+
...route,
|
|
18
|
+
element: <Component key={index} />,
|
|
19
|
+
}
|
|
20
|
+
if (route.children) {
|
|
21
|
+
routeToRender.children = getPreparedRoutes(route.children)
|
|
22
|
+
}
|
|
23
|
+
return routeToRender
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
element: (
|
|
30
|
+
<RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
|
|
31
|
+
<MetaTag />
|
|
32
|
+
<App />
|
|
33
|
+
</RouterDataProvider>
|
|
34
|
+
),
|
|
35
|
+
children: getPreparedRoutes(routes),
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getRoutes = () => {
|
|
41
|
+
return routes
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { configureStore as createStore } from "@reduxjs/toolkit"
|
|
2
|
+
import { combineReducers } from "redux"
|
|
3
|
+
import { shellReducer } from "@containers/App/reducer.js"
|
|
4
|
+
import fetchInstance from "@api"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
|
|
8
|
+
* @param {object} initialState Default state
|
|
9
|
+
* @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
|
|
10
|
+
* @return {object} The store itself
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const configureStore = (initialState) => {
|
|
14
|
+
const api = fetchInstance
|
|
15
|
+
const store = createStore({
|
|
16
|
+
reducer: combineReducers({ shellReducer }),
|
|
17
|
+
middleware: (getDefaultMiddleware) =>
|
|
18
|
+
getDefaultMiddleware({
|
|
19
|
+
thunk: {
|
|
20
|
+
extraArgument: { api },
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
preloadedState: initialState,
|
|
24
|
+
})
|
|
25
|
+
return store
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default configureStore
|