Skip to content

Instantly share code, notes, and snippets.

View saas-work.md

09.04.2021 — 8h

  • Setup blitz project
  • Add Github and Gmail auth
  • Send emails with link to reset password
  • Create an email template
  • Setup CI for tests and builds
  • Send confirmation email after creating an account with login and password
  • Handle account confirmation on the frontend
  • Update DB models to contain info about origin and confirmed account
View fk.sql
SELECT
fk.name AS constraint_name,
sch1.name AS [table_schema],
tab1.name AS [table_name],
sch2.name AS [ref_table_schema],
tab2.name AS [ref_table],
(
SELECT
col1.name AS [column],
col2.name AS [referenced_column]
View codegen.js
module.exports = {
"schema": [
{
"https://<YOUR_GRAPHQL_SERVICE>/graphql": {
"headers": {}
}
}
],
"documents": [
"./src/**/*.tsx",
View io-ts-validation.ts
import { NowResponse } from '@now/node';
import { fold } from 'fp-ts/lib/Either';
import * as t from 'io-ts';
import { reporter } from 'io-ts-reporters';
type GetRequestValidator<
QueryValidator extends t.Any,
ParamsValidator extends t.Any
> = t.TypeC<{
query: QueryValidator;
View useTouch.ts
import * as React from 'react';
import { useState } from 'react';
export const useTouch = (ref: React.RefObject<HTMLElement>, defaultState = false) => {
const [state, setState] = useState(false);
React.useEffect(() => {
const element = ref.current;
if (!element) {
return;
View consList.ts
export type ConsList<T> = null | readonly [T, ConsList<T>];
function cons<T>(h: T, t: ConsList<T>): ConsList<T> {
return [h, t];
}
function head<T>(xs: ConsList<T>): T {
if (!xs) {
throw new Error("can't take head of empty ConsList");
}
View resize.tsx
export const Component: React.FunctionComponent<Props> = ({ text }) => {
const container = React.useRef() as React.MutableRefObject<HTMLDivElement>;
const [textContainerWidth, setTextContainerWidth] = React.useState(0);
React.useLayoutEffect(() => {
handleTextContainerWidth();
}, []);
React.useEffect(() => {
window.addEventListener('resize' handleTextContainerWidth);
View typedExpressResponse.ts
export type ApiError = {
error: string;
error_details?: string;
};
export interface TypedResponse<T = ApiError> extends Response {
status: (status: number) => TypedResponse<T | ApiError>;
send: (body: T | ApiError) => TypedResponse<T | ApiError>;
}