SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.19k stars 661 forks source link

Making adminjs work on Deno #1632

Closed brickpop closed 7 months ago

brickpop commented 7 months ago

Thank you for such an amazing piece of software.

This PR fixes two small issues that prevent AdminJS from working on Deno.

The problem:

AdminJS assumes that the environment is either a browser or NodeJS, only.

user@host ~/d/b/adminjs-deno (main)> deno task dev                                          (base) 
Task dev deno run --watch -A src/app.ts
Watcher Process started.
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'isOnServer')
    at Function.getBaseUrl (file:///Users/user/dev/brickpop/adminjs-deno/node_modules/.deno/adminjs@7.6.0/node_modules/adminjs/lib/frontend/utils/api-client.js:104:19)
    at new ApiClient (file:///Users/user/dev/brickpop/adminjs-deno/node_modules/.deno/adminjs@7.6.0/node_modules/adminjs/lib/frontend/utils/api-client.js:98:30)
    at file:///Users/user/dev/brickpop/adminjs-deno/node_modules/.deno/adminjs@7.6.0/node_modules/adminjs/lib/frontend/hooks/use-record/use-record.js:11:13

The solution

Adding a check to ensure that globalAny is treated as in a server.

Working example

AdminJS app running on Deno: https://github.com/brickpop/adminjs-deno

You need to run the deno task setup to apply the workaround that fixes the issue. See scripts/setup.ts

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 7.7.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: