In this project you will create a Command-Line-Interface (CLI) app.
Phase 1 of the project involves making sure the proper tools are installed.
Phase 2 of the project involves making a basic CLI app that has a “complete-the-sentence” function in Inquirer.
Phase 3 of the project involves adding an additional feature: the CLI app can now create additional users and store that information in PostgreSQL.
Phase 4 of the project involves adding an additional feature: using eventful-node to perform AJAX requests in order to pull data from the Eventful API, and giving the user the option to save to your own PostgreSQL database.
Phase 5 of the project involves adding the final 3 features: matching a user with an event, reading all the users of a particular event, and reading all the events of a particular user. You’ll work with an inner join (many-to-many relationship junction) table.
This is a CLI because we are focusing on using an API to interact with a database. We are specifically not implementing a graphical front end for Eventonica this week! We’ll get to that in a future week.
Follow Setup Postgres if you haven’t already.
You’ll be making your own fork of this starter code, and building on top of it.
Note: In this project, the instructions to complete the project after the installation & setup steps will be increasingly vague. This is done intentionally to get you used to thinking like a software engineer.
cd
into your new folder =)keys.js
file in your project root.Go to Eventful’s API page, create an account, and apply for your own API key. The application process for an API key is instant. The API Key registration asks for a mailing address and phone number. These cannot be left blank, but typing “N/A” in the fields works.
Tell your app about your new Eventful API key as well as your PostgreSQL database by adding the following to your keys.js
file:
json module.exports = { "eventful": '<YOUR_OWN_EVENTFUL_API_KEY_HERE>', "dbPassword": '<YOUR_EVENTONICA_POSTGRES_PASSWORD_HERE>' }
npm start
, yarn start
or nodemon
in the terminal. Now uncomment the dbConnect()
line. You should see the console produce some lines about Eventonica, YAY!PAUSE. Help your group members finish Part 1.
Try running index.js
with Node/Nodemon to see how Inquirer works. Play with it; once you feel comfortable, start looking at the starter code and also skim through this Inquirer.js tutorial. If you want to check out something a little more comprehensive, the project itself has many examples which demonstrate specific input methods that the library supports.
When you’re composing your questions think about what information the user of the app will have, and how do you make it as easy as possible to “get the answers right”.
Command Line Interfaces (CLIs) are a great place to use your regex skills to get the data right.
Now implement the first option: “Complete a sentence.” Use inquirer to ask users for 2 string inputs to console log a complete sentence.
Examples of a sentence to be completed (feel free to make up one on yourself):
So if you choose the first example, and the user enters “red” and “house”, you should see “My favorite color is red, so my dream is to buy a red house.”
Learn about pools and clients by reading the documentation for node-postgres.
Now implement the ability to create new users. First create a database in Postgres (in your graphical client app or terminal) called “eventonica”, and then create a Users and an Events table.
Switching back to JavaScript in VSCode, using Inquirer, implement code in app.createNewUser
to ask for a new fictitious users name and age, or some other attribute. Then, display this information and save it to your Postgres database.
Finally, using your database client, run a SELECT
query against your Users table to verify that your users are successfully created.
Run the starter code in eventfulAPI.js and read about eventful-node and Eventful API Once you feel comfortable about understanding what the code is doing, commenting out the example search code and implement your custom search code in app.searchEventful
.
Use Inquier to:
Look at your console log UI and you should see new events.
Examine Program flow Our program is taking the following steps:
Each of these steps requires the result of the previous. In order to implement this, you’d have to use either callback chaining OR promises. Promises require more setup but it creates cleaner-looking code. Part 4 should take the majority of your project time as there are a lot of steps involved.
Note This step is shorter but is about leveling up your knowledge of SQL by giving you experience using a junction table and JOINs. It can be tricky so watch out for frustration!
Now that we have Users and Events, let’s start to add the ability to create relationships between them. One user can be marked as attending multiple events, and one event can have multiple users attending it. This is called a Many-to-Many relationship. Watch this tutorial to learn more about them.
Using a junction (inner-join) table, complete the 3 remaining features/functions:
Make sure each endpoint and function has a simple passing test. Then add as many as you can!