Skip to content

Commit

Permalink
Merge pull request #1032 from garageScript/next-eslint
Browse files Browse the repository at this point in the history
version bumps, added nextjs eslint plugin
  • Loading branch information
ggwadera authored Aug 14, 2021
2 parents f1d7996 + 07616d6 commit 86ab199
Show file tree
Hide file tree
Showing 4 changed files with 582 additions and 395 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@next/next/recommended",
"plugin:prettier/recommended",
"prettier"
],
Expand Down
47 changes: 23 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@apollo/client": "^3.3.19",
"@prisma/client": "^2.28.0",
"@prisma/client": "^2.29.1",
"@quixo3/prisma-session-store": "^3.0.1",
"@sentry/nextjs": "^6.10.0",
"apollo-server-micro": "^2.25.2",
Expand All @@ -49,11 +49,11 @@
"graphql-request": "^3.4.0",
"lodash": "^4.17.20",
"markdown-to-jsx": "^7.1.3",
"nanoid": "^3.1.23",
"nanoid": "^3.1.25",
"next": "^11.1.0",
"next-connect": "^0.10.0",
"next-connect": "^0.10.2",
"nodemailer": "^6.6.3",
"posthog-js": "^1.11.4",
"posthog-js": "^1.12.3",
"prism-react-renderer": "^1.2.1",
"prismjs": "^1.24.1",
"react": "^17.0.2",
Expand All @@ -73,35 +73,34 @@
"@jest/types": "^27.0.2",
"@mdx-js/loader": "^1.6.22",
"@mdx-js/react": "^1.6.22",
"@next/mdx": "^11.0.1",
"@storybook/addon-actions": "^6.3.6",
"@storybook/addon-essentials": "^6.3.6",
"@storybook/addon-storyshots": "^6.3.6",
"@storybook/addon-storysource": "^6.3.6",
"@storybook/addon-viewport": "^6.3.6",
"@storybook/react": "^6.3.6",
"@next/eslint-plugin-next": "^11.1.0",
"@next/mdx": "^11.1.0",
"@storybook/addon-actions": "^6.3.7",
"@storybook/addon-essentials": "^6.3.7",
"@storybook/addon-storyshots": "^6.3.7",
"@storybook/addon-storysource": "^6.3.7",
"@storybook/addon-viewport": "^6.3.7",
"@storybook/react": "^6.3.7",
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^12.7.0",
"@types/bcrypt": "^5.0.0",
"@types/express-session": "^1.17.4",
"@types/lodash": "^4.14.171",
"@types/lodash": "^4.14.172",
"@types/mdx-js__react": "^1.5.4",
"@types/node": "^16.4.1",
"@types/node-fetch": "^2.5.10",
"@types/node": "^16.6.1",
"@types/nodemailer": "^6.4.4",
"@types/prismjs": "^1.16.6",
"@types/react": "^17.0.15",
"@types/react": "^17.0.17",
"@types/react-dom": "^17.0.9",
"@types/styled-jsx": "^2.2.8",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"babel-jest": "^27.0.6",
"babel-plugin-prismjs": "^2.1.0",
"eslint": "^7.32.0",
"eslint-config-next": "^11.0.1",
"eslint-config-next": "^11.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-mdx": "^1.13.0",
"eslint-plugin-mdx": "^1.14.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"husky": "^7.0.1",
Expand All @@ -110,14 +109,14 @@
"jest-mock-extended": "^1.0.18",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"prisma": "^2.28.0",
"prisma": "^2.29.1",
"react-test-renderer": "^17.0.1",
"remark-gfm": "^1.0.0",
"remark-slug": "^6.1.0",
"remark-toc": "^7.2.0",
"sass-loader": "^10.0.1",
"svgo": "^2.3.1",
"ts-node": "^10.1.0",
"typescript": "^4.3.4"
"svgo": "^2.4.0",
"ts-node": "^10.2.0",
"typescript": "^4.3.5"
}
}
42 changes: 21 additions & 21 deletions pages/api/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { PrismaSessionStore } from '@quixo3/prisma-session-store'
import { withSentry } from '@sentry/nextjs'
import { ApolloServer } from 'apollo-server-micro'
import session from 'express-session'
import nextConnect from 'next-connect'
import userMiddleware from '../../helpers/middleware/user'
import loggingMiddleware from '../../helpers/middleware/logger'
import typeDefs from '../../graphql/typeDefs'
import resolvers from '../../graphql/resolvers'
import { PrismaSessionStore } from '@quixo3/prisma-session-store'
import prisma from '../../prisma'
import typeDefs from '../../graphql/typeDefs'
import { apolloLogPlugin } from '../../helpers/apolloLogPlugin'
import loggingMiddleware from '../../helpers/middleware/logger'
import userMiddleware from '../../helpers/middleware/user'
import prisma from '../../prisma'

const ONE_DAY = 1000 * 60 * 60 * 24
const ONE_WEEK = ONE_DAY * 7

const handler: any = nextConnect() // For session middleware. TODO: Need to define types for Session
const handler = nextConnect()
const apolloServer = new ApolloServer({
typeDefs,
resolvers,
Expand All @@ -26,23 +26,23 @@ const apolloServer = new ApolloServer({

const graphQLHandler = apolloServer.createHandler({ path: '/api/graphql' })

const sessionMiddleware = session({
secret: process.env.SESSION_SECRET as string,
store: new PrismaSessionStore(prisma, {
dbRecordIdIsSessionId: true,
dbRecordIdFunction: undefined,
checkPeriod: ONE_DAY
}),
resave: false,
saveUninitialized: false,
cookie: {
maxAge: ONE_WEEK
}
})

handler
.use(loggingMiddleware)
.use(
session({
secret: process.env.SESSION_SECRET as string,
store: new PrismaSessionStore(prisma, {
dbRecordIdIsSessionId: true,
dbRecordIdFunction: undefined,
checkPeriod: ONE_DAY
}),
resave: false,
saveUninitialized: false,
cookie: {
maxAge: ONE_WEEK
}
})
)
.use(sessionMiddleware)
.use(userMiddleware)
.get('/api/graphql', graphQLHandler)
.post('/api/graphql', graphQLHandler)
Expand Down
Loading

1 comment on commit 86ab199

@vercel
Copy link

@vercel vercel bot commented on 86ab199 Aug 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.