sudo n 10.15.3
git clone [email protected]:kauri-io/kauri-serverless-migration.git
cd app && yarn
yarn global add now
now login; Ask Davide for rest of this 0_o
now dev; open localhost:3000
Extra
- Redux devtools browser extension
- Apollo browser extension
Parental root is only for accessing deploy commands like yarn deploy-dev or yarn deploy-prod
app/*.* = Config files
config/ = development vs production, please also create other configuration files e.g. uppy which is our image plugin
queries/ = Graphql queries + mutations + __generated__ TS interfaces
pages/ = Top level file system api routes, please use with now.json for nested routes + params (Davide is better at explaining this than I am)
-
_app.tsx = Async raw JS scripts here like Mailchimp, think of this as a page route component wrapper
-
_document.tsx = HTML Document structure, this is the entry point for getInitialProps()
Usually actually only used for CSS SSR
-
_error.tsx
Err this is supposed to be the 404 which needs to be enabled for Zeit Now lol
scripts = Node.js scripts like introspection of the GQL API
types = Global typescript module declarations that do not have third party ones
layouts = One level down from _document, essentially the Application semantic structure - Navbar, Content, Footer
containers/ vs components/
- Application + Stateful components === Containers e.g. Forms, Terms of use, Discover
Folder structure is MVC style :- index.tsx View.tsx Module.ts
View is also split. Actions, Header, Content etc.
-
Everything else stateless and context resusable === components e.g. Cards, Buttons
Very philosophical
SSR = Serverside rendered
Actually a headache
tl;dr - Context request comes in, node.js creates an html string, responds with that html
Browser runs JS bundle on top of that html response and React finds no diff = Fast initial render + SEO + Universal/Reusable server and client code
Add in CSS-in-JS to the mix
Next.js is a complete React framework that is less config heavy to handle SSR, async page bundles, non-js file handling, routing + also has Zeit hosting integrated with it because they created it
1 - Raw request accessible via lib/with-data, this is the page wrapper 2 - Reads cookies, fetches user details, sets redux data store + apollo client + backend page data for that page and passes that to the page component, aggregates all css thus exploding the universe
Essentially _app.tsx, _document.tsx and lib/with-data.tsx all work in unison
Prior used styled-components, now converting to material-ui
There's a theme object tied to the constraints of our design system context injected at the top level provided in with-data.
Only difference now is string interpolation => object style
const classes = theme => createStyle(componentStyleObject)
<Button className={classes.button}>
tl;dr Ask Davide
Redux Observable middleware by Netflix essentially is RxJS Operators + Redux
tl;dr - Each epic middleware allows dependency injection, event dispatching and side effect management.
(Redux = global state store + Pure functional event dispatcher lib)
lib/root.ts - Array of business logic "epics"
containers/Community/Module.tsx
- Notice the colocated *Epic.test.tsx files
- Each Module file per container contains all the redux specific stuff - actions, epics, reducers
interface IAction {
type: 'EVENT_NAME'
payload: IMPORTED_GENERATED_MUTATION_INTERFACE
}
Action functions are imported into the index.ts files of the containers to bind the redux dispatch instance to them accessible via this.props.ACTION_NAME in View.tsx
(Handful sorry but this is standard in frontend, ask Kendall lol :( )
tl;dr - Epics are obsercables that listen to the redux store for dispatched events, activate if match, do web3 personal sign, apollo client graphql mutations, clear apollo store cache and dispatch more actions like showNotificationAction()
Folder is separated by resource and reusable fragments and are scanned via the yarn gqt
command to introspect against the backend to generate TS interfaces.
We now have a graphiql playground for documentation + REPL, consult Greg for this :))
Unit test = Mocked Components snapshots + Enzyme
Epic unit tests
Refer to now.json and top level files
Apparently nested file system api does not work in production due to Zeit Now
{
monolithApi: 'api.dev.kauri.io',
monolithExternalApi: 'api.dev.kauri.io',
gateway: 'api.dev.kauri.io',
gethBlockchain: '35.231.60.112:8545',
KauriCommunityId: '5d2c6edefe402500014349f5',
uppyConfig,
analyticsTokens: {
mixpanel: '627c5ccb5bf7da1d079aef2efaa807c2',
ga: 'UA-112179323-4',
},
testingAccounts: [],
environment: 'development',
appId: 'kauri',
clientId: 'kauri-gateway',
}
TOKEN - JWT
USER_ID - Web3 userId
Currently uses Showdown for MD parsing, could convert to remark
Could use prism for code highlighting
Uses Formik for sections as arrays + React DnD for card DOM interactions
Currently uses forked react-markdown editor with plugins + buttons
Could be replaced with slate or quill
Currently uses AntD built in one, to be removed
Davide probs wants to remove Formik at some point :))
Currently the withFormik({}) HoC is used in index.ts files and generated interface form state is from backend mutations per resource
Uppy, Editor ones