Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parserator challenge #34

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

NoahAppelbaum
Copy link

Overview

This PR consists of two major parts:

  • A backend JSON API endpoint, which parses U.S. address strings using usaddress
  • JavaScript for the previously built static frontend, which provides a simple form for a user to enter an address, calls the API, and renders the returned parsed address information in the UI

This PR also includes tests for the API endpoint, and a few other small fixes and adjustments (enumerated below)

Closes #XXX

Demo

Functioning app with network request:
Screenshot 2024-07-12 at 10 40 56 AM

Displaying an error message:
Screenshot 2024-07-12 at 10 41 33 AM

Tests passing
Screenshot 2024-07-12 at 10 42 45 AM

Notes

Other changes:

  • Added npm to the apt-get... line in the Dockerfile, to fix an npm not found error when building
  • In the Index.html template, changed the inline display: none styling on the address results div to use Bootstrap's d-none utility class. This maintains consistency with the rest of the page's styling, and makes manipulating the div's styling through JavaScript more straightforward.
  • This coding challenge was completed by me, Noah Appelbaum

Testing Instructions

How to Test

  • Build with
    docker-compose build
    
  • Run tests with
    docker-compose -f docker-compose.yml -f tests/docker-compose.yml run --rm app
    

New Test Cases

  • test_api_parse_succeeds -- The API should respond successfully, with expected JSON, on a valid address
  • test_api_parse_succeeds_on_empty_string -- the API should respond successfully on an empty string, consistent with the output of usaddress and expected frontend behavior
  • test_api_parse_raises_error -- The API should raise an error on an invalid address input
  • test_api_parse_raises_error_on_missing_address_string -- The API should raise an error when missing address input (from a malformed request, e.g.)

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term>
npm help npm       more involved overview

All commands:

    access, adduser, audit, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    help-search, hook, init, install, install-ci-test,
    install-test, link, ll, login, logout, ls, org, outdated,
    owner, pack, ping, pkg, prefix, profile, prune, publish,
    query, rebuild, repo, restart, root, run-script, search,
    set, shrinkwrap, star, stars, start, stop, team, test,
    token, uninstall, unpublish, unstar, update, version, view,
    whoami

Specify configs in the ini-formatted file:
    /Users/noahappelbaum/.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

[email protected] /opt/homebrew/lib/node_modules/npm to apt-get command explicitly, to fix Unknown command: "not"

To see a list of supported npm commands, run:
  npm help error on Docker build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant