This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ApiProperty } from '@nestjs/swagger'; | |
| import { IsEnum, IsOptional } from 'class-validator'; | |
| import { Prisma } from '@prisma/client'; | |
| const orderByKeys = [ | |
| 'id', | |
| 'title', | |
| 'content', | |
| 'createdAt', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { cleanEnv, url } from "envalid"; | |
| // We have to do this because of how Next.JS handles process.env | |
| const processEnv = { | |
| NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, | |
| }; | |
| const env = cleanEnv(processEnv, { | |
| NEXT_PUBLIC_API_URL: url(), | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| If you have a React component with compount components e.g. List, List.Item using HOC will remove compound components. | |
| For the HOC to inherit compound components you need to do it manually. | |
| Use a library like: https://www.npmjs.com/package/hoist-non-react-statics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This problem occurs when using reactjs-social-login with a SSR metaframework. | |
| // The solution below is for Next.JS. Your framework may do dynamic imports differently. | |
| const LoginSocialInstagram = dynamic( | |
| () => import('reactjs-social-login').then((lib) => lib.LoginSocialInstagram), | |
| { ssr: false } | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This is the solution to the following error: | |
| Property 'em-emoji' does not exist on type 'JSX.IntrinsicElements'.ts(2339) | |
| */ | |
| // Define em-emoji web component inside React | |
| // https://github.com/missive/emoji-mart#-emoji-component | |
| interface EmEmojiProps { | |
| id?: string | |
| shortcodes?: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://ihateregex.io/expr/emoji/ | |
| export const emojiRegExpString = | |
| '(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])' | |
| export const emojiToUnified = (emoji: string) => | |
| [...emoji].map((e) => e.codePointAt(0)?.toString(16)).join('-') | |
| export const unifiedRegExpString = '\b([da-fA-F]{4,5}|[da-fA-F]{6}|[da-fA-F]{8})\b' | |
| export const unifiedToEmoji = (unified: string) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In the .eslintrc file add the following: | |
| extends: ['prettier'] and plugins: ['prettier'] | |
| rules: {'prettier/prettier': ['error', {endOfLine: 'auto'}]} | |
| In .prettierrc remove this: | |
| endOfLine: 'auto' | |
| It works for me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export type InspectRulesArgs<T extends (...args: any) => any> = | |
| | T[] | |
| | [T, ...Parameters<T>][]; | |
| export type InspectRulesResult = "pending" | "approved" | "denied"; | |
| declare const brand: unique symbol; | |
| type Branded<T, Brand extends string> = T & { | |
| [brand]: Brand; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { ReactNode } from 'react' | |
| // Next | |
| import Link from 'next/link' | |
| import { useRouter } from 'next/router' | |
| const SomeComponent = () => { | |
| const router = useRouter(); | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PROBLEM: nodemon does not working inside docker container | |
| sample errors: | |
| [name] exited with code 243 | |
| [name] exited with code 127 | |
| e.g. | |
| SOLUTION: | |
| install nodemon globally inside the container and do not run it with npx but directly |