Skip to content

Commit

Permalink
refactor: use app.usingEdgeJS boolean to register edge plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Nov 25, 2023
1 parent 0ca5d22 commit 55399e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test": "cross-env NODE_DEBUG=adonisjs:session c8 npm run quick:test",
"clean": "del-cli build",
"typecheck": "tsc --noEmit",
"copy:templates": "copyfiles \"stubs/**/*.stub\" build",
"copy:templates": "copyfiles \"stubs/**/*.stub\" --up=\"1\" build",
"precompile": "npm run lint && npm run clean",
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
"postcompile": "npm run copy:templates",
Expand Down Expand Up @@ -77,7 +77,7 @@
"supertest": "^6.3.3",
"ts-node": "^10.9.1",
"tsup": "^8.0.1",
"typescript": "^5.3.2"
"typescript": "5.2.2"
},
"dependencies": {
"@poppinss/utils": "^6.5.1"
Expand Down
12 changes: 3 additions & 9 deletions providers/session_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* file that was distributed with this source code.
*/

import type { Edge } from 'edge.js'
import { configProvider } from '@adonisjs/core'
import { RuntimeException } from '@poppinss/utils'
import type { ApplicationService } from '@adonisjs/core/types'
Expand Down Expand Up @@ -38,15 +37,10 @@ export default class SessionProvider {
* in the user application.
*/
protected async registerEdgePlugin() {
let edge: Edge | null = null
try {
const edgeExports = await import('edge.js')
edge = edgeExports.default
} catch {}

if (edge) {
if (this.app.usingEdgeJS) {
const edge = await import('edge.js')
const { edgePluginSession } = await import('../src/plugins/edge.js')
edge.use(edgePluginSession)
edge.default.use(edgePluginSession)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test.group('Configure', (group) => {
await assert.fileContains('.env', 'SESSION_DRIVER=cookie')
await assert.fileContains(
'start/env.ts',
`SESSION_DRIVER: Env.schema.enum(['cookie', 'redis', 'file', 'memory'] as const)`
`SESSION_DRIVER: Env.schema.enum(['cookie', 'memory'] as const)`
)
}).timeout(60 * 1000)
})

0 comments on commit 55399e0

Please sign in to comment.