jessicadlc101 / severless-camp-repository-

GNU General Public License v3.0
0 stars 1 forks source link

[TOP SECRET] Please open #8

Closed ghost closed 3 years ago

ghost commented 3 years ago

Week 1 Step 8 ⬤⬤⬤⬤⬤⬤⬤⬤◯ | 🕐 Estimated completion: 5-15 minutes

[TOP SECRET] Morse Code Converter

Dwight being a spy

Welcome agent! You have made it this far so we know we can trust you. BitProject is working in an undercover operation, and we need a new way to communicate.

✅ Tasks:

:exclamation: Do not merge the branch!!

1: 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". Screen Shot 2021-04-26 at 3 15 21 AM 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.* Screen Shot 2021-04-26 at 3 12 43 AM

:books: Reminder: don't forget to import your package! const morse = require("morse-code-converter");

:bulb: Make sure your parameter is named plaintext

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? ```

:bulb: Be sure to return the code in the body of the response!

: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!

ghost commented 3 years ago

📝 Week 1 Livestream Feedback

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.

Comment your feedback:

Help us improve BitCamp Serverless - thank you for your feedback! Here are some questions you may want to answer:

:camping: To move on, comment your feedback.

jessicadlc101 commented 3 years ago
  1. As a beginner, I felt stuck a lot of the time because I never had the right applications downloaded. I found the material to be challenging, but ultimately it felt gratifying when a function worked and I hope with practice it will take me less time to complete steps.
  2. During last week's live lecture I felt it was hard to follow along but again it was because I didn't have a lot of applications downloaded which hindered my ability to follow along, hoping next week will go smoother!
  3. I really appreciate when Daniel would ask a lot of questions to Chloe and Emily about definitions/"what does this do"/"how does this help us" as someone who's never coded before knowing why I am doing something and what it's actually doing helps me retain the information better!
ghost commented 3 years ago

That's it for Week 1, move on to Week 2 in your new issue!