Code Monkey home page Code Monkey logo

time-tracker-challenge's Introduction

refactored approach

TimeTracker API

Getting started

  1. bundle install
  2. bundle exec rake db:migrate
  3. bundle exec rake db:seed (for test data)
  4. For API docs: bundle exec rake docs:generate
  5. Open API docs open doc/api/index.html

Implementation

Time entries are started and stopped by switching the started_at property from nil to a time and vice versa. This allows for REST-like manipulation of time entries without 'start' or 'stop' methods and routes.

Task types are defined on a company basis in this implementation, it would also be perfectly valid to define them at the top level of the app, or a mix of both as well.

JSON API

The generated documentation provides most of the fine-grain detail into the requests and responses of the API, but here are a few broad conventions:

JSON responses will be wrapped with with a root element. If you're using Backbone.js you might have to override the parse method on your models. If you are using Ember.js you will probably want to use the RESTAdapter and customize the serializer to user underscores. Angular.js and React should work just fine out of the box.

Rails' parameter wrapping for JSON is enabled so even though the generated API documentation shows that the POST body need a key like this:

{"project":{"name":"Test project name"}}

It can intead be submitted like this so that it mirrors the response:

{"name":"Test project name"}

Authentication

The is application is using Devise for authentication: https://github.com/plataformatec/devise

Additionally it uses the simple_token_authentication gem which allows you to pass the user email and token as headers or query params for authentication:

http://localhost:3000/[email protected]&user_token=some_token_generated_after_seed

More info here

HTTP basic auth is also enabled and can be passed in the header of XHR requests.

Other notes

SQLite3 and Ruby version 2.0.0 or higher required.

The test user email is "[email protected]" with a super secret password of "supersecret." See db/seeds.rb for more information.

time-tracker-challenge's People

Contributors

jannypie avatar

Watchers

James Cloos avatar  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.