#Nestjs- docker postgres not working, small fix needed

9 messages · Page 1 of 1 (latest)

peak ingot
#

have repo
https://github.com/stephyswe/wanago-2024-aug

using wanagos tutorial at https://wanago.io/2020/05/18/api-nestjs-postgresql-typeorm/

i get error

[Nest] 20262  - 08/02/2024, 5:57:06 PM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the PostsService (?). Please make sure that the argument "PostRepository" at index [0] is available in the PostsModule context.

Potential solutions:
- Is PostsModule a valid NestJS module?
- If "PostRepository" is a provider, is it part of the current PostsModule?
- If "PostRepository" is exported from a separate @Module, is that module imported within PostsModule?
  @Module({
    imports: [ /* the Module containing "PostRepository" */ ]
  })

Error: Nest can't resolve dependencies of the PostsService (?). Please make sure that the argument "PostRepository" at index [0] is available in the PostsModule context.
GitHub

Contribute to stephyswe/wanago-2024-aug development by creating an account on GitHub.

  1. API with NestJS #1. Controllers, routing and the module structure 2. API with NestJS #2. Setting up a PostgreSQL database with TypeORM 3. API with NestJS #3. Authenticating users with bcrypt, Passport, JWT, and cookies 4. API with NestJS #4. Error handling and data validation 5. API with NestJS #5. Serializing the response with […]
#

run it with
docker-compose up -d postgres
then npm run start:dev

#

and create post table with

#
 -- Create the sequence
CREATE SEQUENCE post_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- Create the table
CREATE TABLE public.post
(
    id integer NOT NULL DEFAULT nextval('post_id_seq'::regclass),
    title character varying COLLATE pg_catalog."default" NOT NULL,
    content character varying COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT "PK_be5fda3aac270b134ff9c21cdee" PRIMARY KEY (id)
);
visual aurora
#

as you can see, you're not registering a typeorm entity but the @Post() decorator

celest fableBOT
#

This post has been marked as resolved. :white_check_mark:
Please read through the conversation and resolution, if you are having the same issue. If you were the original author of the post and the issue is still fresh (within a few days) and you are still have having trouble, continue to reply here. If you are not the original author of the post or the post has aged, start a new thread linking this one as relevant to your problem, providing as much additional information as possible.

visual aurora
#

tip: always read everything several times when copying code from tutorials

peak ingot
#

oh

#

haha