alexellis / pi_zero_stock

PI Zero Stock tracker in Node.js with Redis back-end to cache results
GNU General Public License v3.0
35 stars 5 forks source link

Raspberry PI Zero Stock Check

A high-speed, cached stock checker for the Raspberry PI Zero through screen-scraping.

See also:

Contributing:

Help is welcome, but my time is limited so if you have a suggestion, enhancement or bug fix then please raise an issue to begin a conversation.

Once an issue is open we can can talk about the proposed change in the open. Once we've figured out what needs to be done then you can go ahead and raise a PR and it's very likely to get merged.

Installation (easy way)

Using latest version of Docker and docker-compose:

$ git clone https://github.com/alexellis/pi_zero_stock
$ docker-compose up -d

Manual installation or development:

Set up a hosts entry in /etc/hosts for redis to localhost, or set the environmental variable 'REDIS' to localhost before starting any of the nodes processes.

Supported endpoints:

I've implemented endpoints for the following stores:

UK-based

US-based

To extend the code and add a new endpoint look at the stock_fetch project and add a new file under the fetch folder. This also needs to be updated in the entrypoint of stock_fetch.

Accessing the API:

curl http://localhost:3000/stock/pimoroni/
curl http://localhost:3000/stock/pisupply/
curl http://localhost:3000/stock/pihut/

Viewing in web-browser

Access the following:

http://localhost:3000/

Hosting the site

Todo:

[x] Must have - hardening for failures during scrape
[x] Should have - total stock numbers for any Raspberry PI bundles/products by store.
[x] Should have - (Static site) Angular 1.x (via CDN) for binding stock results. 
[ ] Should have - Switch to pm2 for the node processes
[x] Should have - coloured bootstrap wells or pills for in/out of stock.
[ ] Could have - web hooks (posting to Twitter)
[x] Could have - show stock for other suppliers. (adafruit)
[ ] Could have - show stock units for individual SKUs, rather than (or in addition to) just one total-per-shop