- When Gatsby starts up, it will read
gatsby-config.jsfirst. - As you can see below, we use that file to
require('ts-node').register()which registers a TypeScript evaluator that will be used when Gatsby reads all other API Javascript files. In other words, we only need to do this once in our entire codebase and not in other Gatsby files likegatsby-node.js. - Our
gatsby-config.jsre-exports all the exported variables available ingatsby-config.ts.
| /* Ultra lightweight Github REST Client */ | |
| // original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
| const token = 'github-token-here' | |
| const githubClient = generateAPI('https://api.github.com', { | |
| headers: { | |
| 'User-Agent': 'xyz', | |
| 'Authorization': `bearer ${token}` | |
| } | |
| }) |
| # KEYCLOAK BASE URL | |
| KEYCLOAK_BASE_URL= | |
| # KEYCLOAK CLIENT SECRET | |
| KEYCLOAK_CLIENT_SECRET= | |
| # KEYCLOAK CLIENT ID | |
| KEYCLOAK_CLIENT_ID= | |
| # BASE URL FOR NEXT AUTH |
| import * as React from "react"; | |
| import styled from "styled-components"; | |
| import lottie from "lottie-web"; | |
| import { up } from "styled-breakpoints"; | |
| import { isServer } from "client/consts/env"; | |
| const Container = styled.div` | |
| width: 100vw; | |
| height: 100vh; |
Ps: The current setup was done on 01-04-19
Project Dependency Versions at the time 👇
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.3",
"typescript": "^3.2.2"
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",Charts are from different sources and thus colors are inconsistent, please carefully read the chart's legends.
Similar analysis:
- React Native vs Flutter: https://gist.github.com/tkrotoff/93f5278a4e8df7e5f6928eff98684979
- ESLint vs Oxlint: https://gist.github.com/tkrotoff/8e10c7d63f97b3480a98301af9e8a28e
After all those years maintaining this data (since 2018): React is still much more popular and continue to grow faster than alternatives; Vue dates back from 2014 and Svelte from 2016, they should have overthrown React by now.
| import { formatDefaultLocale } from 'd3-format'; | |
| const germanNumberFormat = formatDefaultLocale({ | |
| decimal: ',', | |
| thousands: '.', | |
| grouping: [3], | |
| currency: ['€', ''] | |
| }); | |
| export function numberFormat(num, decimals = 0) { |
| import { resolve } from 'path' | |
| import { GatsbyCreatePages } from './types' | |
| const createPages: GatsbyCreatePages = async ({ | |
| graphql, | |
| boundActionCreators, | |
| }) => { | |
| const { createPage } = boundActionCreators | |
| const allMarkdown = await graphql(` |
| /* | |
| The MIT License | |
| Copyright (c) Jeff Hansen 2018 to present. | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION W |
Last updated: 2021-02-21, tested with socket.io v3.1.1
This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.
To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.
If you're looking for examples using frameworks, check these links: