Giter Club home page Giter Club logo

14ers-api-backend's Introduction

mySummits Backend (Flatiron School Mod3 Project)

Functionality

There are several Classes and Relationships at play. Users and Mountains are joined via two M:M relationships, one through the Summit class and one through the Comments class. This allows each individual user to log a Summit and leave a Comment about recent conditions on each Mountain. Users must login using a Bearer token, which customizes their frontend experience and only allows them to log summits and leave comments from their personal account. I also created much of the backend seed data for the 14ers from scratch, with each mountain having its Colorado rank, elevation, range, and an image.

Lessons and Challenges

  1. Multiple Migrations: As the scope of the project changed, I had to make adjustments to the schema fairly deep into development. All told it required 13 seperate migrations, and I was terrified that each one would break something critical. I learned a ton about migrations and the proper and safe procedures for adjusting database tables.
  2. Authentication: Auth was a totally new concept for me, and it wasn't introduced until very late in Mod3. Perhaps the biggest "win" for me in this entire project was getting a user logged in and authenticated with a token.
  3. Validations and Controller Actions: For the first time in any of my projects, I included a serializer, model validations, and more complicated controller actions. For example, a User can only log a particular Summit once, and Comments are restricted in length to 250 characters.
    def login
        @user = User.find_by(username: params[:user][:username])

        if !@user
            render json: {message: 'Bad username'}, status: :unauthorized
        else
            if [email protected] params[:password]
                render json: {message: 'Bad password'}, status: :unauthorized
            else
                payload = {
                    user_id: @user.id
                }
                secret = Rails.application.secret_key_base
                token = JWT.encode(payload, secret)

                render json: {user: @user, token: token}, status: :created
            end
        end
    end

Future Features and Goals

  1. Allow a new user to register themselves.
  2. Since I had to create the fairly complex seed data for each 14er from scratch, I believe this is a good candidate to turn into a public API for other developers to use.
  3. Add latitude/longitude data to the 14er seeds and explore mapping functionality.

14ers-api-backend's People

Watchers

Jeff Golden 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.