The ateliware default uploader app. This is a simple web app with two routes:
GET /token
- this route gives the user a unique authentication token to upload one file. The tokens are automatically expired in 3 hours. You can optionally make this an authenticated route, for more information see the configuration section below.POST /upload
- this route uploads a file to the storage service configured. This route takes two required params:file
, which is the file you want to upload, andtoken
which is the authentication token to your upload (generated byGET /token
).
All the configuration for the app is done through environment variables, so here we go:
NODE_ENV
- the environment to run the app. Can be one of:development
- to use on your local environment onlytest
- to use on your test environment and CIproduction
- to use on your production deployed app
PORT
- the port used to start the server onUPLOADER_USER
- the username to use in the authentication system for theGET \token
route.UPLOADER_PSWD
- the password to use in the authentication system for theGET \token
route.
The following keys are required only in production environment:
BUCKET
- the storage bucket to upload toPROJECT_ID
- the project id where the bucket is onKEYFILE
- the credentials for your storage server
Here is how to install and contribute for this project. But before thinking in anything new to place in this app:
PLEASE, KEEP IT SIMPLE. ;)
Here is a step by step for installing the app and running its main tasks:
- First of all
git clone git@github.com:ateliware/uploader.git
- Then
cd uploader
- Now you can choose from doing it with our without docker so the next steps will have details for both
- Install the dependencies
- docker -
docker build . -t uploader
- no-docker -
npm install
- docker -
- Running the server (with monitoring):
- docker -
docker run -e NODE_ENV=development -p 3000:3000 -v .:/app uploader
- no-docker -
npm start
- If you want to start the server monitoring file changes:
- docker -
docker run -e NODE_ENV=development -p 3000:3000 -v .:/app uploader nodemon index.js
- no-docker -
nodemon index.js
- docker -
- docker -
- The default port of the project is
3000
, so you can use the server inhttp://localhost:3000
- Running the tests:
- docker -
docker run -e NODE_ENV=test uploader npm test
- no-docker -
npm test
- docker -
- Create a new branch for your feature of fix and checkout to it
- Do your code
- Run the tests
- Add a commit to it (only if the tests passed, and prefer tiny chunks of code per commit, it's easier to review this way)
- Repeat 2 to 4 until it's done
- Open a PR
- Someone else will review it
- If needed, fix what the reviewer asked for
- DONE!
The deploy of this app consists in building and pushing a docker image to hub.docker.com.
- Upgrade the version in
package.json
with:VERSION=$(npm version major | cut -c 2-)
when you make incompatible API changesVERSION=$(npm version minor | cut -c 2-)
when you add functionality in a backwards-compatible mannerVERSION=$(npm version patch | cut -c 2-)
when you make backwards-compatible bug fixes- For more details in about versioning, read this
- Build the docker image
docker build -t ateliware/uploader:$VERSION .
- Publish to docker hub
docker push ateliware/uploader:$VERSION
- SHIP IT!