question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoResourceAdapterError: There are no adapters supporting one of the resource you provided

See original GitHub issue

Describe the bug when I try to set up AdminBro for Nest.js + typeorm I am getting the next error: UnhandledPromiseRejectionWarning: NoResourceAdapterError: There are no adapters supporting one of the resource you provided.

Installed libraries and their versions “admin-bro”: “^3.3.1”, “admin-bro-expressjs”: “^2.1.1”, “admin-bro-typeorm”: “^0.1.6-alpha.9”, “express”: “^4.17.1”, “express-formidable”: “^1.2.0”, “@nestjs/common”: “7.0.0”, “@nestjs/core”: “7.0.0”, “@nestjs/platform-express”: “7.0.0”, “@nestjs/typeorm”: “7.0.0”,

To Reproduce Steps to reproduce the behavior: Create base nest.js application and put next: main.ts

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await setupAdminPanel(app);
  await app.listen(3000);
}
bootstrap();

token.entity.ts simple implementation

import AdminBro from "admin-bro";
import { Database, Resource } from '@admin-bro/typeorm';
import { validate } from 'class-validator'

AdminBro.registerAdapter({ Database, Resource });
Resource.validate = validate;

@Entity('token')
export class TokenEntity extends BaseEntity {
  @Column({ type: 'varchar' })
  accessToken: string;
}

Expected behavior Start server properly

Screenshots Screenshot 2020-11-06 at 10 43 04

AdminBroOptions with schema

import { INestApplication } from '@nestjs/common';
import AdminBro from 'admin-bro';
import * as AdminBroExpress from 'admin-bro-expressjs';
import { BaseEntity } from '../shared';

export async function setupAdminPanel(app: INestApplication): Promise<void> {
  const adminBro = new AdminBro({
    resources: [{ resource: TokenEntity, options: {} }],
    rootPath: '/admin',
  });

  const router = AdminBroExpress.buildRouter(adminBro);
  app.use(adminBro.options.rootPath, router);

}

Desktop:

  • OS: macOS Catalina v10.15.7

Additional context If I set up empty resources: [], the Server and Admin panel start properly. Also, I tried to set up it by official documentation but I have the same error. Could you please, help me realize what is wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

63reactions
uapashacommented, Dec 11, 2020

@Volodymyr-Zhuravlov @xinhash your Entity should extend BaseEntity.

import {
    BaseEntity,
    Entity
} from 'typeorm';

@Entity()
export class Person extends BaseEntity


Would be good to mention this in the docs… 😃

1reaction
Tushantcommented, Sep 17, 2022
import AdminJS from 'adminjs';
import { AdminModule } from '@adminjs/nestjs';
import { Resource, Database } from '@adminjs/prisma';
import { getDMMF } from '@prisma/internals';

AdminJS.registerAdapter({ Resource, Database });

AdminModule.createAdminAsync({
      imports: [PrismaModule],
      inject: [PrismaService],
      useFactory: async (prisma: PrismaService) => {
        const prismaSchemaPath = path.join('./prisma', 'schema.prisma');
        const file = fs.readFileSync(prismaSchemaPath, 'utf-8');
        const dmmf = getDMMF({ datamodel: file });
        return {
          adminJsOptions: {
            rootPath: '/admin',
            resources: [
              {
                resource: {
                  model: (await dmmf).datamodel.models,
                  client: prisma,
                },
                options: {},
              },
            ],
          },
          auth: {
            authenticate,
            cookieName: 'adminjs',
            cookiePassword: 'secret',
          },
          sessionOptions: {
            resave: true,
            saveUninitialized: true,
            secret: 'secret',
          },
        };
      },
    }),

I am also getting similar issue. I am using prisma 4.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nodejs adminBro mysql There are no adapters supporting one ...
I get plain Admin panel and it works fine, however when i try to fetch db i get: There are no adapters supporting...
Read more >
NoResourceAdapterError: There are no adapters supporting ...
NoResourceAdapterError : There are no adapters supporting one of the resource you provided.
Read more >
[Solved]-How to use @admin-bro/nestjs with ... - appsloveworld
I also got NoResourceAdapterError: There are no adapters supporting one of the resource you provided when I tried to integrate AdminBro with ...
Read more >
Create an Admin Panel With Node.js and AdminBro
Here's how you can build a back-end admin dashboard for your Node app in a few ... you first have to register an...
Read more >
@adminjs/prisma - npm
Prisma adapter for AdminJS. Latest version: 3.0.1, last published: 5 months ago. Start using @adminjs/prisma in your project by running `npm ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found