Skip to content
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

NestJS 10.2.7 HttpAdapterHost dependency error #60

Open
kok32gold opened this issue Oct 24, 2023 · 3 comments
Open

NestJS 10.2.7 HttpAdapterHost dependency error #60

kok32gold opened this issue Oct 24, 2023 · 3 comments

Comments

@kok32gold
Copy link

kok32gold commented Oct 24, 2023

NestJS 10.2.7 HttpAdapterHost dependency error

Error:

127  - 10/24/2023, 6:53:51 AM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the AdminModule (?, AbstractLoader, CONFIG_TOKEN). Please make sure that the argument HttpAdapterHost at index [0] is available in the AdminModule context
Potential solutions:
- Is AdminModule a valid NestJS module?
- If HttpAdapterHost is a provider, is it part of the current AdminModule?
- If HttpAdapterHost is exported from a separate @Module, is that module imported within AdminModule?
  @Module({
    imports: [ /* the Module containing HttpAdapterHost */ ]
  })

Error: Nest can't resolve dependencies of the AdminModule (?, AbstractLoader, CONFIG_TOKEN). Please make sure that the argument HttpAdapterHost at index [0] is available in the AdminModule context.

Dependencies:

"dependencies": {
    "@admin-bro/express": "^3.1.0",
    "@admin-bro/nestjs": "^1.1.0",
    "@admin-bro/typeorm": "^1.4.0",
    "@adminjs/nestjs": "^6.0.1",
    "@nestjs/axios": "^3.0.0",
    "@nestjs/cache-manager": "^2.1.0",
    "@nestjs/common": "^10.2.7",
    "@nestjs/config": "^3.1.1",
    "@nestjs/core": "^10.2.7",
    "@nestjs/passport": "^10.0.2",
    "@nestjs/platform-express": "^10.2.7",
    "@nestjs/schedule": "^4.0.0",
    "@nestjs/testing": "^10.2.7",
    "@nestjs/typeorm": "^10.0.0",
    "@nextnm/nestjs-mailgun": "^3.0.1",
    "admin-bro": "^3.3.1",
    "axios": "^1.5.1",
    "cache-manager": "^5.2.4",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "express-formidable": "^1.2.0",
    "express-session": "^1.17.3",
    "firebase-admin": "^11.11.0",
    "mysql2": "^3.6.2",
    "passport": "0.6.0",
    "passport-firebase-jwt": "^1.2.1",
    "passport-jwt": "^4.0.1",
    "pg": "^8.11.3",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "ssl-checker": "^2.0.8",
    "typeorm": "^0.3.17"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.2.0",
    "@nestjs/schematics": "^10.0.2",
    "@types/express": "^4.17.20",
    "@types/jest": "29.5.6",
    "@types/node": "20.8.8",
    "@types/passport-jwt": "^3.0.11",
    "@types/supertest": "^2.0.15",
    "@typescript-eslint/eslint-plugin": "^6.9.0",
    "@typescript-eslint/parser": "^6.9.0",
    "eslint": "^8.52.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.1",
    "jest": "29.7.0",
    "prettier": "^3.0.3",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "29.1.1",
    "ts-loader": "^9.5.0",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "4.2.0",
    "typescript": "^5.2.2"
  }

app.module.ts

import { AdminModule } from '@admin-bro/nestjs'
import { Database, Resource } from '@admin-bro/typeorm';
import AdminBro from 'admin-bro'
.....
Resource.validate = validate;
AdminBro.registerAdapter({ Database, Resource });
.....
AdminModule.createAdmin({
      rootPath: '/admin',
      resources: [
          UserEntity
      ]
}),
@chand-babu
Copy link

any solution you got ?

@danyalutsevich
Copy link

any solutions?

@danyalutsevich
Copy link

danyalutsevich commented Feb 16, 2024

the solution for me was to use https://github.com/SoftwareBrothers/adminjs-cli
this cli tool created nestjs typeorm postgres template for me

P.S. Make shure your entities extends BaseEntity
import { BaseEntity } from "typeorm";

PP.S Mark relations with Relation type

User.entity.ts

import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, Relation,BaseEntity } from 'typeorm';
import { UserEntity } from './User.entity.js';

@Entity({ name: 'service' })
export class ServiceEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column()
  description: string;

  @ManyToOne(() => UserEntity, (user) => user.services)
  owner: Relation<UserEntity>;
}

Service.entity.ts


import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Relation, BaseEntity } from 'typeorm';
import { ServiceEntity } from './Service.entity.js';

@Entity({ name: 'user' })
export class UserEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  email: string;

  @Column()
  password: string;

  @OneToMany(() => ServiceEntity, (service) => service.owner)
  services: Relation<ServiceEntity>[];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants