Coder Social home page Coder Social logo

moneybook_api's Introduction

MoneyBook API Server

This is a sample in order to provide an example of a JSON API server built with Hanami Framework using JWT based authentication.

There is a tutorial for implementation of this project. Please Visit here(Korean)

Main features:

  • Implement a token based authentication using JWT Gem
  • Store encrypted password in the database with BCrypt
  • Return a JSON representation of resources

Development environment

  • Ruby v2.4.1
  • Hanami v1.0.0
  • Postgresql v9.6.2

Getting started

Before the beginning

You need at least Ruby v2.3+, and bundler. If you have not installed Hanami, Please install it with this command first.

gem install hanami

You need postgresql installed as well, or change Gemfile in order to use SQLite3 instead.

# Gemfile
# ...
gem 'pg' # => gem 'sqlite3'
# ...

Clone the repo

git clone [email protected]:emaren84/moneybook_api.git
cd moneybook_api
bundle install

then you should create .env.* files for development and test environment. and set DATABASE_URL, JWT_ISSUER, JWT_SECRET.

# .env.development / .env.test
DATABASE_URL="postgresql://username:password@localhost/moneybook_api_development" # or moneybook_api_test
JWT_ISSUER="localhost" # or Your domain name
JWT_SECRET="your secret" # Strongly recommend SHA-256 encrypted hash

DATABASE_URL have to be changed that if you want to use SQLite3 as a databse engine.

DATABASE_URL="sqlite://db/moneybook_api_development"

Prepare databases

bundle exec hanami db prepare
bundle exec hanami db migrate
HANAMI_ENV=test bundle exec hanami db prepare
HANAMI_ENV=test bundle exec hanami db migrate

Test the app

bundle exec rake test

Tests aren't elegant nor covering whole application yet. It needs to be improved.

Start the server

bundle exec hanami server

By deafult Hanami development server is launched at http://localhost:2300

moneybook_api's People

Watchers

 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.