Skip to content

Instantly share code, notes, and snippets.

@psychicbologna
Last active November 17, 2019 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychicbologna/d959ac56d0df815beb94cfe54a29f068 to your computer and use it in GitHub Desktop.
Save psychicbologna/d959ac56d0df815beb94cfe54a29f068 to your computer and use it in GitHub Desktop.
backend-analysis-capstone2
Which database tables are created in the migrations?
user, language and word
What are the endpoints for user registration, login and refresh?
Registration: POST /
Login: POST /token
Refresh: PUT /token
What endpoints have been implemented in the language router?
GET /, GET /head & POST /guess.
What is the async and await syntax for? (Hint)
Async means a function always returns a promise, either explicitly or in a .then chain; await forces javascript to wait until the promise is resolved, ie returns a response. It is functionally similar to .then. While await doesn't work on top level code, it can be wrapped in an anonymous async function. Error handling is best done with try/catch at the top level of code, or .then/.catch in async functions where 'await' can't be used.
Which endpoints need implementing in the language router?
/head and /guess
How does the GET /api/language endpoint decide which language to respond with? (Hint: Does it relate to the user that made the request?)
After use auth in .use(requireAuth), it uses getUsersLanguage() to verify that the user has an assigned language, and retrieves the language the user is using. It then gets the words with the getLanguageWords() service.
In the UserService.populateUserWords method, what is db.transaction?
It is an all-or-nothing transaction to populate and sequence the words for a user. The 'head' acts as the top of the queue for a given sequence of words.
Hints:
https://knexjs.org/#Transactions
https://knexjs.org/#Builder-transacting
https://www.postgresql.org/docs/8.3/tutorial-transactions.html
https://www.tutorialspoint.com/postgresql/postgresql_transactions.htm
What is SERIAL in the create migration files? (Hint)
What is setval in the seed file? (Hint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment