You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Trent Larson bb83982bc7 Revert "Revert "bump version and add "-beta""" 2 months ago
sql start the feature of replacing an existing image 4 months ago
src fix the local ETHR resolver code to work in Docker (because it loaded as undefined) 2 months ago
test add another test image file 2 months ago
.env.sample fix multiple-user check, add tests, use local resolver for did:ethr 2 months ago
.gitignore add DB to record each image upload 7 months ago
CHANGELOG.md Revert "Revert "bump version and add "-beta""" 2 months ago
CONTRIBUTING.md check image upload against user limits 7 months ago
Dockerfile fix the local ETHR resolver code to work in Docker (because it loaded as undefined) 2 months ago
Makefile.test fix multiple-user check, add tests, use local resolver for did:ethr 2 months ago
README.md fix the local ETHR resolver code to work in Docker (because it loaded as undefined) 2 months ago
package.json Revert "Revert "bump version and add "-beta""" 2 months ago
pnpm-lock.yaml pull in did:peer verification (from endorser-ch) 2 months ago
tsconfig.json make into a typescript project 2 months ago

README.md

Image Server

Remaining:

  • dockerize

setup

sh <(curl https://pkgx.sh) +pnpm sh
pnpm install
# create the directory for files that are being uploaded; should stay empty afterward
mkdir uploads
pnpm run migrate

Now set up an S3 bucket, and create a .env file from .env.sample with these important settings:

AWS_ACCESS_KEY=
AWS_SECRET_KEY=
AWS_REGION=

dev

node src/server.js

test

automated

make -C test -j

manual

# run this first command in a directory where `npm install did-jwt` has been run
CODE='OWNER_DID="did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F"; OWNER_PRIVATE_KEY_HEX="2b6472c026ec2aa2c4235c994a63868fc9212d18b58f6cbfe861b52e71330f5b"; didJwt = require("did-jwt"); didJwt.createJWT({ exp: Math.floor(Date.now() / 1000) + 60, iat: Math.floor(Date.now() / 1000), iss: OWNER_DID }, { issuer: OWNER_DID, signer: didJwt.SimpleSigner(OWNER_PRIVATE_KEY_HEX) }).then(console.log)'
JWT=`node -e "$CODE"`; curl -X GET -H "Authorization: Bearer $JWT" http://localhost:3001/image-limits
JWT=`node -e "$CODE"`; curl -X POST -H "Authorization: Bearer $JWT" -F "image=@./test.png" http://localhost:3001/image
JWT=`node -e "$CODE"`; curl -X DELETE -H "Authorization: Bearer $JWT" http://localhost:3001/image/https%3A%2F%2Fgifts-image-test.s3.amazonaws.com%2F4599145c3a8792a678f458747f2d8512c680e8680bf5563c35b06cd770051ed2.png

deploy to prod first time

  • Do the necessary steps from "setup" above, or docker build it.

  • In object storage, set up bucket (and erase any test data).

  • Create a cert for the image delivery & image API servers.

  • In haproxy, set a permanent web forward to the correct storage location.

    • eg. http-request redirect code 301 location https://a2-west.americancloud.com/images6618:giftsimagetest%[capture.req.uri] if { hdr_dom(host) -i test-image.timesafari.app }

deploy to prod subsequent times

  • Update version in package.json, server.js 'ping' endpoint, and CHANGELOG.md entry.

  • Commit, push, and tag.

  • Build the docker image.

  • Bump version and add "-beta" in package.json & server.js 'ping' endpoint.