-
Notifications
You must be signed in to change notification settings - Fork 9
Intro to backend module #76
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
Conversation
| Make sure you have `"type": "module"` in your `package.json`. | ||
| Do you see `express` somewhere in `package.json`? | ||
| Make sure you see the `node_modules` folder. | ||
| Also make sure that the `node_modules/` folder is ignored by Git. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its better to add .vscode folder to gitignore too
| ```shell | ||
| npm init -y | ||
| npm pkg set type="module" | ||
| npm install express |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curios why we don't let them use express generator ? its create a good structure for them and they learn to follow best practice
npm install -g express-generator express --no-view
| - [Refresh on REST](https://fullstackopen.com/en/part3/node_js_and_express#rest) | ||
| - [A basic GET Request](https://fullstackopen.com/en/part3/node_js_and_express#fetching-a-single-resource) | ||
| - [A basic DELETE request](https://fullstackopen.com/en/part3/node_js_and_express#deleting-resources) | ||
| - [What is POSTMAN and how to install](https://fullstackopen.com/en/part3/node_js_and_express#postman) - Please install this before the session! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s better to cover modern authentication systems—such as OAuth2, JWT, etc.—and how to use them in Postman here in the document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better than what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean when we introduce them the postman, then on a small hint or just a short video, tell them there is a part on postman that we can set the authorization ( if endpoint have the authorization), so they will not confused in future,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. So is your suggestion simply to point out "sometimes you'll need to add authorization details, and this is where it goes" — without necessarily even mentioning OAuth2, JWT, etc. ?
Because if that's what you're suggesting, then I agree, that's sensible.
The phrasing "to cover modern authentication systems—such as OAuth2, JWT, etc." makes me think of something much more complicated, so I just want to check exactly what it is that you're suggesting.
| - Much more | ||
| - [ ] Simple webserver with node js | ||
| - [ ] npm init | ||
| - [ ] Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I believe students should be asked to write tests for every function and endpoint they implement from this point forward. Mentors should also do the same to demonstrate how it works in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair feedback. Right now we don't cover testing in our existing curriculum. I'm not really sure what this learning goal is about either (see my notes at the top of the pr, I'm planning to remove this) because there is no content in this module about testing either way :D.
This PR is restructuring some of our existing "backend" content into a new "intro to backend" module for the new foundation course. After that, trainees will continue into a frontend course or backend course to further specialise.
So right now, we won't introduce new skills like testing, but it's on the ideas list to explore further soon as a bigger improvement.
|
Thanks for your feedback @reza-faghani! Really appreciate it. Some of your comments are about improvements to the content, which I'll note for a future task. The scope of this PR is restructuring some of our existing content into this new "intro to backend" module that will exist in our foundation course (see my other comment). Do you have any additional feedback on those 4 points I wrote in the description? I'm a bit stuck on those before moving this PR forward 🙏 |
|
Alright, here's my progress on my questions above:
I'm no longer stuck. But if anyone else reviews this PR and has input on the questions/decisions for this module please share. |
|
|
||
| ## Routes | ||
|
|
||
| - `/all-users` should respond with all users sorted by ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find the data that should be stored in the DB in order for this routes to return something.
That makes me thing that if this lesson is about backend:
- we can provide a prefilled DB with
userstable created and sample users. Trainees focus only on backend - Leave the instructions to create the table and add some kind of SQL with several inserts for the trainees to execute in their database. - More complete but also requires tigther setup instructions on the tool used for interacting with the DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the last comment #76 (comment), we'll go with 1, to avoid derailing on setup issues.
Ok, so I just saw (again!) this answer but I already thought about the questions you were stuck with so here's my 2 cents.
|
bhas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me once we get the exercises defined. Node.js is a bit out of my expert area so I only had limited notes
| # Intro to Backend | ||
|
|
||
| TODO | ||
| Here you can find module content and assignments for the Intro to Frontend module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text says Intro to Frontend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙀 my bad, copying and pasting
|
|
||
| - [ ] Introduction to Node.js | ||
| - [ ] [What is node and why node?](https://www.youtube.com/watch?v=pU9Q6oiQNd0) | ||
| - [ ] V8 vs the browser that runs js? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify this learning goal. I don't understand what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nor me. I feel like v8 is out of scope to reference here in foundation. And a can of worms to start talking about, since v8 is not the only engine around. Feels like it needs way more context to understand properly.
Maybe we should talk simply about how javascript can be run differently (i.e. different environments):
- In the browser. Interactivity and fetching data on web pages. Runs in browser engine (chrome, firefox etc.).
- On the server (or on your own computer). Building web servers, accessing databases, running scripts etc. Runs in node.
Then i suggest a learning goal to replace this as "Understand the difference between running JavaScript in the browser vs node"
I imagine a simple table with some similarities/differences could be nice to illustrate it.
Do you agree? Can you make it any more simplified/clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with Bjørn, with v8 as being out of scope and also with the new goal 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamblanchard This (your simplified version) is what is covered in WA101. https://github.com/HackYourFuture-CPH/programme/blob/webarch101/courses/Foundation/web-architecture-101/presentation/8-recap/README.md
| - Web server | ||
| - Much more | ||
| - [ ] Simple webserver with node js | ||
| - [ ] Simple `GET` requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple GET requests is quite vague. Is the goal to create the endpoints for it or to just call existing ones?
Is the goal: "Create simple GET endpoints to retrieve data" or should this goal reside under Postman?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the exercises in the "exercises" directory, they should be creating simple Get endpoints to return some simple data (node version, mysql version, and some specific user data from a database).
I don't see any content regarding postman, besides the learning goals. I suggest we also cover POST here. It's already introduced in webarch101, so we should build on it here with actual usage.
I will also add some lesson plan content for setting up postman and showing people how to use it with some example. Then they could follow up with using it for the assignments too (as we discussed further down).
So regarding learning goals, i suggest these tweaks:
Building a simple webserver
- Creating simple GET endpoints to return data, including from databases
- ...
Sending requests
- ...
- Making GET and POST requests to APIs
I'll update these for now. But please respond if you have a better idea :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DELETE is also mentioned somewhere (can't find it right now!), and since it's simple we should include that here too for the postman part at least. It's an obvious question too ("ok we added stuff, how do we remove stuff").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| - [Client server model](https://www.youtube.com/watch?v=L5BlpPU_muY) (6 min) | ||
| - [HTTP and HTML](https://www.youtube.com/watch?v=1K64fWX5z4U) (7 min) | ||
| - [Video about node](https://www.youtube.com/watch?v=pU9Q6oiQNd0) (13 min) | ||
| - [The structure of a web application](https://www.freecodecamp.org/news/how-the-web-works-part-ii-client-server-model-the-structure-of-a-web-application-735b4b6d76e3/) Up until the "That’s all folks! (Well, sorta…)" part |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should anything regarding the client / server be taught here or in web-architecture-101?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in scope of webarch101, so i will remove it here and add it to the webarch101 task for now (in case it's a good resource and we want to include there instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| mkdir nodejs-week1 | ||
| code nodejs-week1 # to open the folder in VS Code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid relying too much on terminal commands in the foundation unless necessary. Could we just tell the trainees to create a folder and open it via VS code normally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do that. I agree. If someone is already comfortable with the terminal, i guess they will do that naturally anyway.
I'll update these instructions.
|
|
||
| Current suggestions (not decided): | ||
| 1. Add some further basic endpoints to the simple web server they started in the session | ||
| 2. Practice using Postman to create working requests for some public api (each request increasing in complexity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could use a site such as: https://crudcrud.com/ to have the trainees simulate calling a CRUD API. The exercise could require that they hand in some screenshots of the postman requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, that's cool. Sounds good to explore!
Co-authored-by: Marco Richetta <[email protected]>
Co-authored-by: Marco Richetta <[email protected]>
|
After reading the comments and thinking more, regarding the exercises, i suggest we de-scope the set up steps and provide the skeleton code in https://github.com/HackYourFuture-CPH/hyf-assignment-template ready for trainees to use. For example, remove instructions for setting up a new folder, initialising npm, creating app.js file, creating a new database... We instead provide this directory and files (including sqlite db) in the assignment template as a skeleton app that is already runnable. The session lead could still go through the setup and code a little bit, to provide some familiarity, but focus on the trainees practicing the learning goals rather than lots of things they don't need to know and provide distractions. I understand that these are exercises in the session (rather than assignments), but i still think it makes sense to set up in the assignment repo, then they also have it ready to extend for a possible assignment to do after the session. I will go ahead and make these changes so it's easy to review, but @bhas @marcorichetta if you have any thoughts on this in the meantime, let me know! Would appreciate knowing if you think this is the best direction. |
|
LGTM @adamblanchard About the SQLite DB creation, per my instructions create a DB named I left a question in Slack regarding the use of the https://github.com/HackYourFuture-CPH/hyf-assignment-template, just because I don't understand how/if trainees use it. |
|
I shared an example of how I see the skeleton app exercises working (as described above) in this PR HackYourFuture-CPH/hyf-assignment-template#29 If this is apporved, i will make the updates to the exercise readmes in this PR. |
|
Phew, ok, I've made the updates to the exercises to remove the setup and mostly let the trainees fill in the gaps to the provided exercises in hyf-assignment-template. There are stil two todos in this repo, to update the live coding examples (they are too advanced, from legacy nodejs), and to add an assignment. Since this is new content, I will do in a separate task/PR. @marcorichetta Would you be up to review my final instructions? Check out the "exercises" directory. These now reflect the exercises you previously reviewed in hyf-assignment-template here Then i'll merge this! |
Alrighty, here i've tried my best to restructure the content based on the proposal here.
Things I've changed compared to the legacy content:
Other things we should change/that I need help with:
We need a new assignment. The old ones are a mix of meal-sharing, and sql injection, both of which are out of scope of the learning goals here. I have some suggestions, that are not strongly held:
Should we leave knex out here? Since in backend we are introducing sqllite, is there a simpler library/skeleton we can offer for now? And introduce knex in backend specialism as an optimisation?
All of these learning goals are copied over from legacy node.js. I do think they are all relevant for foundation, but we really need clear notes/guidance for the lesson plan on how much detail to go into (e.g. this is about concepts, usage and a little bit of coding practice). I suggest for example not going deep into discussing express or knex, but mentioning what they are and why we are using them (literally a few sentences). If people agree, I can write some notes for the lesson plan, but need someone else to help with "simplifying" the code examples/exercises if necessary.
Saying that, I'm considering removing two learning goals:
I'm tagging some people who I think are somehow related to the above decisions :D @ahmagdy @marcorichetta @markitosha - please help with feedback if you can 🙏