Skip to content

Commit

Permalink
feat: Enhance API gateway to be able to use OVH Swift backend instead…
Browse files Browse the repository at this point in the history
… of AWS S3 backend (closes #251)
  • Loading branch information
claustres committed Jul 12, 2021
1 parent c27cf87 commit d752b17
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build/express-gateway/plugins/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const aws = require('aws-sdk');

const s3 = new aws.S3({
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
endpoint: process.env.S3_ENDPOINT
})

module.exports = {
Expand Down
3 changes: 2 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function getTipsSidebar () {
'using-artillery',
'handling-long-running-process',
'using-mongodb-atlas',
'extracting-osm-data'
'extracting-osm-data',
'running-express-gateway'
]
}
43 changes: 43 additions & 0 deletions docs/tips/running-express-gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
sidebarDepth: 3
---

# Running express-gateway locally

It is sometimes required to play with the API gateway on your local development environment for debug purpose. As Kargo relies on a specific image built with plugins, etc. you can use it but it might not be so convenient. Otherwise you can clone [express-gateway](https://github.com/ExpressGateway/express-gateway) and do the following to run it locally with e.g. the S3 plugin:

1. Add AWS SDK dependency to the `package.json` file (`"aws-sdk": "^2.607.0"`)

2. Copy the Kargo plugin into the `lib` directory

3. Add S3 plugin at the end of the `lib/config/system.config.yml` file:
```yml
plugins:
s3:
package: ./s3
```
4. Add S3 endpoint/pipeline the `lib/config/gateway.config.yml` file:
```yml
apiEndpoints:
s3:
hosts: '*'
paths: '/s3/*'
serviceEndpoints:
s3:
url: 'http://localhost:9876/s3'
pipelines:
s3:
apiEndpoints:
- s3
policies:
- proxy:
- action:
serviceEndpoint: s3
changeOrigin: true
stripPath: true
```

Configure the required environment variables (`S3_ACCESS_KEY`, `S3_SECRET_ACCESS_KEY`, `S3_ENDPOINT`) then launch the gateway: `npm run start:dev`.

Now you should be able to access objects using the following URL: http://localhost:9876/s3/bucket/key.

0 comments on commit d752b17

Please sign in to comment.