Skip to content

Commit

Permalink
update imgproxy-url-builder to v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BitPatty authored Jun 26, 2022
1 parent 049d204 commit f118c0d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 42 deletions.
1 change: 0 additions & 1 deletion example/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
12 changes: 0 additions & 12 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,5 @@
"build": "next build",
"start": "NODE_ENV=production node server.js",
"lint": "next lint"
},
"dependencies": {
"@bitpatty/imgproxy-url-builder": "^0.2.2",
"next": "12.1.6",
"react": "^17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/react": "17.0.27",
"eslint": "7.32.0",
"eslint-config-next": "11.1.2",
"typescript": "4.4.3"
}
}
8 changes: 4 additions & 4 deletions example/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const demoContent: {

proxyParams: pb()
.crop({
width: 30,
height: 30,
width: 100,
height: 100,
})
.build(),
},
Expand All @@ -43,8 +43,8 @@ const demoContent: {

proxyParams: pb()
.crop({
width: 30,
height: 30,
width: 200,
height: 200,
gravity: {
type: GravityType.NORTHEAST,
offset: {
Expand Down
19 changes: 15 additions & 4 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -12,8 +16,15 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
31 changes: 22 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitpatty/next-image-s3-imgproxy-loader",
"version": "0.7.1",
"version": "0.8.0",
"description": "imgproxy S3 extension for next/image",
"author": "Matteias Collet <[email protected]>",
"main": "dist/index.js",
Expand All @@ -21,6 +21,7 @@
"types": "./dist/index.d.ts",
"homepage": "https://github.com/BitPatty/next-image-s3-imgproxy-loader#readme",
"devDependencies": {
"@types/node": "16.11.7",
"@types/react": "18.0.9",
"create-hmac": "1.1.7",
"next": "12.1.6",
Expand All @@ -35,6 +36,6 @@
"next": "^11.0.0 || ^12.0.0"
},
"dependencies": {
"@bitpatty/imgproxy-url-builder": "^0.4.1"
"@bitpatty/imgproxy-url-builder": "^0.6.0"
}
}
3 changes: 2 additions & 1 deletion scripts/minio-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e
SCRIPT_PATH=$(dirname "$0")
echo "Restoring minio files"
cd $SCRIPT_PATH/../.devcontainer/minio-dump
cd $SCRIPT_PATH/../.devcontainer/minio-dump/test-bucket
echo $PWD
minio-cli mb --ignore-existing myminio/test-bucket
minio-cli rm --recursive --force myminio/test-bucket || true
minio-cli cp --recursive . myminio
22 changes: 13 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ const FORWARDED_HEADERS = [
/**
* Builds the final reuest path to retrieve
* an image from the imgproxy instance
* @param src The source file
* @param options The imgproxy options
* @returns The imgproxy request path
*
* @param src The source file
* @param options The imgproxy options
* @returns The imgproxy request path
*/
const buildRequestPath = (
src: string,
Expand All @@ -40,7 +41,10 @@ const buildRequestPath = (
const { imgproxyParams, signature } = options ?? {};

const paramBuilder = pb();
if (imgproxyParams) paramBuilder.modifiers.push(imgproxyParams);
if (imgproxyParams && imgproxyParams.includes(':')) {
// @ts-ignore
paramBuilder.modifiers.set('params', imgproxyParams);
}

return paramBuilder.build({
path: `s3://${src}`,
Expand All @@ -60,11 +64,11 @@ type ImageOptimizerOptions = {

/**
* Handles an image request
* @param imgproxyBaseUrl The URL to the imgproxy instance
* @param query The URL query generated by the {@link ImgProxyParamBuilder}
* @param res The response to which the resulting file should be piped to
* @param options Optional configuration options for the imgproxy connection
* @returns
*
* @param imgproxyBaseUrl The URL to the imgproxy instance
* @param query The URL query generated by the {@link ImgProxyParamBuilder}
* @param res The response to which the resulting file should be piped to
* @param options Optional configuration options for the imgproxy connection
*/
const handle = (
imgproxyBaseUrl: URL,
Expand Down

0 comments on commit f118c0d

Please sign in to comment.