Skip to content

A simple backend for frontend service, created in nodejs, using expressjs and the http-proxy-middleware module.

License

Notifications You must be signed in to change notification settings

damiancipolat/node-bff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Backend for frontend

A microservices example created with node.js using express-http-proxy.

Install

To install the project run this command:

$npm install

Configuration

To define the redirection endpoints follow this instructions.

{
  "server": {
    "port": "8080"
  },
  "proxy": {
    "map": [
      {
        "target": "https://5f3a062e2300b100169a84f7.mockapi.io",
        "endpoint": "/movies",
        "routes": [
          {
            "method": "get",
            "path": "/movie"
          },
          {
            "method": "get",
            "path": "/movie/:id",
            "auth": true
          }
        ]
      }
    ]
  }
}
  • In proxy.map section define the redirection hots.
  • In proxy.map.routes define the endpoints to redirect and the methods is the auth is required add "auth:true".

Example

To try the example run this command.

#Redirecto to https://5f3a062e2300b100169a84f7.mockapi.io/movies/movie
curl --GET 127.0.0.1:8080/movies/movie/

#Redirecto to https://5f3a062e2300b100169a84f7.mockapi.io/movies/movie/1
curl --GET 127.0.0.1:8080/movies/movie/1

About

A simple backend for frontend service, created in nodejs, using expressjs and the http-proxy-middleware module.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published