https://github.com/dbtek/ipx-s3-middleware
A simple middleware for IPX which translates given path to full S3 url.
https://github.com/dbtek/ipx-s3-middleware
Last synced: 8 months ago
JSON representation
A simple middleware for IPX which translates given path to full S3 url.
- Host: GitHub
- URL: https://github.com/dbtek/ipx-s3-middleware
- Owner: dbtek
- License: mit
- Created: 2021-08-14T16:27:11.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-01T07:46:55.000Z (almost 3 years ago)
- Last Synced: 2025-10-04T02:59:32.063Z (9 months ago)
- Language: TypeScript
- Size: 297 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ipx-s3-middleware
===
A simple middleware which translates given image path to http sourced S3 url for [IPX](https://github.com/unjs/ipx).
It basically enables you to source S3 urls (or any other public remote urls) by the path `/s_200x200/path/to/image.jpg` instead of `/s_200x200/https://my-bucket.s3.us-west-2.amazonaws.com/path/to/image.jpg`.
### Usage
```bash
$ npm i ipx-s3-middleware
# or with yarn
$ yarn add ipx-s3-middleware
```
### Example
`server.js`
```js
const express = require('express');
const { createIPX } = require('ipx');
const { createIPXS3Middleware } = require('ipx-s3-middleware');
const s3BaseUrl = 'https://my-bucket.s3.us-west-2.amazonaws.com';
const ipx = createIPX({ domains: [s3BaseUrl] });
const app = express();
app.use('/images', createIPXS3Middleware(ipx, s3BaseUrl));
app.listen(3001, () => {
console.log(`🚀 Image processing service is ready at http://localhost:3000`)
});
```
**URL**
`GET http://localhost/images/{modifiers}/{objectPath}`
Example: `GET http://localhost:3001/images/s_200x200/path/to/image`