Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
/ uploader Public archive

The uploader service you desperately need!

License

Notifications You must be signed in to change notification settings

ateliware/uploader

Repository files navigation

uploader

Build Status

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, and token which is the authentication token to your upload (generated by GET /token).

Configuration

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 only
    • test - to use on your test environment and CI
    • production - to use on your production deployed app
  • PORT - the port used to start the server on
  • UPLOADER_USER - the username to use in the authentication system for the GET \token route.
  • UPLOADER_PSWD - the password to use in the authentication system for the GET \token route.

The following keys are required only in production environment:

  • BUCKET - the storage bucket to upload to
  • PROJECT_ID - the project id where the bucket is on
  • KEYFILE - the credentials for your storage server

Contribute to the app

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. ;)

Installing the app in dev mode

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
  • 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
  • The default port of the project is 3000, so you can use the server in http://localhost:3000
  • Running the tests:
    • docker - docker run -e NODE_ENV=test uploader npm test
    • no-docker - npm test

Workflow

  1. Create a new branch for your feature of fix and checkout to it
  2. Do your code
  3. Run the tests
  4. 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)
  5. Repeat 2 to 4 until it's done
  6. Open a PR
  7. Someone else will review it
  8. If needed, fix what the reviewer asked for
  9. DONE!

Deploying

The deploy of this app consists in building and pushing a docker image to hub.docker.com.

Building and pushing the image

  • Upgrade the version in package.json with:
    • VERSION=$(npm version major | cut -c 2-) when you make incompatible API changes
    • VERSION=$(npm version minor | cut -c 2-) when you add functionality in a backwards-compatible manner
    • VERSION=$(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! :shipit: