Skip to content

Commit

Permalink
chore(ts): remove @types/next-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Apr 21, 2021
1 parent 86fa2f4 commit 798d8a9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions config.server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Providers from "next-auth/providers";
import Providers, { AppProviders } from "next-auth/providers";
import { prisma, resolvedConfig } from "./utils.server";

/**
* Auth Providers
* https://next-auth.js.org/configuration/providers
*/

const providers = [];
const providers: AppProviders = [];

if (resolvedConfig.useLocalAuth) {
providers.push(
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"markdown-it": "^12.0.6",
"milligram": "^1.4.1",
"next": "^10.0.5",
"next-auth": "3.14.7",
"next-auth": "3.15.5",
"postcss": "^8.2.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
Expand All @@ -53,7 +53,6 @@
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-decorators": "^7.12.12",
"@types/next-auth": "^3.13.0",
"@types/node": "^14.14.21",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
Expand Down
31 changes: 23 additions & 8 deletions pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import Adapters from "next-auth/adapters";
import { prisma, resolvedConfig, singletonSync } from "../../../utils.server";
import { authProviders } from "../../../config.server";

const options = {
// Using Module Augmentation
// https://next-auth.js.org/getting-started/typescript

declare module "next-auth" {
interface Session {
uid: string
}
interface User {
id: string
}
}

declare module "next-auth/jwt" {
interface JWT {
id: string
}
}

export default NextAuth({
// Configure one or more authentication providers
providers: authProviders,

Expand All @@ -19,17 +36,15 @@ const options = {
},

callbacks: {
session: async (session, user) => {
session(session, user) {
session.uid = user.id;
return Promise.resolve(session);
return session;
},
jwt: async (token, user, account, profile) => {
jwt(token, user) {
if (user) {
token.id = user.id;
}
return token;
},
},
};

export default (req, res) => NextAuth(req, res, options);
});
22 changes: 6 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1237,16 +1237,6 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA==

"@types/next-auth@^3.13.0":
version "3.13.0"
resolved "https://registry.yarnpkg.com/@types/next-auth/-/next-auth-3.13.0.tgz#c933bcc4259262959544df24bbc8528e3548fa26"
integrity sha512-zkEVDyoKgRsHm3KUaZoOGSThTS9h0+HbFZctiYbB5MMU6/pUZuF5ozWrVG00jotQJuSEIlPWzdCIXKlaHctJgw==
dependencies:
"@types/node" "*"
"@types/react" "*"
jose "^1.28.0"
typeorm "^0.2.31"

"@types/node@*", "@types/node@^14.14.21":
version "14.14.41"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.41.tgz#d0b939d94c1d7bd53d04824af45f1139b8c45615"
Expand Down Expand Up @@ -3542,7 +3532,7 @@ joi@^13.1.2:
isemail "3.x.x"
topo "3.x.x"

jose@^1.27.2, jose@^1.28.0:
jose@^1.27.2:
version "1.28.1"
resolved "https://registry.yarnpkg.com/jose/-/jose-1.28.1.tgz#34a0f851a534be59ffab82a6e8845f6874e8c128"
integrity sha512-6JK28rFu5ENp/yxMwM+iN7YeaInnY9B9Bggjkz5fuwLiJhbVrl2O4SJr65bdNBPl9y27fdC3Mymh+FVCvozLIg==
Expand Down Expand Up @@ -4053,10 +4043,10 @@ new-github-issue-url@^0.2.1:
resolved "https://registry.yarnpkg.com/new-github-issue-url/-/new-github-issue-url-0.2.1.tgz#e17be1f665a92de465926603e44b9f8685630c1d"
integrity sha512-md4cGoxuT4T4d/HDOXbrUHkTKrp/vp+m3aOA7XXVYwNsUNMK49g3SQicTSeV5GIz/5QVGAeYRAOlyp9OvlgsYA==

next-auth@3.14.7:
version "3.14.7"
resolved "https://registry.yarnpkg.com/next-auth/-/next-auth-3.14.7.tgz#3718fc5265851fbf52838fb3165a7a2a58b59d06"
integrity sha512-Z3kGvmdpr3uaSMyijRytHYpUajPAhpLJjlze99awmXD20pEV7yrtrQmrsgEnhUpASaVQYranexR3k6i+V0SZ6g==
next-auth@3.15.5:
version "3.15.5"
resolved "https://registry.yarnpkg.com/next-auth/-/next-auth-3.15.5.tgz#e129bc04c7a31417877647cb9712f906ce69b7dd"
integrity sha512-oi95on/QwynQOfNu+9XDAohdt5hTF1F44qUfRFeX5PWghlU8CIcV5smmVV6VjejEFL5Knddqkyv9uMzYuLR70A==
dependencies:
crypto-js "^4.0.0"
futoin-hkdf "^1.3.2"
Expand Down Expand Up @@ -5911,7 +5901,7 @@ typegraphql-prisma@^0.9.4:
ts-morph "^9.1.0"
tslib "^2.1.0"

typeorm@^0.2.30, typeorm@^0.2.31:
typeorm@^0.2.30:
version "0.2.32"
resolved "https://registry.yarnpkg.com/typeorm/-/typeorm-0.2.32.tgz#544dbfdfe0cd0887548d9bcbd28527ea4f4b3c9b"
integrity sha512-LOBZKZ9As3f8KRMPCUT2H0JZbZfWfkcUnO3w/1BFAbL/X9+cADTF6bczDGGaKVENJ3P8SaKheKmBgpt5h1x+EQ==
Expand Down

0 comments on commit 798d8a9

Please sign in to comment.