Automattic / mShots

Website Thumbnail/Snapshot Service
GNU General Public License v2.0
100 stars 21 forks source link

Add external url-analyzer endpoint #54

Closed jeroenpf closed 2 years ago

jeroenpf commented 2 years ago

This PR adds the external endpoint logic to mShots. The PR belongs to a series of changes to add a URL analyzer endpoint to the mShots service. #53 for more information, see #51

Since mShots is a service that performed only one task (creating a screenshot of a website), there was no routing logic and all incoming requests would simply trigger the screenshot logic.

In this PR we add logic that routes the requests to either the screenshot or url analyzer feature.

How to test:

Start up the service locally and hit the endpoint: http://localhost:8000/url-analyzer?url=https://wordpress.com

vishnugopal commented 2 years ago

@jeroenpf would love more testing instructions here.

I’m unable to test this btw because mShots doesn’t seem to work for me (seems to be M1 Mac issues)

➜  mShots git:(add/url-analyzer-external-endpoint) ✗ npm start

> mShots.NodeJS@0.1.0 start
> npm run start:docker && npm run start:mshots && echo mshots service successfully in the mshots docker container. && echo Port 8000 is mapped to localhost, e.g. http://localhost:8000/mshots/v1/example.com

> mShots.NodeJS@0.1.0 start:docker
> docker-compose up -d

Pulling memcached (memcached:latest)...
latest: Pulling from library/memcached
32252aec0777: Pull complete
966f1b38b9d3: Pull complete
b2898c9abf66: Pull complete
d331819fcfc0: Pull complete
25a25819b974: Pull complete
b7c790b93b28: Pull complete
Digest: sha256:a5f9ad1b50f73d272b0e72ced4825c4ef139e8efb309d66763892f81c0f21422
Status: Downloaded newer image for memcached:latest
Creating memcached  ... done
Creating mshots-dev ... done

> mShots.NodeJS@0.1.0 start:mshots
> docker-compose exec mshots ./mshots_ctl.sh start

OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: no such file or directory: unknown

I had to make a few tweaks even to get npm install working: