Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvin committed May 5, 2023
1 parent 02acf36 commit 2443262
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This repo consists of an [demo app](/apps/web), and the following npm packages:
3. @dsaid/swagger-ui-custom-layout: [source](/packages/swagger-ui-custom-layout), [npm](https://www.npmjs.com/package/@dsaid/swagger-ui-custom-layout)
4. @dsaid/chain-wrap-components: [source](/packages/chain-wrap-components), [npm](https://www.npmjs.com/package/@dsaid/chain-wrap-components)


## Prerequisites

- Node.js v18
Expand All @@ -26,10 +25,11 @@ $ npm install
Managing the monorepo is done by [turbo](https://turbo.build/repo/docs)

```
$ turbo run dev # boot up instance, e.g. http://localhost:8090
$ turbo run dev # boot up instance, e.g. http://localhost:3000
$ turbo run test # run tests for all packages
$ turbo run lint # run lint for all packages
$ turbo run test:watch # run tests in watch mode
$ turbo run build # run build script for all packages and apps
```

Change logs is managed by [changesets](https://github.com/changesets/changesets).
Expand Down
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -- -p 8090",
"dev": "next dev -- -p 3000",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand All @@ -12,6 +12,7 @@
"@dsaid/swagger-ui-plugin-otp-auth": "*",
"@dsaid/swagger-ui-plugin-saml-auth": "*",
"@dsaid/swagger-ui-custom-layout": "*",
"@dsaid/chain-wrap-components": "*",
"@authenio/samlify-node-xmllint": "^2.0.0",
"@types/jsonwebtoken": "^9.0.1",
"@types/node": "18.15.11",
Expand Down
34 changes: 1 addition & 33 deletions apps/web/src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dynamic from 'next/dynamic'
import otpJwtAuthPlugin from '@dsaid/swagger-ui-plugin-otp-auth'
import productLayoutPlugin from '@dsaid/swagger-ui-custom-layout'
import samlAuthPlugin from '@dsaid/swagger-ui-plugin-saml-auth'
import deepMerge from 'deepmerge'
import chainWrapComponents from '@dsaid/chain-wrap-components'

// swagger-ui-react is not SSR compatible
const SwaggerUI = dynamic(import('swagger-ui-react'), { ssr: false })
Expand All @@ -25,35 +25,3 @@ export default function Home() {
</>
)
}

export const chainWrapComponents = (first, ...plugins) => (system) =>
plugins.reduce((ori, plugin) => {
const { wrapComponents, ...pluginConfig } = plugin(system)
const { wrapComponents: oriWrapComponents, ...oriPluginConfig } = ori

return {

wrapComponents: Object.entries(wrapComponents).reduce((merged, [key, wrapComponent]) => {
const chained = oriWrapComponents?.[key] ?
(ori, sys) => function Chained(props) {

const First = wrapComponent(ori, sys)
const Second = oriWrapComponents?.[key](ori, sys)

return <>
{First && <First {...props} />}
{Second && <Second {...props} />}
</>
} : wrapComponent

return {
...merged,
[key]: chained
}
}, oriWrapComponents || {}),


...deepMerge(oriPluginConfig, pluginConfig)
}
}, first(system))

2 changes: 2 additions & 0 deletions package-lock.json

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

0 comments on commit 2443262

Please sign in to comment.