Skip to content

Instantly share code, notes, and snippets.

View RafalFilipek's full-sized avatar
😱

Rafau RafalFilipek

😱
View GitHub Profile
@RafalFilipek
RafalFilipek / [...nextauth].ts
Last active September 27, 2022 18:05
Hasura + next-auth
import NextAuth, { type NextAuthOptions } from "next-auth";
import { JWT } from "next-auth/jwt";
import * as jwt from "jose";
export const authOptions: NextAuthOptions = {
// the rest is just like in tutorials. Session, callbacks etc.
jwt: {
encode: async ({ secret, token }) => {
if (!token) {
console.warn("encode: No token provided");
Machine({
id: 'foo',
initial: "load",
states: {
load: {
invoke: {
src: () => Promise.resolve(Math.random()),
onDone: [{
target: 'ok',
cond: (_, e) => e.data > 0.5
@RafalFilipek
RafalFilipek / machine.js
Created February 6, 2021 20:34
Generated by XState Viz: https://xstate.js.org/viz
const button = Machine({
id: "button",
type: "parallel",
states: {
size: {
initial: "small",
states: {
small: {},
big: {},
},
/**
* wybierz = actions.choose([{
cond: 'isPhone',
target: 'phone'
},{
cond: 'isPesel',
target: 'pesel'
}, {
cond: 'isEmail',
target: 'email'
const Options = {
actions: {
setErrorInfo: "setErrorInfo",
setInitializingData: "setInitializingData",
setOfferTypeGroup: "setOfferTypeGroup",
setOfferType: "setOfferType",
setProcedure: "setProcedure",
setOffer: "setOffer",
setShouldAddAnotherDevice: "setShouldAddAnotherDevice",
setSelectedProcesableContract: "setSelectedProcesableContract",
@RafalFilipek
RafalFilipek / machine.js
Last active June 2, 2020 11:01
Generated by XState Viz: https://xstate.js.org/viz
const Options = {
actions: {
setContent: "setContent",
setGroups: "setGroups",
setSelectedType: "setSelectedType",
setOnlyType: "setOnlyType",
setSelectedUpsellOffer: "setSelectedUpsellOffer"
},
services: {
loadData: "loadData",
const m = Machine({
initial: 'wejscie',
states: {
'wejscie': {
on: {
'': [
{ target: 'sprawdzenie', cond: 'jest na sg b2b albo b2c' },
{ target: 'koniec' }
@RafalFilipek
RafalFilipek / SketchSystems.spec
Created May 22, 2020 11:08
Otworzenie portalu*
Otworzenie portalu*
Jest to strona SG B2C lub B2B?
Tak -> Sprawdzenie ciastka
Nie -> Koniec
Sprawdzenie ciastka
Uzytkownik jest w wersji A -> Wyślij B2B_rozbiegowka_test_A
Użytkownik jest w wersji B -> Eventy dla wersji B
const m = Machine({
"id": "root",
"states": {
"Otworzenie portalu": {
"id": "Otworzenie portalu",
"states": {
"Jest to strona SG B2C lub B2B?": {
"id": "Jest to strona SG B2C lub B2B?",
"states": {},
"on": {
const stepTransitions = Machine({
initial: "idle",
states: {
idle: {
id: "idle",
on: {
START: { target: "inProgress" },
},
},
inProgress: {