Giter VIP home page Giter VIP logo

Comments (22)

vinhcv161 avatar vinhcv161 commented on May 25, 2024 2

Please, try it:

MONGO

#FOR STANDALONE: MONGO_URL=mongodb://127.0.0.1:27017/nestjs-microservice?replicaSet=app&serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&directConnection=true&ssl=false #FOR CLUSTER: #MONGO_URL=mongodb://127.0.0.1:27081,127.0.0.1:27082,127.0.0.1:27083/nestjs-microservice?replicaSet=app&serverSelectionTimeoutMS=5000&connectTimeoutMS=5000

@mikemajesty @neeteshraj

from nestjs-microservice-boilerplate-api.

vinhcv161 avatar vinhcv161 commented on May 25, 2024 1

I also had connection problems.
Try changing "localhost" to "127.0.0.1" and run again.
I understand it shouldn't have made a difference, but it worked

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024 1

@neeteshraj @vinhcv161 try this branch: branch

from nestjs-microservice-boilerplate-api.

vinhcv161 avatar vinhcv161 commented on May 25, 2024 1

Please, try it: (add for local singleton: directConnection=true)

MONGO

#FOR STANDALONE:
MONGO_URL=mongodb://127.0.0.1:27017/nestjs-microservice?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&directConnection=true&ssl=false
#FOR CLUSTER:
#MONGO_URL=mongodb://127.0.0.1:27081,127.0.0.1:27082,127.0.0.1:27083/nestjs-microservice?replicaSet=app&serverSelectionTimeoutMS=5000&connectTimeoutMS=5000

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024

Try connecting to a DBMS of your choice and see if the same error occurs.

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

i am trying to connect to mongodb and the error occurs.

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

also there is this error when running yarn start:dev

[2:52:42 PM] Starting compilation in watch mode...

src/infra/logger/service.ts:142:7 - error TS2322: Type 'Logger' is not assignable to type 'Logger'.
Type 'Logger' is not assignable to type 'LoggerExtras'.
Types of property 'onChild' are incompatible.
Type 'OnChildCallback<import("/home/nitesh/Development/nestjs-microservice-boilerplate-api/node_modules/pino/pino").LoggerOptions>' is not assignable to type 'OnChildCallback<import("/home/nitesh/Development/nestjs-microservice-boilerplate-api/node_modules/pino-http/node_modules/pino/pino").default.LoggerOptions>'.
Types of parameters 'child' and 'child' are incompatible.
Type 'Logger<LoggerOptions & ChildOptions>' is not assignable to type 'Logger<LoggerOptions & ChildLoggerOptions>'.
Type 'Logger<LoggerOptions & ChildOptions>' is not assignable to type 'LoggerExtras<LoggerOptions & ChildLoggerOptions>'.
The types returned by 'child(...)' are incompatible between these types.
Type 'Logger<LoggerOptions & ChildOptions & ChildOptions>' is not assignable to type 'Logger<LoggerOptions & ChildLoggerOptions & ChildOptions>'.
Type 'Logger<LoggerOptions & ChildOptions & ChildOptions>' is not assignable to type 'LoggerExtras<LoggerOptions & ChildLoggerOptions & ChildOptions>'.
Types of property 'on' are incompatible.
Type '<Opts = LoggerOptions & ChildOptions & ChildOptions>(event: "level-change", listener: LevelChangeEventListener<...>) => Logger<...>' is not assignable to type '<Opts = LoggerOptions & ChildLoggerOptions & ChildOptions>(event: "level-change", listener: LevelChangeEventListener) => LoggerExtras<...>'.
Types of parameters 'listener' and 'listener' are incompatible.
Types of parameters 'logger' and 'logger' are incompatible.
Type 'Logger<LoggerOptions & ChildOptions & ChildOptions>' is not assignable to type 'Logger'.
Type 'Logger<LoggerOptions & ChildOptions & ChildOptions>' is not assignable to type 'CustomLevelLogger'.

142 logger: pinoLogger,
~~~~~~

node_modules/pino-http/index.d.ts:26:5
26 logger?: pino.Logger | undefined;
~~~~~~
The expected type comes from property 'logger' which is declared here on type 'Options<IncomingMessage, ServerResponse>'

src/modules/user/module.ts:40:15 - error TS2322: Type 'Model<unknown, unknown, unknown, {}, Document<unknown, unknown, unknown> & Omit<Required<{ _id: unknown; }>, never>, UserDocument>' is not assignable to type 'MongoRepositoryModelSessionType<PaginateModel<UserDocument, {}, {}>>'.
Property 'paginate' is missing in type 'Model<unknown, unknown, unknown, {}, Document<unknown, unknown, unknown> & Omit<Required<{ _id: unknown; }>, never>, UserDocument>' but required in type 'PaginateModel<UserDocument, {}, {}>'.

40 const repository: MongoRepositoryModelSessionType<PaginateModel> = connection.model<
~~~~~~~~~~

node_modules/mongoose-paginate-v2/index.d.ts:104:5
104 paginate(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 query?: FilterQuery,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
110 ) => void
~~~~~~~~~~~~~~~
111 ): Promise<PaginateResult<PaginateDocument<T, TMethods, O>>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'paginate' is declared here.

src/modules/user/module.ts:43:22 - error TS2345: Argument of type 'Schema<User, Model<User, any, any, any, Document<unknown, any, User> & User & Required<{ _id: string; }>, any>, {}, {}, {}, {}, DefaultSchemaOptions, User, Document<...> & ... 1 more ... & Required<...>>' is not assignable to parameter of type 'Schema<UserDocument, any, any, {}, any, any, any, UserDocument | ({ createdAt: NativeDate; updatedAt: NativeDate; } & Document<any, any, any> & UserEntity), Document<...> & ((FlatRecord<...> & { ...; }) | (FlatRecord<...> & { ...; }))>'.
The types of 'obj.login' are incompatible between these types.
Type 'SchemaDefinitionProperty<string, User>' is not assignable to type 'SchemaDefinitionProperty<string, UserDocument>'.
Type 'SchemaTypeOptions<string, User>' is not assignable to type 'SchemaDefinitionProperty<string, UserDocument>'.
Type 'SchemaTypeOptions<string, User>' is not assignable to type 'SchemaTypeOptions<string, UserDocument> | MixedSchemaTypeOptions'.
Type 'SchemaTypeOptions<string, User>' is not assignable to type 'SchemaTypeOptions<string, UserDocument>'.
Type 'User' is not assignable to type 'UserDocument'.

43 >(User.name, UserSchema);
~~~~~~~~~~

[2:52:48 PM] Found 3 errors. Watching for file changes.

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

@mikemajesty any solutions?

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024

Can you share your repo?

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

@mikemajesty
https://github.com/neeteshraj/sca

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

@mikemajesty can you address the issue here?

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024

There is a difference in some versions of the libraries and there should probably be a break changes between them. I advise you to use the same boilerplate versions. I will update and resolve these issues soon.

@nestjs/common": "^10.2.8"
"@nestjs/core": "^10.2.8",
"@nestjs/mongoose": "^10.0.2",

image

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024

This error happens from version 7 of mongoose.

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

even with the specified packages. i am still getting the error. this is my package.json {
"name": "nestjs-boilerplate-microservice-api",
"version": "1.13.0",
"description": "Nestjs boilerplate api",
"author": "[email protected]",
"private": true,
"license": "MIT",
"scripts": {
"prepare": "husky install",
"build": "nest build",
"start": "node dist/src/main",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"prettier": "prettier --write "src//*.ts" "test//.ts"",
"lint": "eslint "{src,test}/**/
.{ts,js}" --fix",
"test": "jest --config="./jest.config.ts" --detectOpenHandles",
"test:cov": "jest --coverage --detectOpenHandles && yarn make-badges",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"infra": "./scripts/mongo/start-replicaset.sh",
"scaffold": "./node_modules/@mikemajesty/microservice-crud/bin/microservice-crud",
"migration:create": "npx sequelize-cli migration:generate --name migration-skeleton",
"migration:run": "npx sequelize-cli db:migrate",
"make-badges": "istanbul-badges-readme"
},
"dependencies": {
"@nestjs/common": "^10.0.2",
"@nestjs/config": "^3.1.0",
"@nestjs/core": "^10.0.2",
"@nestjs/mongoose": "^10.0.2",
"@nestjs/platform-express": "^10.0.2",
"@nestjs/swagger": "^7.1.0",
"@opentelemetry/api": "^1.7.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.45.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.45.0",
"@opentelemetry/instrumentation-http": "^0.45.0",
"@opentelemetry/instrumentation-mongodb": "^0.37.0",
"@opentelemetry/instrumentation-pg": "^0.37.0",
"@opentelemetry/instrumentation-redis-4": "^0.35.4",
"@opentelemetry/resources": "^1.18.0",
"@opentelemetry/sdk-node": "^0.45.0",
"@opentelemetry/sdk-trace-web": "^1.18.0",
"@opentelemetry/semantic-conventions": "^1.18.0",
"axios": "^1.6.0",
"axios-better-stacktrace": "^2.1.5",
"axios-retry": "^3.9.0",
"body-parser": "^1.20.2",
"class-validator": "^0.14.0",
"colorette": "^2.0.19",
"convert-pino-request-to-curl": "^0.0.29",
"express-rate-limit": "^7.1.4",
"helmet": "^7.1.0",
"jsonwebtoken": "^9.0.0",
"luxon": "^3.4.0",
"mongoose": "^6.9.0",
"mongoose-paginate-v2": "^1.7.1",
"nestjs-convert-to-curl": "^0.0.22",
"node-cache": "^5.1.2",
"pg": "^8.10.0",
"pg-hstore": "^2.3.4",
"pino": "^8.5.0",
"pino-http": "^8.2.0",
"pino-mongodb": "^4.3.0",
"pino-pretty": "^9.1.0",
"redis": "^4.6.4",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"sequelize": "^6.35.0",
"sequelize-typescript": "^2.1.5",
"swagger-ui-express": "^5.0.0",
"ts-jest": "^29.1.1",
"uuid": "^9.0.0",
"zod": "^3.20.2"
},
"devDependencies": {
"@commitlint/cli": "^18.4.0",
"@commitlint/config-conventional": "^18.4.0",
"@mikemajesty/microservice-crud": "0.2.9",
"@nestjs/cli": "^10.0.2",
"@nestjs/schematics": "^10.0.2",
"@nestjs/testing": "^10.0.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.0.4",
"@semantic-release/npm": "^10.0.5",
"@semantic-release/release-notes-generator": "^11.0.4",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.46",
"@swc/jest": "^0.2.24",
"@types/express": "^4.17.13",
"@types/jest": "29.5.8",
"@types/jsonwebtoken": "^9.0.1",
"@types/luxon": "^3.2.0",
"@types/node": "^20.3.0",
"@types/sequelize": "^4.28.14",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.13.0",
"husky": "^8.0.3",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.1.1",
"prettier": "^2.3.2",
"semantic-release": "^21.1.1",
"sequelize-cli": "^5.3.0",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "4.1.1",
"typescript": "5.1.6"
}
} and this is the error [11:43:36 AM] Starting compilation in watch mode...

[11:43:42 AM] Found 0 errors. Watching for file changes.

TRACE [18/11/2023 02:58:44]: CacheMemory connected!
TRACE [18/11/2023 02:58:44]: Redis connected!

[sequelize] Executed (default): SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'cats' 3ms
[sequelize] Executed (default): CREATE TABLE IF NOT EXISTS "cats" ("id" UUID , "name" VARCHAR(255), "age" INTEGER, "breed" VARCHAR(255), "deletedAt" TIMESTAMP WITH TIME ZONE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id")); 12ms
[sequelize] Executed (default): SELECT i.relname AS name, ix.indisprimary AS primary, ix.indisunique AS unique, ix.indkey AS indkey, array_agg(a.attnum) as column_indexes, array_agg(a.attname) AS column_names, pg_get_indexdef(ix.indexrelid) AS definition FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND t.relkind = 'r' and t.relname = 'cats' GROUP BY i.relname, ix.indexrelid, ix.indisprimary, ix.indisunique, ix.indkey ORDER BY i.relname; 4ms
TRACE [18/11/2023 02:58:44]: Sequelize connected!

/home/nitesh/Development/nestjs-microservice-boilerplate-api/node_modules/mongodb/src/sdam/topology.ts:591
const timeoutError = new MongoServerSelectionError(
^
MongoServerSelectionError: Server selection timed out after 5000 ms
at Timeout._onTimeout (/home/nitesh/Development/nestjs-microservice-boilerplate-api/node_modules/mongodb/src/sdam/topology.ts:591:30)
at listOnTimeout (node:internal/timers:569:17)
at processTimers (node:internal/timers:512:7)

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

the docker containers are up and running successfully but i cannot even connect to the replicaset to my mongodb compass.

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024

I can't get the same error here on my machine, even in your project.

Print the terminal output of the "npm run infra" command

Screenshot from 2023-11-18 11-44-51

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

even after changing localhost to 127.0.0.1 i am getting this error
Uploading Screenshot 2023-11-30 at 7.39.41 PM.png…

from nestjs-microservice-boilerplate-api.

hisyam-harun avatar hisyam-harun commented on May 25, 2024

Me too when try run yarn start:dev

Screenshot 2023-12-01 at 09 18 39

Aside that, is there any sample microservices app that was using this boilerplate?

from nestjs-microservice-boilerplate-api.

mikemajesty avatar mikemajesty commented on May 25, 2024

@hisyam-harun

remove
"builder": "swc",
"typeCheck": true

{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "builder": "swc",
    "typeCheck": true
  }
}

nest-cli.json

from nestjs-microservice-boilerplate-api.

neeteshraj avatar neeteshraj commented on May 25, 2024

@neeteshraj @vinhcv161 try this branch: branch

still not connected

from nestjs-microservice-boilerplate-api.

accountsware avatar accountsware commented on May 25, 2024

I am having similar issue

Mongo connection error

I could connect to Mongo if I just use MONGO_URL=mongodb://admin:[email protected]:27017 connection string but then users collection is not to be seen anywhere is in MongoDB

Mongo connected

from nestjs-microservice-boilerplate-api.

accountsware avatar accountsware commented on May 25, 2024

I am having similar issue

Mongo connection error

I could connect to Mongo if I just use MONGO_URL=mongodb://admin:[email protected]:27017 connection string but then users collection is not to be seen anywhere is in MongoDB

Mongo connected

silly me, saw your new .env !! connection string - working now.

from nestjs-microservice-boilerplate-api.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.