-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move JWT options into config Move cookie options into config
- Loading branch information
Showing
5 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { JwtModuleOptions } from '@nestjs/jwt'; | ||
import type { CookieOptions } from 'express'; | ||
import invariant from 'tiny-invariant'; | ||
|
||
export type AuthConfig = ReturnType<typeof auth>; | ||
|
||
export function auth() { | ||
invariant(process.env.SECRET, 'SECRET is missing'); | ||
|
||
return { | ||
jwt: { | ||
secret: process.env.SECRET, | ||
signOptions: { | ||
expiresIn: '30d', | ||
}, | ||
} as JwtModuleOptions, | ||
cookie: { | ||
httpOnly: true, | ||
sameSite: 'strict', | ||
signed: true, | ||
secure: process.env.NODE_ENV === 'production', | ||
} as CookieOptions, | ||
}; | ||
} |
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
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
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