Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"jose": "^1.27.2",
"jsonwebtoken": "^8.5.1",
"oauth": "^0.9.15",
"optional-require": "^1.0.3",
"pkce-challenge": "^2.1.0",
"preact": "^10.4.1",
"preact-render-to-string": "^5.1.14"
Expand Down
4 changes: 3 additions & 1 deletion src/adapters/typeorm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Models from './models'

import { updateConnectionEntities } from './lib/utils'

import optionalRequire from 'optional-require'

const Adapter = (typeOrmConfig, options = {}) => {
// Ensure typeOrmConfigObject is normalized to an object
const typeOrmConfigObject = (typeof typeOrmConfig === 'string')
Expand Down Expand Up @@ -93,7 +95,7 @@ const Adapter = (typeOrmConfig, options = {}) => {
let ObjectId
if (config.type === 'mongodb') {
idKey = '_id'
const mongodb = (await import('mongodb')).default
const mongodb = optionalRequire('mongodb')
ObjectId = mongodb.ObjectID
}

Expand Down
3 changes: 2 additions & 1 deletion src/providers/email.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logger from '../lib/logger'
import optionalRequire from 'optional-require'

export default (options) => {
return {
Expand Down Expand Up @@ -26,7 +27,7 @@ async function sendVerificationRequest ({ identifier: email, url, baseUrl, provi
// Strip protocol from URL and use domain as site name
const site = baseUrl.replace(/^https?:\/\//, '')
try {
const nodemailer = (await import('nodemailer')).default
const nodemailer = optionalRequire('nodemailer')
await nodemailer
.createTransport(server)
.sendMail({
Expand Down
4 changes: 3 additions & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import csrfTokenHandler from './lib/csrf-token-handler'
import * as pkce from './lib/oauth/pkce-handler'
import * as state from './lib/oauth/state-handler'

import optionalRequire from 'optional-require'

// To work properly in production with OAuth providers the NEXTAUTH_URL
// environment variable must be set.
if (!process.env.NEXTAUTH_URL) {
Expand Down Expand Up @@ -87,7 +89,7 @@ async function NextAuthHandler (req, res, userOptions) {
// If database URI or config object is provided, use it (simple usage)
let adapter = userOptions.adapter
if ((!adapter && !!userOptions.database)) {
const TypeOrm = (await import('../adapters/typeorm')).default
const TypeOrm = optionalRequire('../adapters/typeorm')
adapter = TypeOrm.Adapter(userOptions.database)
}

Expand Down