Skip to content

Instantly share code, notes, and snippets.

View mistical2008's full-sized avatar

Evgeniy Talko mistical2008

  • Russia
View GitHub Profile
import crypto from "crypto";
import { renderToStaticMarkup } from "react-dom/server";
import createMailgun from "mailgun-js";
import type { ActionFunction, LoaderFunction, Session } from "remix";
import { createCookieSessionStorage, json, redirect } from "remix";
/*******************************************************************************
* Before we can do anything, we need to make sure the environment has
* everything we need. If anything is missing, we just prevent the app from
* starting up.
import type {
ActionFunction,
LinksFunction,
LoaderFunction,
MetaFunction
} from "@remix-run/react";
import {
Meta,
Links,
Scripts,
const path = require("path");
const express = require("express");
const compression = require("compression");
const morgan = require("morgan");
const { createRequestHandler } = require("@remix-run/express");
////////////////////////////////////////////////////////////////////////////////
let app = express();
app.use(compression());
enum State {
Idle,
LoadingJwt,
Success,
Error,
}
type Data = { error?: string; jwt?: string };
function Comp() {
import React from "react";
import { IconCopy } from "./icons";
export default function CopyButton({ value }) {
let [copied, setCopied] = React.useState(false);
React.useEffect(() => {
if (copied) {
let id = setTimeout(() => {
setCopied(false);
@mistical2008
mistical2008 / entry-server.tsx
Created December 8, 2021 20:29 — forked from ryanflorence/entry-server.tsx
Remix + Styled Components
import ReactDOMServer from "react-dom/server";
import type { EntryContext } from "@remix-run/core";
import Remix from "@remix-run/react/server";
import { renderToString } from "react-dom/server";
import { ServerStyleSheet } from "styled-components";
import StylesContext from "./stylesContext";
export default function handleRequest(
request: Request,
import type { Action, Loader } from "@remix-run/loader";
import { json, parseFormBody, redirect } from "@remix-run/loader";
import { readTodos, createTodo, deleteTodo } from "../data/todo";
let action: Action = async ({ request, context: { session } }) => {
let [method, body] = await methodOverride(request);
await new Promise((res) => setTimeout(res, 1000));
switch (method) {
case "post": {
let [_, error] = await createTodo(body!.name);
import React from "react";
import { Meta, Scripts, Styles, Routes } from "@remix-run/react";
import { useLocation } from "react-router-dom";
let noScriptPaths = new Set(["/", "/buy", "/logout", "/features", "/privacy"]);
export default function App() {
let location = useLocation()
let includeScripts = !noScriptPaths.has(location.pathname);
let { lang }= useLocalization()
import React from "react";
import { renderToNodeStream } from "react-dom/server";
import Remix, { loadRouteData } from "remix/RemixNode";
// same App as entry-web!
import App from "./App";
export default async (req, res, assets, matches) => {
// @remix-run/firebase is calling this function and passing
// the arguments in, @remix-run/aws or @remix-run/azure will
// pass in whatever APIs those platforms use
// you have total control over the server rendering, here we
import { Machine, assign } from "xstate";
import firebase from "./firebase";
const chart = {
id: "auth",
context: {
auth: null,
error: null,
loggedoutTime: null
},