Coder Social home page Coder Social logo

hack-your-future's Introduction

Simple Bank App

The server.js file contains a simple nodejs webapp that lets users manage their money in their accounts.

Get Started

Run the following for installing node package dependencies (within this directory):

    npm install express node-fetch config

You should now be able to run the server by selecting the Debug tab in VS Code and clicking on the green play button

Explore the app

After running the app, visit

    localhost:3000/balances

to see the userId and balance information.

To add some money to a user's account you can visit:

    localhost:3000/updatebalance?userId=USER_ID_HERE&amount=AMOUNT

USER_ID_HERE should be set to userId we want to update, and AMOUNT should be set to the amount of money this person should receive.

So, if we want to update user with id 0's account balance by 100, we visit:

    localhost:3000/updatebalance?userId=0&amount=100

You can see that there's already a bug! We expected user 0's balance to increase by 100! (Bug #1 !)

Debugging the app

You can set breakpoints in VS Code and trigger them by visiting the urls mentioned above.

Known Bugs

  1. Visit

     localhost:3000/updatebalance?userId=0&amount=100
    

in your browser. Did the user 0's money increase by 100?

  1. Visit

     localhost:3000/updatebalance?userId=&amount=100
    

note that user with id 0 still got its balance updated. Why?

  1. Visit

     http://localhost:3000/updatebalance?userId=0&amount=million
    

note that the user with id 0 got its balance updated. Would you want the app to update your app by 1000000 if you type in million? How can you prevent the null value in the balance when a random string is inserted?

  1. Visit

     http://localhost:3000/updatebalance?userId=42&amount=10
    

User 42 didn't exist yet, check the debug console log. How to prevent this TypeError? What should the app do here?

  1. Are there any other bugs you can trigger?

  2. Update the file the "blackbox-server-url" property in "config/default.json" file. This value will be provided. Now there's a new endpoint at:

     localhost:3000/blackbox
    

This endpoint invokes an external service and from the response from this service, it updates our userbalances database. However, it turns out sometimes the database is corrupted! Figure out what's happening and think of a workaround.

hack-your-future's People

Contributors

bcanvural avatar hippo-readonly avatar nielsout 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.