27
loading...
This website collects cookies to deliver better user experience
docker pull express-gateway
touch gateway.config.yml
touch system.config.yml
http:
port: 8080
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
default:
apiEndpoints:
- api
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
# Core
db:
redis:
emulate: true
namespace: EG
#plugins:
# express-gateway-plugin-example:
# param1: 'param from system.config'
crypto:
cipherKey: sensitiveKey
algorithm: aes256
saltRounds: 10
# OAuth2 Settings
session:
secret: keyboard cat
resave: false
saveUninitialized: false
accessTokens:
timeToExpiry: 7200000
refreshTokens:
timeToExpiry: 7200000
authorizationCodes:
timeToExpiry: 300000
touch applications.json
touch credentials.json
touch users.json
{
"$id": "http://express-gateway.io/models/applications.json",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"redirectUri": {
"type": "string",
"format": "uri"
}
},
"required": [
"name"
]
}
{
"$id": "http://express-gateway.io/models/credentials.json",
"type": "object",
"definitions": {
"credentialBase": {
"type": "object",
"properties": {
"autoGeneratePassword": {
"type": "boolean",
"default": true
},
"scopes": {
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
}
},
"required": [
"autoGeneratePassword"
]
}
},
"properties": {
"basic-auth": {
"allOf": [
{
"$ref": "#/definitions/credentialBase"
},
{
"type": "object",
"properties": {
"passwordKey": {
"type": "string",
"default": "password"
}
},
"required": [
"passwordKey"
]
}
]
},
"key-auth": {
"type": "object",
"properties": {
"scopes": {
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
}
}
},
"jwt": {
"type": "object",
"properties": {}
},
"oauth2": {
"allOf": [
{
"$ref": "#/definitions/credentialBase"
},
{
"type": "object",
"properties": {
"passwordKey": {
"type": "string",
"default": "secret"
}
},
"required": [
"passwordKey"
]
}
]
}
}
}
{
"$id": "http://express-gateway.io/models/users.json",
"type": "object",
"properties": {
"firstname": {
"type": "string"
},
"lastname": {
"type": "string"
},
"username": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"redirectUri": {
"type": "string",
"format": "uri"
}
},
"required": [
"username",
"firstname",
"lastname"
]
}
docker run -d --name express-gateway \
-v /Users/naseef/Config:/var/lib/eg \
-p 8080:8080 \
-p 9876:9876 \
express-gateway
docker ps
in the terminal and check. npm init
command to setup my package.json, but you can choose other ways to setup the Express server.npm install express --save
in Actor to install Express.let express = require('express');
let app = express();
app.listen(3000, () => {
console.log("Server running on port 3000");
});
app.get("/actors", (req, res, next) => {
let array_actors = [
"Tom Cruise",
"Johnny Depp",
"Di Caprio",
"Russel Crowe",
"Tom Hanks"
];
res.json(array_actors);
});
node actor.js
to start this server on port 3000 of localhost. Hit the browser (or use Postman) with this url.http://localhost:3000/actors
.[
"Tom Cruise",
"Johnny Depp",
"Di Caprio",
"Russel Crowe",
"Tom Hanks"
]
let express = require('express');
let app = express();
app.listen(8000, () => {
console.log("Server running on port 8000");
});
app.get("/movies", (req, res, next) => {
let array_movies = [
"Mission Impossible",
"Pirates of Carribean",
"Inception",
"Gladiator",
"The Terminal"
];
res.json(array_movies);
});
node movie.js
to start this server on port 8000 of localhost. Hit the browser (or use Postman) with this url.http://localhost:8000/movies
.[
"Mission Impossible",
"Pirates of Carribean",
"Inception",
"Gladiator",
"The Terminal"
]
http://412143bfb37a.ngrok.io/movies
http://eed882f0ffe3.ngrok.io/actors
http:
port: 8080
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
actors:
host: localhost
paths: ['/actors','/actors/*']
movies:
host: localhost
paths: ['/movies','/movies/*']
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
actorService:
url: 'http://eed882f0ffe3.ngrok.io'
movieService:
url: 'http://412143bfb37a.ngrok.io'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
actorPipeline:
apiEndpoints:
- actors
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: actorService
changeOrigin: true
moviePipeline:
apiEndpoints:
- movies
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: movieService
changeOrigin: true
default:
apiEndpoints:
- api
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
docker restart express-gateway
http://localhost:8080/actors
http://localhost:8080/movies