Giter Club home page Giter Club logo

brocoders / nestjs-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
2.4K 2.4K 490.0 5.84 MB

NestJS boilerplate. Auth, TypeORM, Mongoose, Postgres, MongoDB, Mailing, I18N, Docker.

Home Page: https://nestjs-boilerplate-test.herokuapp.com/docs

License: MIT License

JavaScript 0.75% TypeScript 91.50% Shell 2.68% Dockerfile 1.53% Handlebars 1.30% Procfile 0.04% EJS 2.20%
auth boilerplate ci crud database docker e2e i18n mailing mongodb mongoose nestjs nestjs-boilerplate nodejs seed sign swagger typeorm typescript

nestjs-boilerplate's People

Contributors

allcontributors[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar elenvlass avatar fdikmen avatar gornostal avatar hankaibo avatar hcikikci avatar its-monotype avatar keremkurtulus avatar renovate-bot avatar renovate[bot] avatar sergeilomako avatar shchepotin avatar someone92 avatar techstarmahesh avatar valeragin avatar zourdyzou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nestjs-boilerplate's Issues

EntityMetadataNotFoundError: No metadata for "Role" was found.

╰─❯ npm run seed:run

> nestjs-boilerplate@0.0.1 seed:run
> ts-node -r tsconfig-paths/register ./src/database/seeds/run-seed.ts

[Nest] 2808  - 20/02/2023, 18:21:00     LOG [NestFactory] Starting Nest application...
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] SeedModule dependencies initialized +19ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] ConfigModule dependencies initialized +1ms
query: SELECT * FROM current_schema()
query: SELECT version();
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] TypeOrmCoreModule dependencies initialized +269ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] RoleSeedModule dependencies initialized +0ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] StatusSeedModule dependencies initialized +1ms
[Nest] 2808  - 20/02/2023, 18:21:00     LOG [InstanceLoader] UserSeedModule dependencies initialized +0ms
C:\Users\itsmo\Desktop\my-app\node_modules\src\data-source\DataSource.ts:438
        if (!metadata) throw new EntityMetadataNotFoundError(target)
                             ^
EntityMetadataNotFoundError: No metadata for "Role" was found.
    at DataSource.getMetadata (C:\Users\itsmo\Desktop\my-app\node_modules\src\data-source\DataSource.ts:438:30)
    at Repository.get metadata [as metadata] (C:\Users\itsmo\Desktop\my-app\node_modules\src\repository\Repository.ts:53:40)
    at Repository.count (C:\Users\itsmo\Desktop\my-app\node_modules\src\repository\Repository.ts:467:40)
    at RoleSeedService.run (C:\Users\itsmo\Desktop\my-app\src\database\seeds\role\role-seed.service.ts:15:45)
    at runSeed (C:\Users\itsmo\Desktop\my-app\src\database\seeds\run-seed.ts:11:34)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    ```

Asking

Do you have command for generate module like in your project you have users Lets say I want to create another new folder name booking so do I need to create it manually or you have command too?

Deprecated Libraries

Describe the bug
It's not exactly a bug, however, when you try to install dependencies, you focus this:

- npm WARN deprecated [email protected]: this library is no longer supported

- npm WARN deprecated [email protected]: Multer 1.x is affected by CVE-2022-24434. This is fixed in v1.4.4-lts.1 which drops support for 
- versions of Node.js before 6. Please upgrade to at least Node.js 6 and version 1.4.4-lts.1 of Multer. If you need support for older versions of Node.js, we are open to accepting patches that would fix the CVE on the main 1.x release line, whilst maintaining compatibility with Node.js 0.10.

- npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

- npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

- npm WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual v

To Reproduce

  1. Clone repository

    git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app
  2. Go to folder, and copy env-example-relational as .env.

    cd my-app/
    cp env-example-relational .env
  3. Change DATABASE_HOST=postgres to DATABASE_HOST=localhost

    Change MAIL_HOST=maildev to MAIL_HOST=localhost

  4. Run additional container:

    docker compose up -d postgres adminer maildev
  5. Install dependency

    npm install

Expected behavior
Should not have critical dependencies issues, especially with CVE.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • NodeJS Version v20.10.0

Impossible to debug app prod logs on e2e failure

Describe the bug
We on CI the app fails to start with some error, you cannot see app logs to fix it, cause it's currently suppressed using >/dev/ null in startup.ci.sh (e2e.Dockerfile script)

To Reproduce
Steps to reproduce the behavior:

  1. Write smth that will crash your app on CI e2e
  2. Observe "wait-for-it. sh: timeout occurred after waiting 15 seconds for localhost:7777"

Expected behavior
There is the way to see prod logs on e2e failure to fix the issue.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Potential solutions

  1. Remove output suppression.
  2. Save to a log file and upload it as Github artifact.

Run seeds gives error

Describe the bug
const salt = await bcrypt.genSalt();
^
TypeError: Cannot read properties of undefined (reading 'genSalt')
at UserSeedService.run (/xx/nestjs/src/database/seeds/relational/user/user-seed.service.ts:26:33)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runSeed (/xx/nestjs/src/database/seeds/relational/run-seed.ts:13:3)

To Reproduce

  1. Go to folder, and copy env-example-relational as .env.

    cd my-app/
    cp env-example-relational .env
  2. Change DATABASE_HOST=postgres to DATABASE_HOST=localhost

    Change MAIL_HOST=maildev to MAIL_HOST=localhost

  3. Run additional container:

    docker compose up -d postgres adminer maildev
  4. Install dependency

    npm install
  5. Run migrations

    npm run migration:run
  6. Run seeds

    npm run seed:run:relational

Error occurred

Expected behavior
No error when running npm run seed:run:relational

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [Mac Os X, 14.0 (23A344), Apple M2]
  • NodeJS Version v20.11.0

Additional context
N.a

How user's photo is send to s3?

It's not a bug but a question, could you explain to me how is the user's photo (which is a FileEntity) sent to s3? Additionally, could you clarify how it is deleted if I update the photo?

My doubt is why, from what I've seen in the users.service file, it doesn't use the files.service

throws an error that the database <db> does not exist

Describe the bug
It throws an error that the database does not exist, when in fact it does exist when I run "npm run start:dev" but inside docker, in logs, it gives me this error inside the Postgres Service:

2023-04-21 20:16:52 PostgreSQL Database directory appears to contain a database; Skipping initialization 2023-04-21 20:16:52 2023-04-21 19:26:41 2023-04-21 16:26:41.482 UTC [1] LOG: starting PostgreSQL 15.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit 2023-04-21 19:26:41 2023-04-21 16:26:41.483 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-04-21 19:26:41 2023-04-21 16:26:41.483 UTC [1] LOG: listening on IPv6 address "::", port 5432 2023-04-21 19:26:41 2023-04-21 16:26:41.497 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-04-21 19:26:41 2023-04-21 16:26:41.541 UTC [24] LOG: database system was shut down at 2023-04-21 16:26:37 UTC 2023-04-21 19:26:41 2023-04-21 16:26:41.589 UTC [1] LOG: database system is ready to accept connections _2023-04-21 19:27:07 2023-04-21 16:27:07.120 UTC [29] FATAL: database "topen_db_new" does not exist 2023-04-21 19:28:35 2023-04-21 16:28:35.842 UTC [31] FATAL: database "topen_db_new" does not exist_ 2023-04-21 19:28:39 2023-04-21 16:28:39.946 UTC [1] LOG: received fast shutdown request 2023-04-21 19:28:39 2023-04-21 16:28:39.954 UTC [1] LOG: aborting any active transactions 2023-04-21 19:28:39 2023-04-21 16:28:39.957 UTC [1] LOG: background worker "logical replication launcher" (PID 27) exited with exit code 1

and inside Api service logs it gives this error:

2023-04-21 20:16:37 wait-for-it.sh: waiting 15 seconds for postgres:5432 2023-04-21 20:16:37 wait-for-it.sh: postgres:5432 is available after 0 seconds 2023-04-21 20:16:41 error: database "topen_db_new" does not exist 2023-04-21 20:16:41 at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/src/parser.ts:369:69) 2023-04-21 20:16:41 at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/src/parser.ts:188:21) 2023-04-21 20:16:41 at Parser.parse (/usr/src/app/node_modules/pg-protocol/src/parser.ts:103:30) 2023-04-21 20:16:41 at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/src/index.ts:7:48) 2023-04-21 20:16:41 at Socket.emit (node:events:513:28) 2023-04-21 20:16:41 at Socket.emit (node:domain:489:12) 2023-04-21 20:16:41 at addChunk (node:internal/streams/readable:324:12) 2023-04-21 20:16:41 at readableAddChunk (node:internal/streams/readable:297:9) 2023-04-21 20:16:41 at Socket.Readable.push (node:internal/streams/readable:234:10) 2023-04-21 20:16:41 at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { 2023-04-21 20:16:41 length: 97, 2023-04-21 20:16:41 severity: 'FATAL', 2023-04-21 20:16:41 code: '3D000', 2023-04-21 20:16:41 detail: undefined, 2023-04-21 20:16:41 hint: undefined, 2023-04-21 20:16:41 position: undefined, 2023-04-21 20:16:41 internalPosition: undefined, 2023-04-21 20:16:41 internalQuery: undefined, 2023-04-21 20:16:41 where: undefined, 2023-04-21 20:16:41 schema: undefined, 2023-04-21 20:16:41 table: undefined, 2023-04-21 20:16:41 column: undefined, 2023-04-21 20:16:41 dataType: undefined, 2023-04-21 20:16:41 constraint: undefined, 2023-04-21 20:16:41 file: 'postinit.c', 2023-04-21 20:16:37 2023-04-21 20:16:37 > [email protected] migration:run 2023-04-21 20:16:37 > npm run typeorm -- --dataSource=src/database/data-source.ts migration:run 2023-04-21 20:16:37 2023-04-21 20:16:38 2023-04-21 20:16:38 > [email protected] typeorm 2023-04-21 20:16:38 > env-cmd ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --dataSource=src/database/data-source.ts migration:run 2023-04-21 20:16:38 2023-04-21 20:16:40 Error during migration run:

**Desktop

  • OS: [e.g. Windows]
  • NodeJS Version [e.g. 18.16.0]

The server is not turning on

Describe the bug
After cloning, the server (api :3000) is not turning on

To Reproduce

  1. Follow "Quick Run Steps"
  2. Api (localhost:3000) container has the following error:

Screenshots
Screenshot 2023-08-22 at 11 03 22

Desktop (please complete the following information):

  • OS: Mac Venture 13.5
  • NodeJS Version 18.16.0
  • Docker version 23.0.4
  • Docker Compose version 2.17.2

Terminal logs

wait-for-it.sh: postgres:5432 is available after 1 seconds
Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432
}
wait-for-it.sh: waiting 15 seconds for postgres:5432
wait-for-it.sh: postgres:5432 is available after 0 seconds
> [email protected] migration:run
> npm run typeorm -- --dataSource=src/database/data-source.ts migration:run
> [email protected] typeorm```

Running in dev mode

Hey this is a really awesome starter, can you tell me your workflow for running in dev mode? im new to docker and when i run docker-compose up -d it runs and starts, but it doesnt seem to watch files and reload

Unable to connect to the database on Production

I deployed my app to railway app but I am getting this error. I've changed the node_Env to production also I have my PORT as 3000 but the error is still persisting. Below is a screenshot of the error
typeorm error

User doesn't have a role property upon token refresh. Leads to false 403's

Describe the bug
Upon refreshing the auth token, the "user" object attached to the "request" is missing the "role" property. When using the "RolesGuard", the user must have the "role" property present in order to pass; it does not. This leads to the RolesGuard rejecting with a 403

To Reproduce
Steps to reproduce the behavior:

  1. Set the token expiration to a small number.
  2. Trigger the login, log the "request.user" from RolesGuard, observe that is has a "role" property upon the initial login.
  3. Trigger the refresh.
  4. Test the same route as in step 2. The user doesn't have a role property anymore.

Expected behavior
I would expect request.user to have consistent properties, and for the route's specifying roles.user to not reject the user on a 403.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Mac
  • NodeJS Version 20.9.0

Additional context
none.

Deployment crashed

I just deployed my app to railway.app. I have set up the database and added the DATABASE_URL to my env variable but I am getting this error
waitforit

Change serializer to class-transformer Exclude

Thank you for creating an excellent boilerplate!

The serializer way looks great but in my opinion, it is not the best practice. I suggest changing it to Exclude decorator importing from class-transformer. Thus, we don't have to deep map and iterate all the JSON results with conditions.

I will create a PR and pin this issue. Please consider my solution and share your thoughts. Thanks!

Social strategy, is it out of the box working or requires some extra config?

Hey, just want to say this is an amazing starter, really well done.

I have a question about social strategy, am i missing something? Is it social logins supposed to work out of the box? As far as i can see we still need to develop some of the flow logic for handling auth 2.0 login flows such as the relevant passport strategies, GET endpoints etc? and there doesn't seem to be a place to input the callbacks as env property.

I would just like to confirm that we need to implement this ourselves as id prefer to use your libs way if possible before i dig in.

If not all good, and thanks again for the awesome starter

ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'getRepository')

[Nest] 8651 - 06/30/2023, 9:31:59 AM ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'getRepository')
TypeError: Cannot read properties of undefined (reading 'getRepository')
at IsExist.validate (src/utils/validators/is-exists.validator.ts:22:8)
at node_modules/src/validation/ValidationExecutor.ts:271:68
at Array.forEach ()
at node_modules/src/validation/ValidationExecutor.ts:253:82
at Array.forEach ()
at ValidationExecutor.customValidations (node_modules/src/validation/ValidationExecutor.ts:252:15)
at ValidationExecutor.performValidations (node_modules/src/validation/ValidationExecutor.ts:212:10)
at node_modules/src/validation/ValidationExecutor.ts:114:14
at Array.forEach ()
at ValidationExecutor.execute (node_modules/src/validation/ValidationExecutor.ts:95:35)
{"level":30,"time":1688097719815,"pid":8651,"hostname":"","reqId":"req-1","res":{"statusCode":500},"responseTime":32.468290999531746,"msg":"request completed"}

can not connect with mongoose DB

Describe the bug
I try to use mongodb but not able to use i change in env file and then install mongodb npm module and try to create use and then login it is not work

To Reproduce
Steps to reproduce the behavior:

  1. Change env for mongodb
  2. Install npm i mongodb
  3. Create user.
  4. Login user
  5. You can see the use login error.

Expected behavior
I want to do all task that i do in postgresql

Desktop (please complete the following information):

  • OS: [Windows 10]
  • NodeJS Version [18.16.0]

Password cannot be changed

Describe the bug
I changed the password in the .env file. But it was wrong.

To Reproduce
Steps to reproduce the behavior:

git clone --depth 1 https://github.com/brocoders/nestjs-boilerplate.git my-app
cd my-app/
cp env-example .env (change password: secret ---> sec333ret)
docker compose up -d

check status run
截屏2023-08-07 22 48 53

root@iZ2ze8qk0bio1k49bk5lrrZ:~/project/my-app# docker compose logs
my-app-postgres-1  | 
my-app-postgres-1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
my-app-postgres-1  | 
my-app-postgres-1  | 2023-08-07 14:34:50.619 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
my-app-postgres-1  | 2023-08-07 14:34:50.619 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
my-app-postgres-1  | 2023-08-07 14:34:50.619 UTC [1] LOG:  listening on IPv6 address "::", port 5432
my-app-postgres-1  | 2023-08-07 14:34:50.624 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
my-app-postgres-1  | 2023-08-07 14:34:50.639 UTC [23] LOG:  database system was shut down at 2023-08-07 14:33:42 UTC
my-app-postgres-1  | 2023-08-07 14:34:50.647 UTC [1] LOG:  database system is ready to accept connections
my-app-postgres-1  | 2023-08-07 14:35:00.787 UTC [28] FATAL:  password authentication failed for user "root"
my-app-postgres-1  | 2023-08-07 14:35:00.787 UTC [28] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
my-app-adminer-1   | [Mon Aug  7 14:34:51 2023] PHP 7.4.27 Development Server (http://[::]:8080) started
my-app-maildev-1   | MailDev using directory /tmp/maildev-1
my-app-maildev-1   | MailDev webapp running at http://0.0.0.0:1080
my-app-maildev-1   | MailDev SMTP Server running at 0.0.0.0:1025
my-app-api-1       | wait-for-it.sh: waiting 15 seconds for postgres:5432
my-app-api-1       | wait-for-it.sh: postgres:5432 is available after 1 seconds
my-app-api-1       | 
my-app-api-1       | > [email protected] migration:run
my-app-api-1       | > npm run typeorm -- --dataSource=src/database/data-source.ts migration:run
my-app-api-1       | 
my-app-api-1       | 
my-app-api-1       | > [email protected] typeorm
my-app-api-1       | > env-cmd ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --dataSource=src/database/data-source.ts migration:run
my-app-api-1       | 
my-app-api-1       | Error during migration run:
my-app-api-1       | error: password authentication failed for user "root"
my-app-api-1       |     at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/src/parser.ts:369:69)
my-app-api-1       |     at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/src/parser.ts:188:21)
my-app-api-1       |     at Parser.parse (/usr/src/app/node_modules/pg-protocol/src/parser.ts:103:30)
my-app-api-1       |     at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/src/index.ts:7:48)
my-app-api-1       |     at Socket.emit (node:events:514:28)
my-app-api-1       |     at Socket.emit (node:domain:489:12)
my-app-api-1       |     at addChunk (node:internal/streams/readable:324:12)
my-app-api-1       |     at readableAddChunk (node:internal/streams/readable:297:9)
my-app-api-1       |     at Socket.Readable.push (node:internal/streams/readable:234:10)
my-app-api-1       |     at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
my-app-api-1       |   length: 100,
my-app-api-1       |   severity: 'FATAL',
my-app-api-1       |   code: '28P01',
my-app-api-1       |   detail: undefined,
my-app-api-1       |   hint: undefined,
my-app-api-1       |   position: undefined,
my-app-api-1       |   internalPosition: undefined,
my-app-api-1       |   internalQuery: undefined,
my-app-api-1       |   where: undefined,
my-app-api-1       |   schema: undefined,
my-app-api-1       |   table: undefined,
my-app-api-1       |   column: undefined,
my-app-api-1       |   dataType: undefined,
my-app-api-1       |   constraint: undefined,
my-app-api-1       |   file: 'auth.c',
my-app-api-1       |   line: '326',
my-app-api-1       |   routine: 'auth_failed'
my-app-api-1       | }
root@iZ2ze8qk0bio1k49bk5lrrZ:~/project/my-app# 

Expected behavior
change password.

Desktop (please complete the following information):

  • OS: ubuntu 20
  • NodeJS Version 18

how do i use it with pm2

I have finished developing my api and now I want it to work with pm2 so that it works 24/7, the problem is that when I restart my server, it does not connect, I do not know if I have to add something to docker compose, I am something new

SyntaxError: Unexpected token 'for'

Describe the bug
Moving all files to folder server breaks e2e docker tests

To Reproduce
Steps to reproduce the behavior:

  1. Move all files to server folder
  2. Add working-directory: ./server under - name: Run e2e tests
  3. Wait until CI runs

Expected behavior
CI passes tests

Screenshots
image

Desktop (please complete the following information):
N/A: GitHub actions

Additional context
Tested in local repo, might missing something in docker setup:
https://github.com/nmashchenko/nestjs

error when running "docker-compose up -d"

Describe the bug
I am new to Nest and Docker, so sorry for my noob questioning.
when I run the docker-compose up command in a terminal, it runs all the containers (services), except the API service, and it gives me the following error in the logs:

2023-04-21 15:29:56 wait-for-it.sh: waiting 15 seconds for postgres:5432
2023-04-21 15:29:57 wait-for-it.sh: postgres:5432 is available after 1 seconds
2023-04-21 15:30:01 Error: connect ECONNREFUSED 127.0.0.1:5432
2023-04-21 15:30:01     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
2023-04-21 15:30:01   errno: -111,
2023-04-21 15:30:01   code: 'ECONNREFUSED',
2023-04-21 15:30:01   syscall: 'connect',
2023-04-21 15:30:01   address: '127.0.0.1',
2023-04-21 15:30:01   port: 5432
2023-04-21 15:30:01 }
2023-04-21 15:29:57 
2023-04-21 15:29:57 > [email protected] migration:run
2023-04-21 15:29:57 > npm run typeorm -- --dataSource=src/database/data-source.ts migration:run
2023-04-21 15:29:57 
2023-04-21 15:29:58 
2023-04-21 15:29:58 > [email protected] typeorm
2023-04-21 15:29:58 > env-cmd ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --dataSource=src/database/data-source.ts migration:run

although, I have no problem with Postgres config, or any issue related to env variables because the app runs perfectly when I run npm run start:dev

I have wasted almost one week on this, any help would be appreciated, thanks a lot.

To Reproduce
Steps to reproduce the behavior:

  1. Go to terminal and run docker-compose up -d
  2. the API service does not start, it says exited with (1), see logs
  3. the error is shown in the logs that I provided above.

Expected behavior
I wanted all the services to run perfectly, so I can deploy the code to server.

Desktop (please complete the following information):

  • OS: Windows
  • NodeJS Version 18.16.0

No volumes were detected when running postgres on Docker

Describe the bug
First of all, it is really great starter repo when doing a kickstart backend development on Nest.js but I have something for improvements, It's not really a bug, it's mostly about improvements when running the app locally on docker and sometimes we need to restart everything when a new change comes in. Although I'm fully aware that this repository is not running on docker for development purposes more just for testing or utilizing it.

I'm just gonna correct the docker-compose file to add the volumes correctly

Apple sign in env example

Hello, you would have an example of the parameters that we should put in the apple sign in environment, right in this line

APPLE_APP_AUDIENCE=[]

Could you indicate if you have where to get the parameters, could you extend the env.example with an example array?

Thanks good job in template

Some guidance on refresh flow

In first place, thanks so much for the huge effort on this boilerplate. It is one of the most complete one I have used.

I have been reading the code for the new refresh session workflow and did a couple of tests using the swagger documentation but I have been unable make it work.

It would be much appreciated to have some guidance about which parameters it should receive.

Thanks in advance

Add new validation for files

Replace this

fileFilter: (request, file, callback) => {
if (!file.originalname.match(/\.(jpg|jpeg|png|gif)$/i)) {
return callback(
new HttpException(
{
status: HttpStatus.UNPROCESSABLE_ENTITY,
errors: {
file: `cantUploadFileType`,
},
},
HttpStatus.UNPROCESSABLE_ENTITY,
),
false,
);
}

With

MaxFileSizeValidator and FileTypeValidator

database <db> does not exist.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Send '....'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows]
  • NodeJS Version [e.g. 18.16.0]

Additional context
Add any other context about the problem here.

Docker run failed

After run docker container it is fail
/usr/bin/env: 'bash\r': No such file or directory

"[37;40mnpm ERR! Missing script: "start:prod

npm ERR!

npm ERR! Did you mean this?

npm ERR! npm run start:prod # run the "start:prod" package script

npm ERR!

npm ERR! To see a list of scripts, run:

npm ERR! npm run

npm ERR! A complete log of this run can be found in:

npm ERR! /root/.npm/_logs/2022-07-20T12_20_18_944Z-debug-0.log

Upgrade AWS SDK to V3

Thank you for the awesome project!
I noticed a warning and would appreciate it if you could upgrade the AWS SDK to version 3.
Thanks

(node:105) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy

help

Sorry for my noob questioning, but is there any doc or help on how to deploy the containers on server and set up ci/cd?
Thanks in advance.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
docker-compose.document.ci.yaml
  • mongo 7.0.9
docker-compose.document.test.yaml
  • mongo 7.0.9
docker-compose.document.yaml
  • mongo 7.0.9
docker-compose.relational.ci.yaml
  • postgres 16.2-alpine
docker-compose.relational.test.yaml
  • postgres 16.2-alpine
docker-compose.yaml
  • postgres 16.2-alpine
dockerfile
Dockerfile
  • node 20.12.2-alpine
document.Dockerfile
  • node 20.12.2-alpine
document.e2e.Dockerfile
  • node 20.12.2-alpine
document.test.Dockerfile
  • node 20.12.2-alpine
maildev.Dockerfile
  • node 20.12.2-alpine
relational.e2e.Dockerfile
  • node 20.12.2-alpine
relational.test.Dockerfile
  • node 20.12.2-alpine
github-actions
.github/workflows/docker-e2e.yml
  • actions/checkout v4
  • actions/upload-artifact v4
npm
package.json
  • @aws-sdk/client-s3 3.565.0
  • @aws-sdk/s3-request-presigner 3.565.0
  • @nestjs/common 10.3.8
  • @nestjs/config 3.2.2
  • @nestjs/core 10.3.8
  • @nestjs/jwt 10.2.0
  • @nestjs/mongoose 10.0.6
  • @nestjs/passport 10.0.3
  • @nestjs/platform-express 10.3.8
  • @nestjs/swagger 7.3.1
  • @nestjs/typeorm 10.0.2
  • @types/multer-s3 3.0.3
  • @types/prompts 2.4.9
  • apple-signin-auth 1.7.6
  • bcryptjs 2.4.3
  • class-transformer 0.5.1
  • class-validator 0.14.1
  • dotenv 16.4.5
  • fb 2.0.0
  • google-auth-library 9.9.0
  • handlebars 4.7.8
  • mongoose 8.3.3
  • ms 2.1.3
  • multer 1.4.5-lts.1
  • multer-s3 3.0.1
  • nestjs-i18n 10.4.5
  • nodemailer 6.9.13
  • passport 0.7.0
  • passport-anonymous 1.0.1
  • passport-jwt 4.0.1
  • pg 8.11.5
  • reflect-metadata 0.2.2
  • rimraf 5.0.5
  • rxjs 7.8.1
  • source-map-support 0.5.21
  • swagger-ui-express 5.0.0
  • twitter 1.7.1
  • typeorm 0.3.20
  • @commitlint/cli 19.3.0
  • @commitlint/config-conventional 19.2.2
  • @nestjs/cli 10.3.2
  • @nestjs/schematics 10.1.1
  • @nestjs/testing 10.3.8
  • @release-it/conventional-changelog 8.0.1
  • @swc/cli 0.3.12
  • @swc/core 1.4.17
  • @types/bcryptjs 2.4.6
  • @types/express 4.17.21
  • @types/facebook-js-sdk 3.3.11
  • @types/jest 29.5.12
  • @types/ms 0.7.34
  • @types/multer 1.4.11
  • @types/node 20.12.7
  • @types/passport-anonymous 1.0.5
  • @types/passport-jwt 4.0.1
  • @types/supertest 6.0.2
  • @types/twitter 1.7.4
  • @typescript-eslint/eslint-plugin 7.8.0
  • @typescript-eslint/parser 7.8.0
  • env-cmd 10.1.0
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-import 2.29.1
  • eslint-plugin-prettier 5.1.3
  • husky 9.0.11
  • hygen 6.2.11
  • is-ci 3.0.1
  • jest 29.7.0
  • prettier 3.2.5
  • prompts 2.4.2
  • release-it 17.2.1
  • supertest 7.0.0
  • ts-jest 29.1.2
  • ts-loader 9.5.1
  • ts-node 10.9.2
  • tsconfig-paths 4.2.0
  • tslib 2.6.2
  • typescript 5.4.5
  • node >=16.0.0
  • npm >=8.0.0
nvm
.nvmrc
  • node 20.12.2

  • Check this box to trigger a request for Renovate to run again on this repository

Error Generating Migration: TypeError Reading 'COLLATION' Property

Describe the bug
When attempting to generate a new migration , I encounter a TypeError related to reading the 'COLLATION' property. This error occurs during the schema reflection process, preventing the migration file from being generated.

To Reproduce
Steps to reproduce the behavior:

  1. Modify entity definitions to correct relationships between entities.
  2. Run migration generation command: npm run migration:generate -- src/database/migrations/db-changes
  3. Encounter the error during the migration generation process.

Initially, my entities had the following relationship definitions:

// Incorrect version
@ManyToOne(() => Course, (course) => course.intakes)
course: Course;

@ManyToOne(() => Lecturer, (lecturer) => lecturer.intakes)
lecturer: Lecturer;

I corrected the relationships to properly map to scrapedReviews:

// correct version
@ManyToOne(() => Course, (course) => course.scrapedReviews)
course: Course;

@ManyToOne(() => Lecturer, (lecturer) => lecturer.scrapedReviews)
lecturer: Lecturer;

After making this change, I attempted to generate a new migration to reflect these updates by running migration command. and it fails and gives an error

Expected behavior
The migration generation process should complete successfully, reflecting the recent changes made to the entity definitions in the generated migration file.

Actual behavior
The process fails with the following error message:
Error during migration generation: TypeError: Cannot read properties of undefined (reading 'COLLATION') at /path/to/project/node_modules/typeorm/src/driver/mysql/MysqlQueryRunner.ts:2571:53 ...

Desktop (please complete the following information):

  • OS : Mac OS - Sonoma 14.3
  • NodeJS Version 18.16.0

Additional context

  • This issue arose after correcting the inverse side of relationships in my entity definitions.
  • I have verified that my MySQL version is compatible with the current TypeORM version I'm using.
  • I have attempted to update TypeORM to the latest version and checked my database schema for any unusual configurations related to collations, with no success in resolving the issue.

Migrations does not apply entities

Steps

I had installed the project with all requirements. After that delete the migrations folder.
Try to create migration with npm run migrate:create Init.
The result is an empty init.ts migration folder.
Add a new module with an entity.
Try to create migration with npm run migrate:create Init.
The result again is an empty init.ts migration folder.

Can postgis be supported ?

Describe the bug
Hi, I changed the image from postges to postgis in docker-compose.yaml. But it faild.

To Reproduce
Steps to reproduce the behavior:

  1. .env
DATABASE_TYPE=postgres
DATABASE_HOST=localhost
DATABASE_PORT=9432
DATABASE_USERNAME=root
DATABASE_PASSWORD=123456
DATABASE_NAME=api
DATABASE_SYNCHRONIZE=false
DATABASE_MAX_CONNECTIONS=100
DATABASE_SSL_ENABLED=false
DATABASE_REJECT_UNAUTHORIZED=false
DATABASE_CA=
DATABASE_KEY=
DATABASE_CERT=
  1. docker-compose.yaml
services:
  postgres:
    image: postgis/postgis:15-3.3-alpine
    container_name: a-map-postgis
    ports:
      - ${DATABASE_PORT}:5432
    volumes:
      - ./.data/db:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
  1. run docker compose up
WARN[0000] The "wERI" variable is not set. Defaulting to a blank string. 
[+] Building 0.0s (0/0)                                                                                                                                                                                                                                    
[+] Running 3/0
 ✔ Container a-map-postgis  Recreated                                                                                                                                                                                                                 0.1s 
 ✔ Container a-map-maildev  Created                                                                                                                                                                                                                   0.0s 
 ✔ Container a-map-api      Created                                                                                                                                                                                                                   0.0s 
Attaching to a-map-api, a-map-maildev, a-map-postgis
a-map-postgis  | 
a-map-postgis  | PostgreSQL Database directory appears to contain a database; Skipping initialization
a-map-postgis  | 
a-map-api      | wait-for-it.sh: waiting 15 seconds for postgres:5432
a-map-postgis  | 2023-08-06 01:17:49.806 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
a-map-postgis  | 2023-08-06 01:17:49.806 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
a-map-postgis  | 2023-08-06 01:17:49.806 UTC [1] LOG:  listening on IPv6 address "::", port 5432
a-map-postgis  | 2023-08-06 01:17:49.812 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
a-map-postgis  | 2023-08-06 01:17:49.822 UTC [23] LOG:  database system was shut down at 2023-08-06 01:13:00 UTC
a-map-postgis  | 2023-08-06 01:17:49.829 UTC [1] LOG:  database system is ready to accept connections
a-map-maildev  | MailDev using directory /tmp/maildev-1
a-map-api      | wait-for-it.sh: postgres:5432 is available after 1 seconds
a-map-maildev  | MailDev webapp running at http://0.0.0.0:1080
a-map-maildev  | MailDev SMTP Server running at 0.0.0.0:1025
a-map-api      | 
a-map-api      | > [email protected] migration:run
a-map-api      | > npm run typeorm -- --dataSource=src/database/data-source.ts migration:run
a-map-api      | 
a-map-api      | 
a-map-api      | > [email protected] typeorm
a-map-api      | > env-cmd ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --dataSource=src/database/data-source.ts migration:run
a-map-api      | 
a-map-postgis  | 2023-08-06 01:17:58.279 UTC [28] FATAL:  password authentication failed for user "root"
a-map-postgis  | 2023-08-06 01:17:58.279 UTC [28] DETAIL:  Role "root" does not exist.
a-map-postgis  | 	Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
a-map-api      | Error during migration run:
a-map-api      | error: password authentication failed for user "root"
a-map-api      |     at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/src/parser.ts:369:69)
a-map-api      |     at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/src/parser.ts:188:21)
a-map-api      |     at Parser.parse (/usr/src/app/node_modules/pg-protocol/src/parser.ts:103:30)
a-map-api      |     at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/src/index.ts:7:48)
a-map-api      |     at Socket.emit (node:events:514:28)
a-map-api      |     at Socket.emit (node:domain:489:12)
a-map-api      |     at addChunk (node:internal/streams/readable:324:12)
a-map-api      |     at readableAddChunk (node:internal/streams/readable:297:9)
a-map-api      |     at Socket.Readable.push (node:internal/streams/readable:234:10)
a-map-api      |     at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
a-map-api      |   length: 100,
a-map-api      |   severity: 'FATAL',
a-map-api      |   code: '28P01',
a-map-api      |   detail: undefined,
a-map-api      |   hint: undefined,
a-map-api      |   position: undefined,
a-map-api      |   internalPosition: undefined,
a-map-api      |   internalQuery: undefined,
a-map-api      |   where: undefined,
a-map-api      |   schema: undefined,
a-map-api      |   table: undefined,
a-map-api      |   column: undefined,
a-map-api      |   dataType: undefined,
a-map-api      |   constraint: undefined,
a-map-api      |   file: 'auth.c',
a-map-api      |   line: '326',
a-map-api      |   routine: 'auth_failed'
a-map-api      | }
a-map-api exited with code 1


Expected behavior
I want to use postgis database.

Desktop (please complete the following information):

  • OS: ubuntu 20.04
  • Docker: 24.0.2
  • Docker Compose: 2.18.1

thanks.

Deploying to render.com

Describe the bug
First of all, thanks for the amazing repo!
I am trying to deploy it using docker inside render

To Reproduce
Steps to reproduce the behavior:

  1. Go to render.com
  2. Create a new web service
  3. Use a free instance
  4. Use the default configuration
  5. Deploy it

Expected behavior
Deploy successfully

Screenshots
Screenshot 2023-10-25 at 16 38 17

Desktop (please complete the following information):

  • OS: [e.g. Windows]
  • NodeJS Version [e.g. 18.16.0]

Additional context
Add any other context about the problem here.

api docker container not starting

/usr/bin/env: 'bash\r': No such file or directory
"pm ERR! Missing script: "start:prod
npm ERR!
npm ERR! Did you mean this?
npm ERR! npm run start:prod # run the "start:prod" package script
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-07-26T17_59_15_319Z-debug-0.log

Nest API service not able to connect Postgres using docker compose

I have used the master branch, where I set DATABASE_HOST=localhost as specified from the instructions.
After I run docker-compose up -d,
All other docker services are running except API service is having issue connecting postgres database.
Screenshot from 2022-02-17 14-16-44

What could be the possible fixes?

Cannot get value.__entity === "User" in serializer.interceptor.ts file

Thank you for the great project.I refer to this repository for learning.
The password was not hidden in the response when the user creation was completed.
I investigated the cause and it seems that __entity was not retrieved in the following if minutes.

map((data) => {
    return deepMapObject(data, (value) => {
      if (value.__entity === 'User') {
        userResponseSerializer(value as User);
      }
      return value;
    });
}),

Also, the following code was working.

map((data) => {
    return deepMapObject(data, (value) => {
      if (value.constructor.name === 'User') {
        userResponseSerializer(value as User);
      }
      return value;
    });
}),

I apologize if I am wrong.

No logger is set up

An important part of any new project is having a good logging system set up from the very first beginning.
Taking into consideration the current best practices, could you please add a nice logging system to the boilerplate?

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.