Skip to content

Commit

Permalink
feat: flesh in dynomimage
Browse files Browse the repository at this point in the history
Signed-off-by: hxtree <[email protected]>
  • Loading branch information
hxtree committed Apr 9, 2024
1 parent 734134b commit dc4536b
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 36 deletions.
66 changes: 31 additions & 35 deletions common/config/rush/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion common/config/rush/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "26a8113c8a584552d3b9a0b564e70298bf4801c3",
"pnpmShrinkwrapHash": "1b24796e97dbb7cb867594d4d1d8446b53880abc",
"preferredVersionsHash": "a48003cf229dd47d077bcf6301ac15a6f90e1c34"
}
13 changes: 13 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,19 @@
"tags": ["services", "cimongo"],
"shouldPublish": true
},
{
"packageName": "@cats-cradle/dynamo-image",
"projectFolder": "services/dynamo-image",
"reviewCategory": "apis",
"decoupledLocalDependencies": [
"@cats-cradle/eslint-config",
"@cats-cradle/nestjs-modules",
"@cats-cradle/create-artifact",
"@cats-cradle/create-bundle"
],
"tags": ["services", "mongoshelf"],
"shouldPublish": true
},
{
"packageName": "@cats-cradle/email-service",
"projectFolder": "services/email-service",
Expand Down
6 changes: 6 additions & 0 deletions services/dynamo-image/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@cats-cradle/eslint-config/profile/base'],
parserOptions: {
tsconfigRootDir: __dirname,
},
};
17 changes: 17 additions & 0 deletions services/dynamo-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @cats-cradle/dynamo-image

![Lifecycle](https://img.shields.io/badge/lifecycle-unstable-red)

When an original image is PUT into the S3 bucket an event is fired. A listener
generates multiple images of desired window sizes if image matches desired
format. Request can be made to upload a specifc version of other image variants
but it does not trigger generation of other variants.

Event

key: /original

## References

Based on [DynamoImage](https://github.com/Ouxsoft/DynamoImage) and
[AWS Lambda S3 Thumbnail Generator](https://github.com/hxtree/AWS-Lambda-S3-Thumbnail-Generator).
16 changes: 16 additions & 0 deletions services/dynamo-image/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@cats-cradle/dynamo-image",
"module": "commonjs",
"version": "0.0.1",
"scripts": {
"lint": "eslint --format visualstudio \"./{stacks,src}/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run"
},
"dependencies": {
"@cats-cradle/base-nodejs": "workspace:*"
},
"devDependencies": {
"eslint": "8.57.0",
"@cats-cradle/eslint-config": "1.0.11"
}
}
8 changes: 8 additions & 0 deletions services/dynamo-image/src/models/image-format.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum ImageFormat {
'JPEG' = 'jpeg',
'PNG' = 'png',
'GIF' = 'gif',
'WEBP' = 'webp',
'SVG' = 'svg',
'ICO' = 'ico',
}
34 changes: 34 additions & 0 deletions services/dynamo-image/src/models/image-set-embeddable.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import {
IsEnum, IsInt, Min, Max,
} from '@cats-cradle/validation-schemas';
import { ImageVariant } from './image-variant.enum';

@Schema()
export class ImageSetEmbeddable {
@IsEnum(ImageVariant)
@Prop({
type: String,
required: true,
enum: ImageVariant,
})
public variant!: ImageVariant;

@IsInt()
@Min(0)
@Max(255000)
@Prop()
public width!: number;

@IsInt()
@Min(0)
@Max(255000)
@Prop()
public height!: number;

@IsInt()
@Min(0)
@Max(255000)
@Prop()
public filesize!: number;
}
12 changes: 12 additions & 0 deletions services/dynamo-image/src/models/image-variant.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export enum ImageVariant {
ORIGNAL = 'original',
THUMBNAIL = 'thumbnail',
XSMALL = 'xsmall',
SMALL = 'small',
LARGE = 'large',
XLARGE = 'xlarge',
SMALLSQUARE = 'smallsquare',
MEDIUMSQUARE = 'mediumSquare',
LARGESQUARE = 'largesquare',
BANNER = 'banner',
}
Loading

0 comments on commit dc4536b

Please sign in to comment.