Helping Kiva vet its microloan applications
Here's our project plan
Temple University's Hack4Impact Chapter
- Jake Lawrence
- Nasir K
- Jared Massa
- Brendan Manning
- Install server dependencies
cd server && npm install && cd ..
- Install client dependencies
cd client && npm install && cd ..
- Tap and Install MongoDB Server
brew tap mongodb/brew && brew install [email protected]
- Start the server
mongod --config /usr/local/etc/mongod.conf
- You can access the local mongob concole by running
mongo
- Modify
server/public/config.js
, filling in the appropriate values - Modify
client/src/config.js
with appropriate additional values in order to customize FAQs, practice videos, and practice loans. To add a practice loan, you must first add the ID of the loan to theloanIDs
array at the top of the file, and then add the ID of the loan to the correct column and corresponding row of the loan you wish to add, in the CSV file that contains the loan (server/data/...
) - Modify
client/src/index.js
, replacing the urls in theloadJS(<url>)
calls with the URL Crowdvet server will be running on. - Edit the two url constants at the top of
server/src/public/classes/APIRequest.js
- See the
Sensitive Data
Google Doc and follow all steps there.
- In the root folder
yuidoc . -o doc
(Use three different terminal windows for this)
- Open the
server
folder and runyarn start
- Open the
client
folder and runyarn start
- As described above, start the server
mongod --config /usr/local/etc/mongod.conf
In order to share Loan.js
, APIRequest.js
, and config.js
classes between client and server, I had to make a few tweaks, which you should keep in mind:
- Because code intended for the server only will require dependencies unavailable on the client, in these three files use const module = require(....) inside the requiring function. Do not create any top-level import/require statements
- Likewise, when requiring one of these "shared" files on the server, you may need to use the form var Config = require('./public/config.js').default;
- On the clientside, prefix each class name with widow *(var loan = new window.Loan())
On the client side, the user object can be easily accessed and manipulated through window.user
. Whatever changes you make through the await window.user.update
function will be reflected in the browser and on the server. Overall this should make for a fluid experience, however, there are a few things you should know.
window.user
is nullable. A null window.user can mean that we are logged out or have not finished loading data yet. Therefore, this is a poor way to check authentication/loaded state.- To check if the user is logged in, check
window.loggedIn
. If this istrue
the user is logged in (though perhaps not fully loaded yet). If this is eitherfalse
ornull
the user is logged out or not loaded yet. - To redirect away from pages that do not work for logged out users, implement the
allowRedirectIfDesired()
method in your page's builder object, like soallowRedirectIfDesired() { if(window.loggedIn == false || window.loggedIn == null) { window.location.href = '/login'; } }
- For pages that require all user data to be loaded. You can render null content for your page when
window.user.inited != true
. To ensure that your page reloads when the user object becomes fully available, implementrerenderOnUserLoaded
in your builder, like sorerenderOnUserLoaded() { return true; }
- https://fontawesome.com/license
- Using progress loader code from https://www.w3schools.com/howto/howto_css_loader.asp
- A lot more we have to add