This file contains 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
{ | |
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Typescript React PureComponent": { | |
"prefix": "rpc", | |
"body": [ | |
"import * as React from 'react'", |
This file contains 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
{ | |
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Type GraphQL Resolver": { | |
"prefix": "resolver", | |
"body": [ | |
"import { Resolver } from \"type-graphql\";", |
This file contains 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
{ | |
"vim.insertModeKeyBindings": [ | |
{ | |
"before": [ | |
"j", | |
"k" | |
], | |
"after": [ | |
"<esc>" | |
] |
This file contains 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 { MiddlewareFn } from "type-graphql"; | |
import { redis } from "./redis"; | |
import { MyContext } from "./types/MyContext"; | |
const ONE_DAY = 60 * 60 * 24; | |
export const rateLimit: (limit?: number) => MiddlewareFn<MyContext> = ( | |
limitForAnonUser = 50, | |
limitForUser = 100 | |
) => async ({ context: { req }, info }, next) => { |
This file contains 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 { produce } from "immer"; | |
import { ApolloCache } from "@apollo/client"; | |
export const updateQuery = ( | |
store, | |
query, | |
fn, | |
variables | |
) => { | |
let data; |
This file contains 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 fs from "fs"; | |
import MDX from "@mdx-js/runtime"; | |
import ReactDOM from "react-dom/server"; | |
import path from "path"; | |
const Post = ({ post }) => { | |
return <div dangerouslySetInnerHTML={{ __html: post }} />; | |
}; | |
export async function getStaticPaths() { |
This file contains 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
module.exports = { | |
parser: "@typescript-eslint/parser", // Specifies the ESLint parser | |
extends: [ | |
"plugin:@typescript-eslint/recommended" // Uses the recommended rules from the @typescript-eslint/eslint-plugin | |
], | |
parserOptions: { | |
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features | |
sourceType: "module" // Allows for the use of imports | |
}, | |
rules: { |
This file contains 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
@UseMiddleware(hasRole("admin")) | |
@Query(() => String) | |
async hello() { | |
return "Hello World!"; | |
} |
This file contains 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
const { GraphQLServer } = require("graphql-yoga"); | |
const session = require("express-session"); | |
const { Prisma } = require("prisma-binding"); | |
const resolvers = require("./resolvers"); | |
const db = new Prisma({ | |
typeDefs: "src/generated/prisma.graphql", // the auto-generated GraphQL schema of the Prisma API | |
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`) | |
debug: true // log all GraphQL queries & mutations sent to the Prisma API | |
// secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`) |
This file contains 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 { MiddlewareFn } from "type-graphql"; | |
import { redis } from "./redis"; | |
import { MyContext } from "./types/MyContext"; | |
const ONE_DAY = 60 * 60 * 24; | |
export const rateLimit: (limit?: number) => MiddlewareFn<MyContext> = ( | |
limit = 50 | |
) => async ({ context: { req }, info }, next) => { | |
const key = `rate-limit:${info.fieldName}:${req.ip}`; |