Skip to content

Instantly share code, notes, and snippets.

View epicbytes's full-sized avatar
🎯
Focusing

Epicbytes epicbytes

🎯
Focusing
View GitHub Profile
@epicbytes
epicbytes / layout-popup.tsx
Created May 27, 2023 21:08
Portals in nextJS
export const LayoutPopup = <T extends unknown>({
library,
}: {
library: Record<keyof T, ComponentType<any>>;
}): JSX.Element => {
const modalRoot = useCreateDomElement();
return (
<>
{modalRoot &&
createPortal(<PopupContainer<T> library={library} />, modalRoot)}
@epicbytes
epicbytes / flow-editor.d.ts
Last active October 22, 2022 05:41
Example how to use reactflow and effector together
import { NodeTypes } from "@reactflow/core/dist/esm/types";
import { Edge, Node } from "reactflow";
export type FlowEditorProps = {
nodeTypes?: NodeTypes;
nodes?: Node[];
edges?: Edge[];
library: FlowEditorLibrary
children?: JSX.Element;
};
@epicbytes
epicbytes / example.api.ts
Last active February 6, 2024 18:28
NextJS Authorization Files
/*** function that used as middleware ***/
accessToken: async (name) => {
if (typeof document === "undefined") return "";
let token = document.cookie
.split(";")
.filter((cookie) => cookie.startsWith("token"))[0];
if (!token) {
const response = await fetch("/api/refresh", { method: "POST" });
import { validate, define } from "superstruct";
export function validatePhoneForE164(phoneNumber: string) {
const regEx = /^\+[1-9]\d{10,14}$/;
return regEx.test("+" + phoneNumber.replace(/\D/g, ""));
}
export const isAccept = define("isAccept", (value, context) => !!value);
export function CustomValidator<T>(
"use strict" нахуй
ясенХуй apisauce внатуре require("apisauce").намутить нахуй
ясенХуй superagent внатуре require("superagent") нахуй
ясенХуй uuid внатуре require("uuid") нахуй
ясенХуй moment внатуре require("moment") нахуй
ясенХуйжЫMoleculerClientError есть внатуре require("moleculer").Errors нахуй
ясенХуй Utils внатуре require("./utils.mixin") нахуй