Giter VIP home page Giter VIP logo

tagging_api's Introduction

Tagging API

https://gist.github.com/dradford/9407c8c6af5ea3469596

A general use tagging api for distributed systems. Tag anything with a type and UUID.

Dependencies

  • Ruby 2.3.0
  • Bundler
  • SQLite
  • (Optional) A ruby version manager like chruby or rbenv

Install

$ git clone https://github.com/binarycleric/tagging_api.git
$ cd ./tagging_api
$ bundle install
$ bundle exec rake db:create db:migrate
$ bundle exec rails server

Testing

$ bundle exec rake db:drop db:create db:migrate RAILS_ENV=test
$ bundle exec rake

Acceptance Testing

A rough acceptance test suite has been created. It requires an instance of the service running and makes various HTTP connections to ensure basic functionality is working. Eventually I'd like to move this over to a proper tool but this should help us get off the ground.

$ bundle exec rails s
# In a different tab/pane
$ bundle exec rake acceptance

Endpoints

Create tags for a particular entity (given a type and id).

PUT /tags/:entity_type/:entity_id
tags: []

Get information about tags stored on a particular entity.

GET /tags/:entity_type/:entity_id

Delete all tags on a particular entity.

DELETE /tags/:entity_type/:entity_id 

Get stats about all stored tags.

GET /stats/tags

Get stats about tags stored on a particular entity.

GET /stats/:entity_type/:entity_id

Changes

Used 'PUT /tags' instead of 'POST /tags'

After some thought I decided that a PUT action made the most sense for creating new tags. The reasoning for this is because I am assuming that by using this service, you already have the entity created upstream. Since we are essentially creating new fields on an existing record (in the platform-wide sense) we're actually modifying existing records.

Questions

Why use specific routes instead of resources?

Since we have nested params (entity_id and entity_type), trying to hack that functionality into Rails routes would most likely result in unexpected bugs and somewhat confusing code. To make our routes as clear as possible I felt that adding each one manually was the best approach.

Why are the stats endpoints so sparse?

Correct. I had thought about various features to add to the stats endpoints, but I'm not 100% sure of their uses-cases yet. Instead of possibly building features we may not need, I'd much rather add some basics to get started then iterate as we discover more use-cases.

tagging_api's People

Contributors

binarycleric avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.