Skip to content

Instantly share code, notes, and snippets.

@JeremyTheModernist
JeremyTheModernist / app.js
Created September 14, 2020 18:02
A gist for very basic server side authorization
const express = require('express');
const bodyParser = require('body-parser');
const jwt = require('jsonwebtoken');
const app = express();
app.use(bodyParser.json());
const users = [];
@JeremyTheModernist
JeremyTheModernist / graphql-express.js
Last active August 21, 2020 19:23
Quickly scaffold and express server with graphql
const express = require('express');
const bodyParser = require('body-parser');
const { graphqlHTTP } = require('express-graphql');
// build schema allows you to build your schema as a string literal, processed through
// then build schema converts it into a js object
// then use it in the "schema" property in the express graphql middleware
// alternatively you can create these schemas in object form using graphql's GraphQLObjectType, and types like GraphQLString,
// GraphQL object types act more like components with resolvers included
// helpful article:
// https://dev.to/elisealcala/react-context-with-usereducer-and-typescript-4obm
import React, { createContext, useContext, useReducer } from "react";
type IState = {
count: number;
message?: string;
};
import React, { useState, createContext, useContext } from "react";
import { uuid } from "uuidv4";
var initialState = [
{
id: uuid(),
title: "Intro to HTML",
description: "Learn everything you need to know about html!",
duration: "1hr 5min",
},
@JeremyTheModernist
JeremyTheModernist / store.js
Created June 29, 2020 21:43
Global React state with Reducer
import React, { createContext, useContext, useReducer } from "react";
var StoreContext = createContext();
var initialState = {
count: 0,
};
var reducer = (state, action) => {
switch (action.type) {

Setup Gatsby Layout Component

Gatsby Layout Component is a great way to wrap your site with a consistent header and footer


Install necessary NPM packages

@JeremyTheModernist
JeremyTheModernist / index.js
Last active April 10, 2020 16:06
A gist for Gatsby Recipe Layout Component
import React from 'react'
const Index = (props) => {
return (
<div>
<h1>your nav here</h1>
{props.children}
<h1>your footer here</h1>
</div>
)