-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnhandledPromiseRejectionWarning: NoResourceAdapterError: There are no adapters supporting one of the resource you provided #14
Comments
The same thing is happening to me. Were you able to solve this error? |
Getting the same error in my project. Here is the relevant part of my dependencies :
And I'm using Node 14.4.0. |
Hello @Protectator @iamraffe @JamshedLatipov, try to extends the Entity with BaseEntity from typeorm. Work form me. import { Entity, Column, PrimaryGeneratedColumn, BaseEntity } from 'typeorm'; @column() @column() @column({ default: true }) |
My Entity is already extending the BaseEntity class, it doesn't work. |
i think that you have different versions of AdminBro installed in the app. Try to run if that is the case make sure to have the latest one in you package.json. Remove none_modules and install everything again. Let me know if that helped. |
any luck anyone? |
I'm 99.9% I fixed it by extending my entities from BaseEntity. |
+1 I dug a bit deeper and it appears that there is no admin-bro-typeorm/src/Resource.ts Line 287 in 463ea4c
I'm quite lost. Anyone have any ideas why metadata wouldn't be generated on the repositories? Simplified Readme.md exampleimport {
BaseEntity,
Entity, PrimaryGeneratedColumn, Column,
createConnection,
} from "typeorm";
import express from "express";
import { Database, Resource, UseAsTitle, UseForSearch } from "admin-bro-typeorm";
import { validate } from 'class-validator'
import AdminBro from "admin-bro";
const AdminBroExpress = require("admin-bro-expressjs") // No types for admin-bro-expressjs so required instead
Resource.validate = validate;
AdminBro.registerAdapter({ Database, Resource });
@Entity({name: "Persons"})
export class Person extends BaseEntity
{
@PrimaryGeneratedColumn()
public id!: number;
@Column({type: 'varchar'})
public firstName!: string;
@Column({type: 'varchar'})
public lastName!: string;
@UseAsTitle()
public toString(): string
{
return `${this.firstName} ${this.lastName}`;
}
}
( async () =>
{
const connection = await createConnection({
name: "default",
type: "sqlite",
database: "admin_bro_test",
synchronize: true,
logging: true,
entities: [
"src/entity/*.*"
],
migrationsTableName: "typeorm_migrations",
migrations: [
"src/db/migration/*.{ts, js}"
],
});
// Applying connection to model
Person.useConnection(connection);
const adminBro = new AdminBro({
// databases: [connection],
resources: [
{ resource: Person, options: { parent: { name: "foobar" } } }
],
rootPath: '/admin',
});
const app = express();
const router = AdminBroExpress.buildRouter(adminBro);
app.use(adminBro.options.rootPath, router);
app.listen(3000);
})(); StacktraceIncluding logging from connection
|
UPDATE: I've found my problem!! This was a TypeORM problem. in the connection, if referencing your entities using wildcards, it doesn't generate the Not working (NoResourceAdapterError)const connection = await createConnection({
name: "default",
type: "sqlite",
database: "admin_bro_test",
synchronize: true,
logging: true,
entities: [
"src/entity/*.*" // <------- Wildcard entities used by TypeORM
],
migrationsTableName: "typeorm_migrations",
migrations: [
"src/db/migration/*.{ts, js}"
],
}); WorkingAdminBro compiling. const connection = await createConnection({
name: "default",
type: "sqlite",
database: "admin_bro_test",
synchronize: true,
logging: true,
entities: [
Person // <---- Pass in the Entity here instead of using a wildcard
],
migrationsTableName: "typeorm_migrations",
migrations: [
"src/db/migration/*.{ts, js}"
],
}); Fix: entities: [
Person // <---- Pass in the Entity here instead of using a wildcard
], |
For anyone with this error, in my case was AdminBro initializing before my DB connection. |
I had the same error, solved by using an Async Configuration and by extending |
this was my problem |
Any updates on this issue for those of us that don't want to extend the BaseEntity class? This is a pretty silly thing to have to do if we are following the data mapper pattern and need an async config. |
Good day! Please help, i have installed every dependencies and i don't understand why i get "no adapters" error.
As i understand admin-bro-typescript is adapter.
Thanks!
query: START TRANSACTION
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = current_schema() AND "table_name" = 'typeorm_metadata'
query: COMMIT
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = current_schema() AND "table_name" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
(node:70454) UnhandledPromiseRejectionWarning: NoResourceAdapterError: There are no adapters supporting one of the resource you provided
at /Users/jamshedlatipov/work/elenafurs-express-admin/node_modules/admin-bro/lib/backend/utils/resources-factory.js:93:15
at Array.map ()
at ResourcesFactory._convertResources (/Users/jamshedlatipov/work/elenafurs-express-admin/node_modules/admin-bro/lib/backend/utils/resources-factory.js:87:22)
at ResourcesFactory.buildResources (/Users/jamshedlatipov/work/elenafurs-express-admin/node_modules/admin-bro/lib/backend/utils/resources-factory.js:42:35)
at new AdminBro (/Users/jamshedlatipov/work/elenafurs-express-admin/node_modules/admin-bro/lib/admin-bro.js:168:39)
at /Users/jamshedlatipov/work/elenafurs-express-admin/app.js:71:32
at step (/Users/jamshedlatipov/work/elenafurs-express-admin/app.js:33:23)
at Object.next (/Users/jamshedlatipov/work/elenafurs-express-admin/app.js:14:53)
at fulfilled (/Users/jamshedlatipov/work/elenafurs-express-admin/app.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use
node --trace-warnings ...
to show where the warning was created)(node:70454) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)(node:70454) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The text was updated successfully, but these errors were encountered: