Closed ghost closed 3 years ago
Please complete after you've viewed the Week 1 livestream! If you haven't yet watched it but want to move on, just close this issue and come back to it later.
Help us improve BitCamp Serverless - thank you for your feedback! Here are some questions you may want to answer:
1) I think the content was not too difficult and the live stream was very helpful as it was a very good guide in helping beginners get started with Azure functions and Javascript. It was a little challenging, which is a good thing and the live stream helped me complete this week's homework. 2) The pace was too fast because not everything is understood at first glance, which is totally fine because I don't want you guys to take 5 hours to do the live stream lol (if you guys had that time though, it would be amazing). However, I could not keep up at the pace you guys were and I fell behind very quickly. 3) I think just slowing down a bit more would be an improvement, but apart from that, everything is good!
That's it for Week 1, move on to Week 2 in your new issue!
Week 1 Step 8 ⬤⬤⬤⬤⬤⬤⬤⬤◯ | 🕐 Estimated completion: 5-15 minutes
[TOP SECRET] Morse Code Converter
✅ Tasks:
git pull
and create a new branch calledmorse
morse-code-converter
packagemorse
withmorse-code-converter
that takes in English as a parameter and outputs it in Morse CodeMORSE_ENDPOINT
and commit your function's code to a file namedmorse/index.js
to themorse
branchmorse
tomain
, but do not merge it1: Installing Packages
Create a new HTTP trigger function in your Azure portal along with the Function App. Navigate to your Function App. This is not the function code, but the actual app service resource.
We will be using the
morse-code-converter
npm package.:question: Why do we need these "packages" and what are they?
Packages are awesome! They're chunks of publicly available code that someone else has written to help make coding easier for everyone else. These packages reusable code that increases functionality in your code. Before the Azure Function can run the code we will write, we have to install all the necessary package dependencies. These packages contain **code that we will "depend on" in the application**; we have to install them in the console using `npm install`. [What is a package?](https://www.w3schools.com/nodejs/nodejs_npm.asp) [What is the morse-code-converter package?](https://www.npmjs.com/package/morse-code-converter):question: How do I install the package?
In the left tab, scroll down to Console: ![console](https://user-images.githubusercontent.com/52464195/93178238-cf5c4e00-f6e8-11ea-90ab-c42f746cf04e.png) Enter these commands in order: ```sh npm init -y npm install morse-code-converter ```:exclamation: Woah! What just happened when the package was installed?
The first command created a **package.json** file to store your dependencies and essentially keeps track of what packages your application needs. You can find this file by going into the left menu and clicking on "App Files". The next one actually installs the necessary packages with code, `morse-code-converter`. *Note: If you get red text like `WARN`, you can ignore it.*2: Using morse-code-converter
:question: How do I receive the English as a parameter?
[Query parameters](https://rapidapi.com/blog/api-glossary/parameters/query/) can be accessed from the `req` object in the input of the `module.exports` function. > :bulb: Since ours is named `plaintext`, we can access it with `req.query.plaintext`. **How would I send the English?** [place your function url here]&plaintext=[insert the English]:question: How do I use the Morse Code package?
**Tip**: Try reading the [documentation](https://www.npmjs.com/package/morse-code-converter) first. ```js const morse = require("morse-code-converter"); const code = morse.textToMorse('Hey how are you?'); // .... . -.-- .... --- .-- .- .-. . -.-- --- ..- ..-.. const text = morse.morseToText(code); // HEY HOW ARE YOU? ```:question: Um. Body?
**Tip**: `context.res` is the object you use to return a response to the user. ```js context.res = { body: [insert your encoded English here] }; ```:exclamation: Don't forget to
git pull
before making any changes to your local repo!!Remember: we test your Morse Code function everytime you commit!