ExpressGateway / express-gateway

A microservices API Gateway built on top of Express.js
https://www.express-gateway.io
Apache License 2.0
2.97k stars 347 forks source link

Bug: "No Suitable pipeline found for..." #992

Open ravig-lakmiri opened 4 years ago

ravig-lakmiri commented 4 years ago

Hi Getting the following in the log which suggests that gateway is not able to create the pipelines/routes.. Pls see below log with LOG_LEVEL=debug npm start

2020-03-28T13:46:09.608Z [EG:gateway] debug: mounting routes for apiEndpointName auth-email-confirm, mount /auth/email-confirm/:token
2020-03-28T13:46:09.608Z [EG:gateway] debug: No suitable pipeline found for auth-email-confirm
2020-03-28T13:46:09.608Z [EG:gateway] debug: methods specified, registering for each method individually
2020-03-28T13:46:09.609Z [EG:gateway] debug: mounting routes for apiEndpointName auth-register-login, mount /auth/register-user
2020-03-28T13:46:09.609Z [EG:gateway] debug: No suitable pipeline found for auth-register-login
2020-03-28T13:46:09.609Z [EG:gateway] debug: methods specified, registering for each method individually
2020-03-28T13:46:09.609Z [EG:gateway] debug: mounting routes for apiEndpointName auth-register-login, mount /auth/login
2020-03-28T13:46:09.609Z [EG:gateway] debug: No suitable pipeline found for auth-register-login
2020-03-28T13:46:09.609Z [EG:gateway] debug: methods specified, registering for each method individually
2020-03-28T13:46:09.609Z [EG:gateway] debug: mounting routes for apiEndpointName auth-user, mount /auth/user*
2020-03-28T13:46:09.609Z [EG:gateway] debug: No suitable pipeline found for auth-user
2020-03-28T13:46:09.609Z [EG:gateway] debug: no methods specified. handle all mode.
2020-03-28T13:46:09.610Z [EG:gateway] debug: mounting routes for apiEndpointName properties, mount /property*
2020-03-28T13:46:09.610Z [EG:gateway] debug: No suitable pipeline found for properties
2020-03-28T13:46:09.610Z [EG:gateway] debug: no methods specified. handle all mode.
2020-03-28T13:46:09.631Z [EG:gateway] info: gateway http server listening on :::8080
2020-03-28T13:46:09.631Z [EG:admin] info: admin http server listening on 127.0.0.1:9876
2020-03-28T13:46:09.636Z [EG:db] debug: Redis is ready

Here is my gateway.config.yml:

http:
  port: 8080

admin:
  host: localhost
  port: 9876

apiEndpoints:
  auth-email-confirm:
    host: localhost
    path: '/auth/email-confirm/:token'
    methods: ["GET"]

  auth-register-login:
    host: localhost
    paths: ['/auth/register-user', '/auth/login']
    methods: ["POST"]

  auth-user:
    host: localhost
    path:  '/auth/user*'

  properties:
    host: localhost
    path: '/property*'

serviceEndpoints:
  auth:
    url: 'http://localhost:3003'

#policies to be used
policies:
  - log
  - cors
  - jwt
  - request-transformer
  - proxy

#pipelines 
pipelines:
  # this pipeline is used for user clicking on email confirmation
  authEmailConfirmPipeline: 
    apiEndPoints: 
      - auth-email-confirm
    policies:
      - log:
          action:
            message: '${req.method} ${req.originalUrl}'
      - proxy:
          action: 
            serviceEndpoint: auth
            changeOrigin: true

  # this pipeline is used for user registration or login apis
  authRegisterPipeline: 
    apiEndPoints: # in this case we dont need to validate the jwt
      - auth-register-login
    policies:
      - log:
          action:
            message: '${req.method} ${req.originalUrl}'  
      - proxy:
          action: 
            serviceEndpoint: auth
            changeOrigin: true

  # this pipeline is used for user logout or other user update functions (roles, privileges etc)
  authPipeline:
    apiEndpoints:
      - auth-user
    policies:
      - log:
          action:
            message: '${req.method} ${req.originalUrl}'
      - jwt:
          action:
            secretOrPublicKeyFile: ./.key/pubkey.pem
            checkCredentialExistence: false
      - proxy:
          action:
            serviceEndpoint: auth
            changeOrigin: true

I think I have been conformant to the gateway.config.yml spec.. When I send a simple post to register the user.. I get a 404 error. Can any one help and guide if it is a gateway issue or my issue.

POST http://localhost:8080/auth/register-user
Content-Type: application/json

{
    "username": "xyz@hotmail.com",
    "password": "adfj",
    "provider": "adf",
    "firstName": "adfads",
    "lastName": "asdfadsf",
    "middleName": "adsfa",
    "phones": [{"1123345678", "mobile"}]
}

Response:

HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Content-Length: 9
ETag: W/"9-0gXL1ngzMqISxa6S1zx3F4wtLyg"
Date: Sat, 28 Mar 2020 02:18:30 GMT
Connection: close

Not Found