Related
I have a nestjs module called AuthModule
import { Module } from '#nestjs/common';
import { AuthService } from './auth.service';
import { TypeOrmModule } from '#nestjs/typeorm';
import { UsersEntity } from './user-auth-credentials.entity';
import { UsersRepository } from './users.repository';
import { AuthController } from './auth.controller';
#Module({
imports: [TypeOrmModule.forFeature([UsersRepository])],
controllers: [AuthController],
providers: [AuthService],
})
export class AuthModule {}
a controller called **AuthController**.
import { Controller, Get } from '#nestjs/common';
import { AuthService } from './auth.service';
#Controller('auth')
export class AuthController {
constructor(private authService: AuthService) {}
#Get()
findAll() {
return 'Hello World';
}
}
The methods in the controller findAll as an example are not being mapped during compiling as shown by the output of npm run start:dev below.
[12:36:39] File change detected. Starting incremental compilation...
[12:36:39] Found 0 errors. Watching for file changes.
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [NestFactory] Starting Nest application...
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] TypeOrmModule dependencies initialized +122ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] AppModule dependencies initialized +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] TypeOrmCoreModule dependencies initialized +73ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] AuthModule dependencies initialized +0ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [InstanceLoader] TeachersModule dependencies initialized +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RoutesResolver] AppController {/}: +7ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RouterExplorer] Mapped {/, GET} route +4ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RoutesResolver] TeachersController {/teachers}: +0ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RouterExplorer] Mapped {/teachers, GET} route +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RouterExplorer] Mapped {/teachers/id, GET} route +2ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RouterExplorer] Mapped {/teachers, POST} route +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RouterExplorer] Mapped {/teachers/id, PATCH} route +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RouterExplorer] Mapped {/teachers/id, DELETE} route +1ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [RoutesResolver] AuthController {/auth}: +0ms
[Nest] 4262 - 09/03/2022, 12:36:40 LOG [NestApplication] Nest application successfully started +4ms
When I access the route using Insomnia i get this
output of Insomnia
Is there something Im not doing right?
your code looks fine but the output didn't show any Mapped {/auth, GET}. I'd say that you're probably running an old version of the your code (which doesn't have that findAll method)
Try rm -rf dist and start it again.
I'am trying to deploy my NestJs application on an EC2 instance.
I cloned my project and installed all dependencies but then when I tried to start the app, it can't initialize all dependencies (can't even reach TypeOrmCoreModule dependencies).
I have no errors.
[Nest] 117257 - 09/27/2021, 1:14 AM [NestFactory] Starting Nest application...
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] TypeOrmModule dependencies initialized +176ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] PassportModule dependencies initialized +0ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] NeconfigModule dependencies initialized +1ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] JwtModule dependencies initialized +0ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] CommentsModule dependencies initialized +0ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] MsPostsModule dependencies initialized +1ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] PostCommentsModule dependencies initialized +0ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] ConfigHostModule dependencies initialized +1ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] ConfigModule dependencies initialized +11ms
[Nest] 117257 - 09/27/2021, 1:14 AM [InstanceLoader] AppModule dependencies initialized +1ms
I my local machine the Nest application is successfully started.
[Nest] 15660 - 27/09/2021, 03:10:58 [NestFactory] Starting Nest application...
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +112ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] PassportModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] NeconfigModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] JwtModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] CommentsModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] MsPostsModule dependencies initialized +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] PostCommentsModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] ConfigHostModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] ConfigModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmCoreModule dependencies initialized +236ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] NotificationModule dependencies initialized +16ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] PostContentModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] FollowersTsModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] FavorisModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] PostModule dependencies initialized +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] AccountModule dependencies initialized +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [InstanceLoader] UsersModule dependencies initialized +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] AppController {/}: +8ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/facebook, GET} route +3ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/facebook/redirect, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/authorize_user, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/handleauth, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/handleauthcode, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/google, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/google/redirect, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] UsersController {/users}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/createUser, POST} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/:id, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/search/:email, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/:id, PUT} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/:id, DELETE} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/login, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/confirm/:id, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/resetPassword, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/changePassword/:id, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/follow, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/unfollow, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/inst, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/googlelogin, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/facebooklogin, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/testTypeCnx/:id, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] NotificationController {/notification}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/addNotif, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getNotif, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] CommentsController {/comments}: +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] MsPostsController {/ms-posts}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] AccountController {/account}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/createOneAccount, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getAllUser, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getUserByName/:userName, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/UpdateUser/:userName, PUT} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/DeleteByUsername/:userName, DELETE} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/addFromxlsx, POST} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/showAllUsername, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getBestAccountLastMonth, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getBestAccountLastYear, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getRankAccountLastWeek, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getBestAccountByDay, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getRank/:starName/:dateTest, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getFollowersByDay/:userName, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getFollowersByMonth/:starName, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getFollowersByweek/:starName, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/compare/:starName1/:starName2, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/createData/:starName/:fieldScrape/:countryScrape, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] PostController {/post}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/allPosts, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/country, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/username/:userName/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/Rankingpermonth/:month/:year/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/:userName/Rankingpermonth/:month/:year/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/maxMonth, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/avgLikesMonth, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/avgCommentMonth, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/RankingLastweek/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/:userName/RankingLastweek/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/Rankingperyear/:year/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/:userName/Rankingperyear/:year/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/totalYear, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/maxYear, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/likesYear/:year/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/likesMonth/:year/:month/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/likesAllTimes/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/celeblikesAllTimes/:userName/:skip, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/celeblikesByMonth/:userName/:year/:month, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/celeblikesByYear/:userName/:year/:skip, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/avgCommentYear, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/maxCommentYear, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] PostContentController {/postContent}: +0ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/postId, GET} route +3ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] PostCommentsController {/post-comments}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] FavorisController {/favoris}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/addFavoris/:idUser, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getAllFavoris/:idUser, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/addFavorisToAccount/:idUser/:starName, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/checkFavorit/:idUser/:starName, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/FavorisByYear/:idUser, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/FavorisByMonth/:idUser, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/FavorisByDay/:idUser, GET} route +3ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/fovorisAll/:idUser, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/deleteFavoris/:idUser/:starName, DELETE} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/FavorisByWeek/:idUser, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RoutesResolver] FollowersTsController {/followers-ts}: +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/insertDataToDataBase/:username, POST} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getAllData/:starName, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getDataofSpecificDate/:starName, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getAccountLastYear, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getAccountLastMonth, GET} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/getAccountLastWeek, GET} route +2ms
[Nest] 15660 - 27/09/2021, 03:10:58 [RouterExplorer] Mapped {/scrappingInsta/:starName/:fieldScrape/:countryScrape, POST} route +1ms
[Nest] 15660 - 27/09/2021, 03:10:58 [NestApplication] Nest application successfully started +9ms
And this is my main.ts file
import { NestFactory } from '#nestjs/core';
import { AppModule } from './app.module';
import * as dotenv from "dotenv";
import * as http from 'http';
import * as express from 'express';
const fs = require('fs');
dotenv.config();
async function bootstrap() {
const server = express();
const app = await NestFactory.create(
AppModule,
);
app.enableCors({
"origin": "*",
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"allowedHeaders" : ['Content-Type']
});
await app.init();
http.createServer(server).listen(3005);
}
bootstrap();
I can't figure out why the app can't be started successfully in the ec2 instance.
I'm trying to use the #ssut/nestjs-sqs library to communicate to AWS SQS queues from a Node/NestJS application. I'm new to NestJS and using AWS SQS queues. I can consume messages, but I can't send them. I've got an AppService pretty much identical to the example in the repository READEM, but it keeps failing:
export class AppService {
public constructor(private readonly sqsService: SqsService) {}
getHello(): string {
return 'Hello World YouTube';
}
public async sendMessage(message) {
const id = String(Math.floor(Math.random() * 1000000));
await this.sqsService.send(TestQueue.Test, {
id,
body: { test: true },
groupId: 'test',
deduplicationId: id,
delaySeconds: 0,
});
}
}
When I run the app and try to send a message (through a POST call also handled by this app) I get these messages:
[Nest] 22049 - 05/27/2021, 6:27:22 PM [NestFactory] Starting Nest application...
[Nest] 22049 - 05/27/2021, 6:27:22 PM [InstanceLoader] HttpModule dependencies initialized +25ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [InstanceLoader] DiscoveryModule dependencies initialized +0ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [InstanceLoader] SqsModule dependencies initialized +0ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [InstanceLoader] AppModule dependencies initialized +1ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RoutesResolver] AppController {}: +5ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RouterExplorer] Mapped {, GET} route +3ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RoutesResolver] SpaceController {/space}: +1ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RouterExplorer] Mapped {/space, GET} route +0ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RoutesResolver] MessagesController {/messages}: +1ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RouterExplorer] Mapped {/messages, GET} route +0ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [RouterExplorer] Mapped {/messages, POST} route +1ms
[Nest] 22049 - 05/27/2021, 6:27:22 PM [NestApplication] Nest application successfully started +35ms
[Nest] 22049 - 05/27/2021, 6:27:26 PM [ExceptionsHandler] Failed to send messages: 742884 +4328ms
Error: Failed to send messages: 742884
at Producer.sendBatch (/Users/dougfarrell/tmp/sqs-handler/node_modules/sqs-producer/dist/producer.js:56:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async AppService.sendMessage (/Users/dougfarrell/tmp/sqs-handler/dist/app.service.js:25:9)
at async /Users/dougfarrell/tmp/sqs-handler/node_modules/#nestjs/core/router/router-execution-context.js:46:28
at async /Users/dougfarrell/tmp/sqs-handler/node_modules/#nestjs/core/router/router-proxy.js:9:17
How can I resolve this error?
I resolved this myself by debugging into the send message code and getting the AWS error code. The problem is the example code shown for the ssut#nestjs-sqs module to send a message is for an FIFO queue. If you're using a standard queue the queueuId and deduplicationId values in the message will cause the error. Remove those and it worked fine.
We are deploying node microservices for the first time in AWS ECS and each services are listening on dynamic ports.
The following are the APIs of the microservices exposing while starting the node application.
ANIMAL MicroService
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/animal/:id, GET} route +2ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/animal/getAll, GET} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/animal, POST} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/animal/:id, PUT} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/animal/:id, DELETE} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RoutesResolver] dogPlanController {/dog}: +0ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/dog/:id, GET} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/dog, POST} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/dog/:id, DELETE} route +1ms
Bird MicroService
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/bird/:id, GET} route +2ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/bird/getAll, GET} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/bird, POST} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/bird/:id, PUT} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/bird/:id, DELETE} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RoutesResolver] eaglePlanController {/eagle}: +0ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/eagle/:id, GET} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/eagle, POST} route +1ms
[Nest] 29 - 12/22/2020, 8:12:30 AM [RouterExplorer] Mapped {/eagle/:id, DELETE} route +1ms
Users MicroService
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/healthcheck, GET} route +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RoutesResolver] SsoController {/sso}: +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/sso, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RoutesResolver] AuthController {/auth}: +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/signup, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/sendotp, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/verifyOtp, POST} route +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/login, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/duplicateUserName, GET} route +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/resetPasswordOtp, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/auth/resetPassword, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RoutesResolver] UserController {/user}: +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user/questionnaire/:id, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user/questionnaire/:id, GET} route +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user/:id, GET} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user, GET} route +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user/userList, POST} route +1ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user/connectWearable, POST} route +0ms
[Nest] 28 - 12/21/2020, 11:29:32 PM [RouterExplorer] Mapped {/user/getArticles, POST} route +1ms
Backend MicroService
[Nest] 29 - 12/22/2020, 12:02:28 AM [RoutesResolver] AuthController {/auth}: +1ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/auth/signup, POST} route +0ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/auth/login, POST} route +1ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RoutesResolver] animalController {/animal}: +0ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/animal/color, GET} route +1ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/animal/color, POST} route +0ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/animal, GET} route +1ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/animal, POST} route +1ms
[Nest] 29 - 12/22/2020, 12:02:28 AM [RouterExplorer] Mapped {/animal/:id, DELETE} route +0ms
..
..
..
..
Developers are expecting the following routing.
Note: carefully observe the routing they are requesting.
For ANIMAL MicroServices,
example.com/animal -->> animal-microservice-url/animal
example.com/animal/dog -->> animal-microservice-url/dog
For USER MicroServices,
example.com/user -->> user-microservice-url/user
example.com/user/auth -->> user-microservice-url/auth
example.com/user/sso -->> user-microservice-url/sso
Can someone help me to achieve this in AWS environment.?
I tried ALB path based routing which wasn't fruitful given the scenario as ALB doesn't strip off the postfixes in alburl.
I have also tried API Gateway with ALB. I setup few ALB path based routes such that it can accept requests from apigateway & forward them to target groups.
However, I'm experiencing trouble while setting `wildcard, *, in ALB path based routing' alike in APIGateway to route all postfixes to one url.
example:
apigatewayurl.com/animal -->> alburl.com/animal
apigatewayurl.com/animal/dog -->> alburl.com/dog
The above two are working fine.
But the following are not.
apigatewayurl.com/animal/:id -->> alburl.com/animal/:id
apigatewayurl.com/animal/getAll -->> alburl.com/animal/getAll
apigatewayurl.com/animal/dog/:id -->> alburl.com/dog/:id
How can I create an HTTP API route such that it access all the postfixes in alburl from apigatewayurl?
Like, when I enter apigatewayurl.com/animal/dog/* -->> alburl.com/dog/*
I tried present the issue as possible as I can.
Please feel free to ask about configuration.
If this can be done via any other service in AWS, please suggest me here.
I don't think its possible. because here ALB just checks path, it just verifies whether given path is equal to the one mention there , it cant accept values.. You are sending values in URL.
My suggestion is that - send id or your data values in body of your request ,instead sending those in request URL. and catch those value in your API
I don't see any status or console messages in the IDE console while trying to hit any end-point. I do see the response getting returned but no call details in the console. I am confused as why is it behaving this way?
Following is what I see on running npm run-script start:dev -
> nest start --watch
[3:04:44 PM] Starting compilation in watch mode...
[Nest] 14340 - 05/20/2020, 3:10:58 PM [NestFactory] Starting Nest application...
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] TypeOrmModule dependencies initialized +220ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] TypeOrmCoreModule dependencies initialized +195ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] TypeOrmModule dependencies initialized +6ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [InstanceLoader] AppModule dependencies initialized +5ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RoutesResolver] AppController {}: +13ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {, GET} route +4ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RoutesResolver] BatchController {/batch}: +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/batch, POST} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/batch, GET} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/batch/:batch, GET} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/batch/:batch, DELETE} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RoutesResolver] StudentController {/student}: +0ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/student, POST} route +2ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/student, GET} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/student/:id, GET} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:58 PM [RouterExplorer] Mapped {/student/:id, DELETE} route +2ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RoutesResolver] AssignmentController {/assignment}: +1ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RouterExplorer] Mapped {/assignment, POST} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RouterExplorer] Mapped {/assignment, GET} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RouterExplorer] Mapped {/assignment/:id, GET} route +2ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RouterExplorer] Mapped {/assignment/:id, DELETE} route +1ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RoutesResolver] UploadController {/upload}: +1ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [RouterExplorer] Mapped {/upload, POST} route +2ms
[Nest] 14340 - 05/20/2020, 3:10:59 PM [NestApplication] Nest application successfully started +3ms
When I hit http://localhost:3000/batch, I see the response but the console above doesn't display anything like API type GET or status 200 etc.
This is what I have in controller -
import {
Controller,
Get,
Post,
Body,
Param,
Delete,
Logger,
} from '#nestjs/common';
import { BatchService } from './batch.service';
import { Batch } from './batch.entity';
import { InsertResult } from 'typeorm';
#Controller('batch')
export class BatchController {
private readonly logger = new Logger(BatchController.name);
constructor(private batchService: BatchService) {}
#Post()
create(#Body() batchDto: Batch): Promise<InsertResult> {
this.logger.log(':: BatchController :: create()');
console.log(':: BatchController :: create()');
return this.batchService.create(batchDto);
}
#Get()
findAll(): Promise<Batch[]> {
this.logger.log(':: BatchController :: findAll()');
console.log(':: BatchController :: findAll()');
return this.batchService.findAll();
}
#Get(':batch')
findOne(#Param('batch') batchName): Promise<Batch> {
this.logger.log(':: BatchController :: findOne()');
console.log(':: BatchController :: findOne()');
return this.batchService.findOne(batchName);
}
#Delete(':batch')
remove(#Param('batch') batchName) {
this.logger.log(':: BatchController :: remove()');
console.log(':: BatchController :: remove()');
return this.batchService.remove(batchName);
}
}
Put the console and logger both as to see if anything works.
It seems like you have the logs disabled for your NestJS Application.
The best and simple way to enable NestJS request logging is to use its built-in logger service.
To do that, you can pass an array of LogLevels when bootstrapping a NestJS Application.
In your main.ts OR wherever you are bootstrapping the Nest app,
const app = await NestFactory.create<NestExpressApplication>(AppModule, new ExpressAdapter(), {
cors: true,
logger: ['error', 'warn', 'log'] // <--- Add this line in options object
});
Here, pass an array of LogLevels in options.logger.
As of now, LogLevel type has these applicable values:
declare type LogLevel = 'log' | 'error' | 'warn' | 'debug' | 'verbose';
(code snippet taken from #nestjs/common)
Now run the project again and it should print request logs in console.
Almost sure that there are some host settings that prevent the normal behavior. I will contact my hosting provider to understand it, but how did i get to that information:
My NestJS app stopped to send emails. I implemented Logger from NestJS tutorial - No output.
I have added console.log/error - no output
I have removed all my app files from host and left only 1 app.js file with a simple code snippet:
const http = require("http");
const port = 80;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
res.end("Hello World");
});
server.listen(port, () => {
console.log("I WILL BE LOGGED1?");
process.stdout.write("I WILL BE LOGGED2?");
process.stderr.write("I WILL BE LOGGED3?");
});
And noticed that only "process.stderr.write" gets logged no matter what you do. So currently i'm using only that piece of code to log info.
I was not able to get either console.log nor this.logger.log to work. After some sanity checking, it appeared to be a cacheing issue.
In my case the solution was much simpler. I had to:
delete the /dist folder and
re-run npm run start:dev
Both console.log(...) and this.logger.log(...) instance I setup began working.