Code Monkey home page Code Monkey logo

azure-func-http's People

Contributors

caucik avatar dependabot[bot] avatar jefiozie avatar kamilmysliwiec avatar manekinekko avatar marsonya avatar newbish avatar renovate-bot avatar renovate[bot] avatar sinedied avatar tony133 avatar wodcz avatar yashmurty 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

azure-func-http's Issues

Project dependencies

Is there a reason this project has the following as hard dependencies?

  • @angular-devkit/schematics
  • @schematics/angular
  • @types/jest
  • jest
  • ts-jest

Could you make them dev dependencies instead?

azure function + nest js + Graphql

use nest js graphql app in an azure function

The function is started, the submitted post is received in the function, but no response is sent to the client.

Socket.io not working

I'm submitting a...


[ ] Bug report

Current behavior

I have an Ionic project and a NestJs project integrated with azure-func-http. I am also using socket.io to make realtime communication between them. But socket.io is not working. Its working with the default NestJs project but not with the azure-func-http.
When I run locally I face:

Access to XMLHttpRequest at 'http://localhost:7071/socket.io/?EIO=3&transport=polling&t=N6eYJqK' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

When I run with the deployed one(deployed to Azure function with service plan where Websocket is turned on) I face:

GET https://my-nestjs-deployed-url/socket.io/?EIO=3&transport=polling&t=N6eYhXI 404 (Not Found)

I have tried to add the path and many other solutions. Nothing is working.

Expected behavior

Communication via socket.io should be working

Minimal reproduction of the problem with instructions

Here are the repositories where you can reproduce the issue:
Frontend Ionic project: https://github.com/ahsanhabib23/ionic-azurefunction-socketio-testing
Backend NestJs project: https://github.com/ahsanhabib23/nestjs-azurefunction-socketio-testing

Environment


Nest info:

[System Information]
OS Version     : macOS Catalina
NodeJS Version : v12.16.1
NPM Version    : 6.14.4 

[Nest CLI]
Nest CLI Version : 7.1.2 

[Nest Platform Information]
platform-socket.io version : 7.0.8
platform-express version   : 7.0.0
azure-func-http version    : 0.5.0
websockets version         : 7.0.8
common version             : 7.0.0
core version               : 7.0.0


Ionic Info:

Ionic:

   Ionic CLI                     : 6.6.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.0.7
   @angular-devkit/build-angular : 0.803.26
   @angular-devkit/schematics    : 8.3.26
   @angular/cli                  : 8.3.26
   @ionic/angular-toolkit        : 2.2.0

Utility:

   cordova-res (update available: 0.13.0) : 0.9.0
   native-run (update available: 1.0.0)   : 0.3.0

System:

   NodeJS : v12.16.1 (/usr/local/bin/node)
   npm    : 6.14.4
   OS     : macOS Catalina

AzureHttpRouter constructor throws an exception

Hi Nest.js team! I'm running into the following issue while using this package. Thanks in advance for your help! I'm really loving nest.js so far and really looking forward to getting my project working on an azure function app!

I'm submitting a...

[ ] Regression
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior

AzureHttpRouter constructor is throwing an exception:

[2022-11-15T15:44:11.885Z] Executing HTTP request: {
[2022-11-15T15:44:11.885Z]   requestId: "da9a6aa2-4bcc-42a2-8f2d-f3969f01ecf4",
[2022-11-15T15:44:11.885Z]   method: "GET",
[2022-11-15T15:44:11.886Z]   userAgent: "PostmanRuntime/7.28.4",
[2022-11-15T15:44:11.886Z]   uri: "/"
[2022-11-15T15:44:11.886Z] }
[2022-11-15T15:44:11.973Z] Executing 'Functions.main' (Reason='This function was programmatically called via the host APIs.', Id=12eac574-6fe4-49dd-baee-619866eb4be0)
[2022-11-15T15:44:12.006Z] Received FunctionInvocationRequest
[2022-11-15T15:44:12.006Z] (node:1922) UnhandledPromiseRejectionWarning: TypeError: trouter_1.default is not a constructor
[2022-11-15T15:44:12.006Z]     at new AzureHttpRouter (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/node_modules/@nestjs/azure-func-http/dist/router/azure-http.router.js:12:15)
[2022-11-15T15:44:12.006Z]     at createApp (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/dist/src/main.azure.js:8:73)
[2022-11-15T15:44:12.006Z]     at AzureHttpAdapterStatic.<anonymous> (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/node_modules/@nestjs/azure-func-http/dist/azure-http.adapter.js:24:31)
[2022-11-15T15:44:12.006Z]     at Generator.next (<anonymous>)
[2022-11-15T15:44:12.006Z]     at /Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/node_modules/@nestjs/azure-func-http/dist/azure-http.adapter.js:8:71
[2022-11-15T15:44:12.006Z]     at new Promise (<anonymous>)
[2022-11-15T15:44:12.006Z]     at __awaiter (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/node_modules/@nestjs/azure-func-http/dist/azure-http.adapter.js:4:12)
[2022-11-15T15:44:12.006Z]     at AzureHttpAdapterStatic.createHandler (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/node_modules/@nestjs/azure-func-http/dist/azure-http.adapter.js:23:16)
[2022-11-15T15:44:12.006Z]     at AzureHttpAdapterStatic.handle (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/node_modules/@nestjs/azure-func-http/dist/azure-http.adapter.js:20:14)
[2022-11-15T15:44:12.006Z]     at Object.run (/Users/siddharthkapoor/Desktop/projects/OdapCloud/odap/dist/main/index.js:7:40)

I added dded @nestjs/azure-func-http to my project via nest cli. Added the AzureHttpRouter constructor into main.azure.ts as per documentation:

export async function createApp(): Promise<INestApplication> {
  const app = await NestFactory.create(AppModule, new AzureHttpRouter());
  // app.setGlobalPrefix('api');

  await app.init();
  return app;
}

Everything works fine if I don't use the AzureHttpRouter (i.e. using express instead), but I would like to be able to use it for faster routing.

I dug into the package, and observed the following code in dist/router/azure-http.router.ts

// at line 8
const trouter_1 = require("trouter");
const adapter_1 = require("../adapter");
class AzureHttpRouter extends core_1.AbstractHttpAdapter {
    constructor() {
        super(new trouter_1.default()); // <-- this is where the exception occurs
        this.routerMethodFactory = new router_method_factory_1.RouterMethodFactory();
    }

Everything works as expected if I change the above code as follows:

const trouter_1 = require("trouter");
const adapter_1 = require("../adapter");
class AzureHttpRouter extends core_1.AbstractHttpAdapter {
    constructor() {
        super(new trouter_1()); // <-- just removed default
        this.routerMethodFactory = new router_method_factory_1.RouterMethodFactory();
    }

Expected behavior

new AzureHttpRouter() should not throw exception.

Minimal reproduction of the problem with instructions

  1. With a matching environment as below, install nestjs/cli@8 (since 9 does not work with azure functions yet)
  2. create a new nest project
  3. add nestjs/azure-func-http
  4. Build with npm run build
  5. Serve with func host start --verbose

I experienced some issues at this point. Dist folder showed a single compiled main.js file, and the func logging complained that the scriptFile was not found. So I had to set the webpack config in nest-cli.json off (to get the dist/main/index.js file specified in the auto-generated main/function.json file) to get things working.

  1. Add the AzureHttpRouter constructor in main.azure.ts as show above

Environment

  • nest version: 8.2.8
  • nest/azure-func-http version: 0.8.0
  • node version: 14.18.2
  • npm version: 6.14.15
  • azure core func tools version: 4.0.4865
  • platform: macbook pro m1

enable server side event support

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

server returns the response once.
Screenshot 2023-09-05 at 10 45 34

Expected behavior

Server should return data timely

Screenshot 2023-09-05 at 10 46 16

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version:10.1.16 

 
For Tooling issues:
- Node version: v18.16.0 
- Platform:  Mac 

Others:

AzureHttpRouter not working with query params

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When enabling AzureHttpRouter with const app = await NestFactory.create(AppModule, new AzureHttpRouter());, all requests with a query param fail with a 404.

Expected behavior

Same behavior as when using express router.

Minimal reproduction of the problem with instructions

  1. nest new bug
  2. nest add @nestjs/azure-func-http
  3. replace in main.azure.ts const app = await NestFactory.create(AppModule, new AzureHttpRouter());
  4. npm run start:azure
  5. curl http://localhost:7071/api/?test=1 fail, while curl http://localhost:7071/api/ works

What is the motivation / use case for changing the behavior?

Using routes with query params.

Environment


Nest version: 6.12.2

 
For Tooling issues:
- Node version: 12.13.0
- Platform: Mac

Others:

Response Headers are Not Matching the NEST Response when publish to Azure Function

I'm submitting a question/issue regarding the response headers that are not preserved when we run the nest application on azure function. If we run the Nest app only the response headers are preserved.


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When we send a response on an endpoint we expect to receive the content-type: application/json when running the application as azure function but we are not receiving the content-type.

Expected behavior

Preserve the header content-type sent by nest app.

Minimal reproduction of the problem with instructions

Create a nest app install the azure-func-http and send a response as JSON. Run the azure function app locally to see if the content-type: application/json are preserved.

What is the motivation / use case for changing the behavior?

Preserve headers sent by NEST App.

Environment


Nest version: 8.0.0

 
For Tooling issues:
- Node version: 14  
- Platform:  Mac and Windows

Others:
Visual Code Studio

Could not resolve dependency with @nestjs/common 9.0.0

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current Behavior

nest add @nestjs/azure-func-http fails with the following messages

Failed to execute command: npm install --save @nestjs/azure-func-http@latest

Unable to install library @nestjs/azure-func-http because package did not install. Please check package name.

When I try npm install --save @nestjs/azure-func@latest myself it gives more information. Viz

ERESOLVE unable to resolve dependency tree

While resolving: [email protected]
Found: @nestjs/[email protected]
node_modules/@nestjs/common
  @nestjs/common@"^9.0.0" from the root project

Could not resolve dependency:
peer @nestjs/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @nestjs/[email protected]
node_modules/@nestjs/azure-func-http
  @nestjs/azure-func-http@"0.8.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Expected Behavior

The command should add the documented azure-func-http capabilities

Minimal reproduction of the problem with instructions

npm uninstall @nestjs/cli -g
npm install @nestjs/cli -g
nest n fapp
cd fapp
nest add @nestjs/azure-func-http

What is the motivation / use case for changing the behavior?

I am experimenting with an azure function for my api and wanted to use the features I read about with this plugin

Environment


Nest version: 9.0.0

 
For Tooling issues:
- Node version: 18.7.0  
- Platform:  Windows 11 

Others:

npm: 8.16.1

Make nest openapi impl better with azurefx

I'm submitting a help request.


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

using the swagger module with azure fx (express) requires several things be in sync:

  1. Port of azure fx and app.listen must be in sync.
  2. Use swagger module global Prefix option must be true if using global prefix.
  3. Set basepath option must be equal to .setup(, ...
  4. Not doing these 3 things will never load all the js required by swagger page when using nestjs with azurefx.

Expected behavior

app.init seems to be 100% required to work.
app.listen seems to be essential to getting swagger to work on the same port. Please encapsulate this behavior.

Minimal reproduction of the problem with instructions

[]1. (https://trilon.io/blog/deploy-nestjs-azure-functions)
2. then add your openapi module and configure it.

What is the motivation / use case for changing the behavior?

do more with less.

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

exclude path not working in Azure function

I'm submitting a...


[ ] Regression 
[v ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

npm start:azure is not working
mpm start:dev is well

Expected behavior

We are testing Azure Function
we made Middleware and some url exclude
but it is not working

same issue reported
https://stackoverflow.com/questions/69198570/nestjs-middlewareconsumer-exclude-path-not-working-in-azure-function

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 8.0.0

 
For Tooling issues:
- Node version: 8.4.1  
- Platform:  Mac, Linux

Others:

Documentation lacking around using context object to build custom logger module

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

No documentation surrounding use of azure context which is greatly needed for setting up logging for azure functions

Expected behavior

Would love to see an example LoggerModule that can be used locally (default to console.log) or with azure func context (context.log)

What is the motivation / use case for changing the behavior?

Documentation surrounding this repository is very minimal, and outdated

MonoRepo Support

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

if in a nestjs monorepo I run the nest add @nestjs/azure-func-http it asks for destination project and creates a azure function for it but if you run in twice it overrides the existing azure function to use the new project

Expected behavior

running nest add @nestjs/azure-func-http and selecting different projects should create multiple azure functions

Minimal reproduction of the problem with instructions

nest new demo
cd demo
nest generate app models
nest add @nestjs/azure-func-http (select demo project)
nest add @nestjs/azure-func-http (select models project)

What is the motivation / use case for changing the behavior?

I'd like to use one repo for multiple azure functions

Environment


Nest version: 8.2.8

 
For Tooling issues:
- Node version: 16  
- Platform: Mac 

Others:

AzureHttpRouter does not implement 'getRequestHostname'; breaks `nest build`

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

The @nestjs\azure-func-http\dist\router\azure-http.router.d.ts type definition is missing the getRequestHostname function declared in AbstractHttpAdapter. It is however, present in lib/router/azure-http.router.ts. If I manually add it, it all builds and runs just fine.

I'm thinking a build/publish might have gone wrong?

Environment


Nest version: 6.10.14

 
For Tooling issues:
- Node version: v12.14.1 
- Platform: Windows  

Others:

- @nestjs/azure-func-http version: 0.4.1
 (also present in 0.4.0, 0.3.2, haven't tested further back as the property didn't exist back then in AbstractHttpAdapter)

Schematics fail without install dependencies

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Schematics fail. You need to install manually npm i @nestjs/azure-func-http and then add schematics with nest add @nestjs/azure-func-http.

Expected behavior

Automatically install necessary dependencies.

Minimal reproduction of the problem with instructions

nest add @nestjs/azure-func-http

What is the motivation / use case for changing the behavior?

Comodity

Environment


Nest version: 7.0.0

 
For Tooling issues:
- Node version: 12.18.3  
- Platform:  Linux 

Others:

Thanks for your work,

Cronjobs support

I'm submitting a...

[x] Bug report
OR
[x] Feature request

Current behavior

Cronjobs not working when using Azure Functions start:azure, but working when using only nest start

Expected behavior

Cronjobs working in both scenarios.

Example

  import { Cron, CronExpression } from '@nestjs/schedule';

  @Cron(CronExpression.EVERY_SECOND)
  async myCronjob() {
    console.log('do something')
  }

For Tooling issues:

  • Node version:18
  • Platform: Windows & Linux

Others:
Thank you for developing this <3

class-validator is not working

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Running with azure-func-http the class-validator module is not working, that is the request are not validated.

Expected behavior

As same as the express nest module the request must be validated when i use class-validator module.

Minimal reproduction of the problem with instructions

The following class is defined:

export class TestProductIdQueryDto {
  @IsDefined()
  @IsEnum(AtarProductId)
  @ApiProperty({
    enum: TestProductId,
  })
  productId: keyof typeof TestProductId;
}

When the request is made without productId on query should return a bad request.

What is the motivation / use case for changing the behavior?

I think class-validator is a good feature witch I can not use because when I add azure-func-http it's becomes incompatible.

Environment


Nest version: 8.0.0

 
For Tooling issues:
- Node version: 14.17.5
- Platform:  Mac

Others:

- Azure func: 3.0.3904
- @nestjs/azure-func-http: 0.8.0
- class-validator: 0.13.2,

Error: Could not read package.json - Monorepo Project

I'm submitting a...


[ ] Regression 
[*] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I try to install NestJS Azure functions schematics to any app in a monorepo created using the cli, I get the following error:

nestjsissue

Expected behavior

Should create main.azure.ts and other files as shown here.

Minimal reproduction of the problem with instructions

  • Generate a new project, select yarn as the package manager
    nest new my-app
  • Goto project root and convert it to a mono repo
    cd micro2
    nest generate app micro2
  • Add @nestjs/azure-func-http to any app
    cd apps\micro2
    nest add @nestjs/azure-func-http

What is the motivation / use case for changing the behavior?

Building and deploy multiple azure functions from a single monorepo.

Environment


Nest version: 6.7.2

 
For Tooling issues:
- Node version: 10.17.0  
- Platform:  Windows 

Others:

Is express only supported? Fastify?

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Response headers doesn't work

I'm submitting a...


[x] Bug report

Current behavior

Response headers are not sent back to the client.
The example below returns this response:


HTTP/1.1 200 OK
Date: Tue, 10 Nov 2020 12:39:58 GMT
Server: Kestrel
Content-Length: 12

Hello World!

Expected behavior

All response headers should be returned to the client.
From the example below the "Content-Type" and "MyHeader" header should have been returned from the REST api.

Minimal reproduction of the problem with instructions

Using this instruction:
https://trilon.io/blog/deploy-nestjs-azure-functions
Then adding two @Header() decorators to the api:


import { Controller, Get, Header } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @Header("Content-Type", "text/plain")
  @Header("MyHeader", "MyHeaderValue")
  getHello(): string {
    return this.appService.getHello();
  }
}

Environment


Nest version: 7.4.4
 
For Tooling issues:
- Node version: v12.18.0
- Platform:  Windows

Workaround

It seems like the writeHead(...) method is never called.
Triggering this method from IDE or through code (in an interceptor) solves the issue.

Build error when using example code

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Hi when I try to build my project using nest build I get this error:

node_modules/@nestjs/azure-func-http/dist/router/azure-http.router.d.ts:4:22 -
 error TS2515: Non-abstract class 'AzureHttpRouter' does not implement inherited abstract member 'getRequestHostname' from class 'AbstractHttpAdapter<any, any, any>'.

4 export declare class AzureHttpRouter extends AbstractHttpAdapter {
                       ~~~~~~~~~~~~~~~

Found 1 error(s).

the code is basically:

// index.ts
import { Context, HttpRequest } from '@azure/functions';
import { AzureHttpAdapter } from '@nestjs/azure-func-http';
import { createApp } from '../src/main.azure';

export default function(context: Context, req: HttpRequest): void {
  AzureHttpAdapter.handle(createApp, context, req);
}

// main.azure.ts
export async function createApp(): Promise<any> {
  const app = await NestFactory.create(AppModule, new AzureHttpRouter());
}

Expected behavior

I used to build ok, so I guess I had an old version installed, but I didn't see any other issues posted here so would love to know if its a bug or my configuration.

Minimal reproduction of the problem with instructions

Can provide if required

What is the motivation / use case for changing the behavior?

Currently cannot build the project

Environment


Nest version: v10.18.0
 
For Tooling issues:
- Node version: v10.18.0
- Platform:  macOs

Add compatibility with the @nestjs/fastify-adaptor

I'm submitting a...


[ ] Regression 
[ X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

I am not sure if this is a bug, or a feature request.

Current behavior

  1. git clone https://github.com/TrilonIO/nestjs-azure-functions - the azure func demo app.
  2. npm install --save @nestjs/platform-fastify
  3. npm install the rest.
  4. Swap the default express adaptor with the fastify one.
  5. Make sure you have Azure's func cli installed, then npm run build && func host start.
  6. Open a valid endpoint. In this case, the url logged when func host start has completed and the server is running.

Expected behavior

Fastify should have the same 200 success response as Express adaptor.

Minimal reproduction of the problem with instructions

See instructions above.

What is the motivation / use case for changing the behavior?

I'd like to use Fastify with Azure functions as it's lighter weight and faster.

Environment

MacOS Catalina
NodeJS: 12.16.3

NestJS common, core: 7.0.8
NestJS platform-fastify 7.0.11
@nestjs/azure-func-http: 0.5.0
@azure/functions: 1.0.3

Others:
npm
VSCode
zsh

Support "nest add" in monorepo

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Ref nestjs/nest-cli#415

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Peer dependencies allows @azure/functions v1 or v3 but not v2

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I've noticed that the peer dependencies are pinned to @azure/functions@^1.0.3 and @azure/functions@^3.0.0 but there's no support for @azure/functions@^2.0.0.

Expected behavior

As per the README of the @azure/functions package addressing versioning, v1 of the package is in maintenance mode, v2 supports Azure Function runtime v3 which is not EOL, and v3 supports Azure Function Runtime v4 which is relatively new. Pinning this dependency to v1 or v3 leaves out a large majority of people who are still on Azure Functions runtime v3. If you're still supporting v1, which is in maintenance mode, there should be no reason that @azure/functions@^2.0.0, still in general availability, isn't supported.

I propose a change to:

"peerDependencies": {
    "@azure/functions": "^1.0.3 || ^2.0.0 || ^3.0.0",
    ...
  },

Add sample usages, here with nest/graphql

I'm stuck with mixing nest/azure-func-http and nest/graphql


[ ] Regression 
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

part1 - nest add @nestjs/azure-func-http

npm run build && func host start

Works fine! Thank You :-)

part2 - https://github.com/nestjs/nest/tree/master/sample/23-type-graphql

Installed, works fine! :-)

part3 - use my graphql app in an azure function

The function is started, the submitted post is received in the function, but no response is sent to the client.
This seems to be a configuration problem.

Expected behavior

I will be happy if a sample app can be provided here or in nest/nest/sample.
Same feature requested by somebody, but no solution provided.

Minimal reproduction of the problem with instructions

Details can be found here:
https://spectrum.chat/nestjs/help/unable-to-start-nestjs-graphql-azure-functions~4cc66b5d-69cd-4e36-a4f8-20006b1a2155

Environment


Nest version: 6.10.1
 
For Tooling issues:
- Node version: v10.17.0
- Platform: Windows 10

API crash when static file hosting is enabled

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using this adapter and following this recipe: https://docs.nestjs.com/recipes/serve-static, the API crash when trying to serve a static file.

Expected behavior

Static file serving works as intended.

Minimal reproduction of the problem with instructions

  1. Create new nest project with this adapter
  2. Follow this recipe: https://docs.nestjs.com/recipes/serve-static
  3. Try to get a static file with curl -> exception

What is the motivation / use case for changing the behavior?

Allowing any regular use case valid for NestJS app.

Environment


Nest version: 6.12.2

 
For Tooling issues:
- Node version: 12.13.0
- Platform:  Mac

Others:

Work with Monorepo mode

I'm submitting a...

[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

On Monorepo project, I can't create multiple functions based on my apps.

Expected behavior

Ability to use azure-http-func on Monorepo Mode projects to create multiple functions.

Minimal reproduction of the problem with instructions

  1. Create a new NestJS project using CLI nest new my-project

  2. Create a Monorepo adding new app with nest g app my-app

  3. Add azure-http-func to the first app: nest add @nestjs/azure-func-http --rootDir apps/my-project/src.
    3.1. Select my-project project to add library to.

    At this point everything works fine.

  4. Try add azure-http-func to the second app: nest add @nestjs/azure-func-http --rootDir apps/my-app/src.
    4.1. Select my-app project to add library to.

We are presented the following error:

โฏ nest add @nestjs/azure-func-http --rootDir apps/my-app/src
โœ” Package installation in progress... โ˜•
? Which project would you like to add the library to? my-app
Starting library setup...
ERROR! .funcignore already exists.
ERROR! host.json already exists.
ERROR! local.settings.json already exists.
ERROR! proxies.json already exists.
ERROR! main/function.json already exists.
ERROR! main/index.ts already exists.
ERROR! main/sample.dat already exists.
The Schematic workflow failed. See above.

Failed to execute command: "/home/danilo/Projects/my-project/node_modules/.bin/schematics" @nestjs/azure-func-http:nest-add --sourceRoot="apps/my-app/src" --rootDir apps/my-app/src

What is the motivation / use case for changing the behavior?

I want to create a Monorepo with multiple apps and split my API into separated Azure Functions.

Environment

Nest version: 7.2.0
 
For Tooling issues:
- Node version: v12.17.0
- Platform: Linux

Possible to define function names for routes with decorator?

I'm submitting a...

[X] Feature request
[X] Documentation issue or request

Current behavior

The Azure Functions portal does not show any functions, it would be nice to have API routes here, for instance.
functions

Expected behavior

Have a decorator to mark controllers and methods or manually specify what should be defined, similar to how Swagger UI works.

Environment

  • Nest version: 6.1.1
  • Node version: v12.14.1
  • Platform: Linux

str.split is not a function?

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

If I use the cookie-parser middleware or if I try to enable cors, I get this error:

[20.04.2020 12:42:56] TypeError: str.split is not a function
[20.04.2020 12:42:56]     at module.exports (censored\api\node_modules\regexparam\dist\regexparam.js:3:53)
[20.04.2020 12:42:56]     at Trouter.use (censored\api\node_modules\trouter\index.js:21:27)
[20.04.2020 12:42:56]     at AzureHttpRouter.use (censored\api\node_modules\@nestjs\core\adapters\http-adapter.js:11:30)
[20.04.2020 12:42:56]     at AzureHttpRouter.enableCors (censored\api\node_modules\@nestjs\azure-func-http\dist\router\azure-http.router.js:39:14)
[20.04.2020 12:42:56]     at NestApplication.enableCors censored\api\node_modules\@nestjs\core\nest-application.js:136:26)
[20.04.2020 12:42:56]     at exceptions_zone_1.ExceptionsZone.run (censored\api\node_modules\@nestjs\core\nest-factory.js:111:40)
[20.04.2020 12:42:56]     at Function.run (censored\api\node_modules\@nestjs\core\errors\exceptions-zone.js:8:13)
[20.04.2020 12:42:56]     at Proxy.args (censored\api\node_modules\@nestjs\core\nest-factory.js:110:46)
[20.04.2020 12:42:56]     at createApp (censored\api\dist\src\app.fabric.js:13:9)
[20.04.2020 12:42:56]     at process._tickCallback (internal/process/next_tick.js:68:7)

Expected behavior

Should apply the middleware and enable cors. If I use express as router, it works.

Minimal reproduction of the problem with instructions

Minimal reproduction repository can be found here:
https://github.com/Syntarex/minimal-reproduction-str-split

Start with npm run start
Look in src/app.fabric.ts

Environment


Nest version: 7.0.7

 
For Tooling issues:
- Node version: 10.19.0
- Platform:  Windows 10

swagger-ui* not loading

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

We are currently using the same source for a local deployment (main.ts) and also an Azure deployment (main.azure.ts)
Swagger is working as expected with the installed node version (node dist/src/main.js) but is not working using the installed Azure Functions Core Tools (func host start --useHttps --cors * --verbose).
If is started using local azure functions files are not loaded as seen in the following image.

swagger_bug

Expected behavior

Should show the UI without problems as seen below:
swagger_working

Minimal reproduction of the problem with instructions

main.azure.ts (not working)

import { NestFactory, HttpAdapterHost } from '@nestjs/core';
import { INestApplication, RequestMethod } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import helmet from 'helmet';
import { AllExceptionsFilter } from './base/all-exceptions.filter';
import * as databases from './config/databases';
import { BackendHandshakeDto } from './globals/dto/backend-handshake-dto';
import { VersioningType } from '@nestjs/common';

export async function createApp(): Promise<INestApplication> {
  const handshake: BackendHandshakeDto = new BackendHandshakeDto();
  const app = await NestFactory.create(AppModule);
  app.use(helmet());
  app.enableCors();
  app.use((request, response, next) => {
    response.header('Access-Control-Allow-Origin', '*');
    response.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    response.header('Access-Control-Allow-Headers', 'Content-Type, Accept');
    next();
  });
  app.enableVersioning({
    defaultVersion: '1',
    type: VersioningType.URI,
  });

  app.setGlobalPrefix('api');

  const options = new DocumentBuilder()
    .setTitle('TUNNEL:Manager API')
    .setDescription(
      `API for TUNNEL:Manager App
      Supported database versions: ${databases.default.supportedVersions()}`,
    )
    .setVersion(handshake.backendVersion)
    .addBearerAuth()
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api-docs', app, document, { useGlobalPrefix: true });

  const { httpAdapter } = app.get(HttpAdapterHost);
  app.useGlobalFilters(
    new AllExceptionsFilter(httpAdapter, app.get('NestWinston')),
  );

  // app.setGlobalPrefix('api', {
  //   exclude: ['swagger'],
  // });

  await app.init();
  return app;
}

main.ts (working)

import { NestFactory, HttpAdapterHost } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import helmet from 'helmet';
import * as fs from 'fs';
import { config, DotenvConfigOutput } from 'dotenv';
import { AllExceptionsFilter } from './base/all-exceptions.filter';
import * as databases from './config/databases';
import { BackendHandshakeDto } from './globals/dto/backend-handshake-dto';
import { HttpsOptions } from '@nestjs/common/interfaces/external/https-options.interface';
import { VersioningType } from '@nestjs/common';

async function bootstrap() {
  // call dotenv-config to get .env values before nest app creation
  const configuration: DotenvConfigOutput = config();
  let httpsOptions: HttpsOptions = null;
  const httpsPrivateKeyPath = configuration.parsed.HTTPS_KEY_PATH;
  const httpsCertificatePath = configuration.parsed.HTTPS_CERT_PATH;
  if (httpsPrivateKeyPath && httpsCertificatePath) {
    httpsOptions = {
      key: fs.readFileSync(httpsPrivateKeyPath),
      cert: fs.readFileSync(httpsCertificatePath),
    };
  }
  const handshake: BackendHandshakeDto = new BackendHandshakeDto();
  const app = await NestFactory.create(AppModule, { httpsOptions });
  app.use(helmet());
  app.enableCors();
  app.use((request, response, next) => {
    response.header('Access-Control-Allow-Origin', '*');
    response.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    response.header('Access-Control-Allow-Headers', 'Content-Type, Accept');
    next();
  });
  app.enableVersioning({
    defaultVersion: '1',
    type: VersioningType.URI,
  });

  app.setGlobalPrefix('api');

  const options = new DocumentBuilder()
    .setTitle('TUNNEL:Manager API')
    .setDescription(
      `API for TUNNEL:Manager App
      Supported database versions: ${databases.default.supportedVersions()}`,
    )
    .setVersion(handshake.backendVersion)
    .addBearerAuth()
    .build();
  const document = SwaggerModule.createDocument(app, options, {
    //ignoreGlobalPrefix: false,
  });
  SwaggerModule.setup('api-docs', app, document, { useGlobalPrefix: true });

  const { httpAdapter } = app.get(HttpAdapterHost);
  app.useGlobalFilters(
    new AllExceptionsFilter(httpAdapter, app.get('NestWinston')),
  );

  await app.listen(process.env.SERVER_PORT || 3000);
}
bootstrap();

What is the motivation / use case for changing the behavior?

Environment


"dependencies": {
    "@nestjs/azure-func-http": "^0.8.0",
    "@nestjs/common": "^8.2.6",
    "@nestjs/core": "^8.2.6",
    "@nestjs/jwt": "^8.0.0",
    "@nestjs/passport": "^8.1.0",
    "@nestjs/platform-express": "^8.2.6",
    "@nestjs/swagger": "^5.2.1",
    "@nestjs/typeorm": "^8.0.3",
    "cache-manager": "^3.6.0",
    "co": "^4.6.0",
    "compare-versions": "^3.6.0",
    "helmet": "^5.0.2",
    "js-sha512": "^0.8.0",
    "markdown-it": "^12.3.2",
    "mo": "^1.7.3",
    "moment": "^2.29.1",
    "mssql": "^6.4.0",
    "nest-winston": "^1.6.2",
    "nestjs-config": "^1.4.10",
    "passport": "^0.5.2",
    "passport-jwt": "^4.0.0",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.5.2",
    "s": "^1.0.0",
    "swagger-ui-express": "^4.3.0",
    "typeorm": "^0.2.41",
    "winston": "^3.5.1"
  },
  "devDependencies": {
    "@azure/functions": "^1.2.3",
    "@nestjs/testing": "^8.2.6",
    "@types/express": "^4.17.13",
    "@types/jest": "^23.3.13",
    "@types/node": "12.12.43",
    "@types/readable-stream": "2.3.5",
    "@types/supertest": "^2.0.11",
    "jest": "^27.4.7",
    "nodemon": "^2.0.15",
    "prettier": "^2.5.1",
    "sqlite3": "^5.0.2",
    "supertest": "^3.4.1",
    "ts-jest": "^27.1.3",
    "ts-node": "^10.4.0",
    "tsconfig-paths": "^3.12.0",
    "tslint": "6.1.3",
    "typescript": "^4.5.5"
  },

Would be nice if somebody can help us with this issue. I guess its a weird configuration issue.
Thank you anyway and bye

Error: Option "rootDir" is not defined

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Iam trying to follow the example here https://trilon.io/blog/deploy-nestjs-azure-functions
for azure functions deployment, however I keep getting this error


$ nest add @nestjs/azure-func-http
โˆš Installation in progress... โ˜•
Error: Option "rootDir" is not defined.
    at C:\Users\hemed\Desktop\_coreteck\gray\pos-system-backend\node_modules\@angular-devkit\schematics\src\rules\template.js:85:27     
    at C:\Users\hemed\Desktop\_coreteck\gray\pos-system-backend\node_modules\@angular-devkit\schematics\src\rules\base.js:109:30        
    at C:\Users\hemed\.npm-global\node_modules\@nestjs\cli\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:233:13
    at C:\Users\hemed\.npm-global\node_modules\@nestjs\cli\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:41:59
    at Array.forEach ()
    at HostDirEntry.visit (C:\Users\hemed\.npm-global\node_modules\@nestjs\cli\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:41:43)
    at HostCreateTree.visit (C:\Users\hemed\.npm-global\node_modules\@nestjs\cli\node_modules\@angular-devkit\schematics\src\tree\host-tree.js:232:19)
    at C:\Users\hemed\Desktop\_coreteck\gray\pos-system-backend\node_modules\@angular-devkit\schematics\src\rules\base.js:105:14        
    at MergeMapSubscriber.project (C:\Users\hemed\Desktop\_coreteck\gray\pos-system-backend\node_modules\@angular-devkit\schematics\src\rules\call.js:74:24)
    at MergeMapSubscriber._tryNext (C:\Users\hemed\Desktop\_coreteck\gray\pos-system-backend\node_modules\@angular-devkit\schematics\node_modules\rxjs\internal\operators\mergeMap.js:69:27)

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 7.0.3

 
For Tooling issues:
- Node version: 12.14  
- Platform:  Windows 

Others:

package manager: yarn

CORS does not work with azure-func-http

I'm submitting an issue


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

In the Azure function handler, createApp with
const app = await NestFactory.create(AppModule, { cors: true });

Expected behavior

When calling the Azure function running locally, a HTTP OPTIONS request to the /restapi - it should return the CORS headers.

Minimal reproduction of the problem with instructions

Running the NestJS server directly (in express mode)
curl -vvv -X OPTIONS http://myserver:3333/restapi
returns CORS headers

But when running under func start
curl -vvv -X OPTIONS http://myserver:7071/restapi
should return the CORS accept header response.
No headers are returned.

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: 14
- Platform:  Mac
- Azure Function 4.0.0
- @nestjs/azure-func-http:^0.8.0
- @nestjs/platform-express:^8.0.0
- express: 4.17.1
Others:
Sharing investigation if it helps.

The default CORS handling in the express router - wraps the done with a check to handle OPTIONS
[email protected]/node_modules/express/lib/router/index.js
line 162
 // for options requests, respond with a default if nothing else responds
  if (req.method === 'OPTIONS') {
    done = wrap(done, function(old, err) {
      if (err || options.length === 0) return old(err);
      sendOptionsResponse(res, options, old);
    });
  }

This method is not called by the Azure HTTP handler - so the default CORS handling for OPTIONS does not get invoked.

Azure Functions v4 support

When doing npm run build && func host start I get the following error:

Warning: Proxies are not supported in Azure Functions v4. Instead of 'proxies.json', try Azure API Management: https://aka.ms/AAfiueq

After trying to access the endpoint, for example: https://nestjstest1.azurewebsites.net/api

I get the following error:

Server Error

502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

Please add Azure Functions v4 support, which has been out since last year.

Reference:

https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-v4-versus-v3/ba-p/3276055

Using Multiple Azure function in one app

Currently I can see one index.ts inside Main folder which has code like
export default function(context: Context, req: HttpRequest): void { AzureHttpAdapter.handle(createApp, context, req); }

If I have another azure function in same app, what is the recommended approach? See the below code which we have in .NetCore

`
public static class ClientInfoFuncion
{
[FunctionName("IP")]
public static IActionResult GetClientIp(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("Requesting client IP.");
var ip = req.HttpContext.Connection.RemoteIpAddress.ToString();
return ip != null
? (ActionResult)new OkObjectResult($"{ip}")
: new BadRequestObjectResult("ip is null");
}

    [FunctionName("UserAgent")]
    public static IActionResult GetClientUserAgent(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
    {
        log.LogInformation("Requesting client User-Agent.");
        var ua = req.Headers["User-Agent"].ToString();
        return ua != null
            ? (ActionResult)new OkObjectResult($"{ua}")
            : new BadRequestObjectResult("user-agent is null");
    }
}

`

main/index.ts not compiled

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

After setting up a monorepo project with some libraries and an application, when I run npm run start:azure I get the following error:

[3/15/20 5:22:56 PM] 0 proxies loaded
[3/15/20 5:22:56 PM] Generating 0 job function(s)
[3/15/20 5:22:56 PM] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[3/15/20 5:22:56 PM] Initializing function HTTP routes
[3/15/20 5:22:56 PM] No HTTP routes mapped
[3/15/20 5:22:56 PM] 
[3/15/20 5:22:56 PM] Host initialized (589ms)
[3/15/20 5:22:56 PM] Host started (595ms)
[3/15/20 5:22:56 PM] Job host started
[3/15/20 5:22:56 PM] The 'main' function is in error: Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.
Hosting environment: Production
Content root path: ...
Now listening on: http://0.0.0.0:7071

I also notice it's the regular main.ts that gets compiled with webpack, not the main.azure.ts
image

Environment


Nest version: 7.0.0
@nestjs/azure-func-http: 0.5.0

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

circleci
.circleci/config.yml
  • cimg/node 20.3
  • cimg/node 20.3
npm
package.json
  • cors 2.8.5
  • jsonc-parser ^3.2.0
  • trouter 3.2.1
  • @angular-devkit/schematics ^16.0.0
  • @azure/functions 3.5.1
  • @commitlint/cli 19.2.1
  • @commitlint/config-angular 19.1.0
  • @nestjs/common 10.2.7
  • @nestjs/core 10.2.7
  • @nestjs/schematics 10.0.2
  • @types/node 20.11.30
  • @types/jest 29.5.12
  • @typescript-eslint/eslint-plugin 7.4.0
  • @typescript-eslint/parser 7.4.0
  • @schematics/angular 16.2.13
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-import 2.29.1
  • husky 9.0.11
  • lint-staged 15.2.2
  • prettier 3.2.5
  • release-it 17.1.1
  • typescript 5.4.3
  • jest 29.7.0
  • ts-jest 29.1.2
  • @azure/functions ^1.0.3 || ^2.0.0 || ^3.0.0
  • @nestjs/common ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0
  • @nestjs/core ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0
  • reflect-metadata ^0.1.13

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

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

POST requests not working

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using the npm run start:azure entry point or deploy my app on Functions, POST requests are not working. Using the regular entry point npm start, requests works well.

Expected behavior

POST requests works the same using azure functions entry points or the regular one.

Minimal reproduction of the problem with instructions

  1. Clone this project example project: https://github.com/nitro-stack/nitro-cats/blob/master/server/src/cat/cat.controller.ts
  2. npm start:azure
  3. upload an image file using POST /api/upload
  4. NestJS endpoint handler is never called

But really, this can be reproduced with any project and POST requests. (GET requests works fine)

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.10.12

 
For Tooling issues:
- Node version: 12.13.0  
- Platform:  Mac

Others:

Requests with body not in JSON format failing

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Follow-up to #78.

Any request providing body that is not JSON (see #78) is failing (POST, PUT) due to the fact that express middleware expect an open stream for the request, and currently it received an event emitter through azure-function-express wrapper.

Expected behavior

Any kind of valid request should be processable like a regular NestJS app.

Minimal reproduction of the problem with instructions

See #78

What is the motivation / use case for changing the behavior?

Support file upload, form-encoded data...

Environment


Nest version: 6.12.2

 
For Tooling issues:
- Node version: 12.13.0
- Platform:  Mac

Others:

TRouter constructor is undefined at runtime in AzureHttpRouter

I'm submitting a.


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

AzureHttpRouter tries to instantiateTRouter but it's constructor is undefined at runtime.

dist/router/azure-http.router.js

class AzureHttpRouter extends core_1.AbstractHttpAdapter {
    constructor() {
        super(new trouter_1.default());
        this.routerMethodFactory = new router_method_factory_1.RouterMethodFactory();
    }

screenshot

azure-http.router.ts line 15

logs error

[2021-08-09T07:02:24.228Z] (node:2928) UnhandledPromiseRejectionWarning: TypeError: trouter_1.default is not a constructor
[2021-08-09T07:02:24.231Z]     at new AzureHttpRouter (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\node_modules\@nestjs\azure-func-http\dist\router\azure-http.router.js:12:15)
[2021-08-09T07:02:24.235Z]     at createApp (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\dist\src\main.azure.js:8:73)
[2021-08-09T07:02:24.238Z]     at AzureHttpAdapterStatic.<anonymous> (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\node_modules\@nestjs\azure-func-http\dist\azure-http.adapter.js:24:31)
[2021-08-09T07:02:24.241Z]     at Generator.next (<anonymous>)
[2021-08-09T07:02:24.243Z]     at C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\node_modules\@nestjs\azure-func-http\dist\azure-http.adapter.js:8:71
[2021-08-09T07:02:24.246Z]     at new Promise (<anonymous>)
[2021-08-09T07:02:24.249Z]     at __awaiter (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\node_modules\@nestjs\azure-func-http\dist\azure-http.adapter.js:4:12)
[2021-08-09T07:02:24.251Z]     at AzureHttpAdapterStatic.createHandler (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\node_modules\@nestjs\azure-func-http\dist\azure-http.adapter.js:23:16)
[2021-08-09T07:02:24.252Z]     at AzureHttpAdapterStatic.handle (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\node_modules\@nestjs\azure-func-http\dist\azure-http.adapter.js:20:14)
[2021-08-09T07:02:24.254Z]     at Object.default_1 [as default] (C:\Users\rim\DEV\reproduction-nest-azure-http-issue-636\dist\main\index.js:6:40)

Expected behavior

Instantiating Trouter should work.

Minimal reproduction of the problem with instructions

Reproduction repo

TRouter issue

This issue seems more related to TRouter package.
Using the code snippet below works properly and does not require esModuleInterrop.

import * as TRouter from "trouter";
//@ts-ignore
const R = new TRouter();

reproduction repo

What is the motivation / use case for changing the behavior?

Fix a bug.

Environment


Nest version: 8.0.0
nest/azure-http-func version : 0.7.0
 
For Tooling issues:
- Node version: v14.16.0
- Platform:  Mac

AzureHttpRouter not exported/not working

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request

Current behavior

When creating an app with the AzureHttpRouter, routing does not work.

Expected behavior

In the README, it shows you can instantiate the app using an azure http router instead of the default express router. However, when adding this: const app = await NestFactory.create(AppModule, new AzureHttpRouter()); the request to any endpoint just hangs.
Perhaps I need to do something else to get this to work?

Also, when I use this with Typescript, and run build, it says that AzureHttpRouter is not being exported from the @nestjs/azure-func-http package.

Minimal reproduction of the problem with instructions

yarn add @nestjs/azure-func-http
main.azure.[j/t]s

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AzureHttpRouter } from '@nestjs/azure-func-http'

export async function createApp() {
  const app = await NestFactory.create(AppModule, new AzureHttpRouter());
  app.setGlobalPrefix('webhooks');

  await app.init();
  return app;
}

Environment


Nest version: 6.8.3
 
For Tooling issues:
- Node version: 10.16.2
- Platform:  Linux

Others:

Pls update documentation that this project is abandoned / deprecated

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ *] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Project is not marked as abandoned / deprecated

Expected behavior

Please update front-page readme with info that the project is no longer actively maintained

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

To inform users that this is no longer a viable option

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

package fails to install

I'm submitting a...


[ X] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Trying to install the package fails with following error:
Starting library setup...
Error: NOT SUPPORTED: keyword "id", use "$id" for schema ID
at Object.code (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/vocabularies/core/id.js:6:15)
at keywordCode (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/validate/index.js:454:13)
at /Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/validate/index.js:222:17
at CodeGen.code (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/codegen/index.js:439:13)
at CodeGen.block (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/codegen/index.js:568:18)
at iterateKeywords (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/validate/index.js:219:9)
at groupKeywords (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/validate/index.js:208:13)
at /Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/validate/index.js:192:13
at CodeGen.code (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/codegen/index.js:439:13)
at CodeGen.block (/Users/johanvrolix/Sites/laviejoly/api/node_modules/ajv/dist/compile/codegen/index.js:568:18)

Failed to execute command: node @nestjs/azure-func-http:nest-add --sourceRoot="src" /usr/local/Cellar/node@14/14.18.1/bin/node /usr/local/bin/nest add @nestjs/azure-func-http

Expected behavior

package to be installed and Azure function to be set up.

Minimal reproduction of the problem with instructions

nest add @nestjs/azure-func-http

What is the motivation / use case for changing the behavior?

Environment


Nest version: 8.1.5

 
For Tooling issues:
- Node version: v14.18.1
- Platform: Mac

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.