Fix challenge title formatting misc
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb0367417b2b2512bee",
|
||||
"title": "Start a working Express Server",
|
||||
"title": "Start a Working Express Server",
|
||||
"description": [
|
||||
"In the first two lines of the file myApp.js you can see how it’s easy to create an Express app object. This object has several methods, and we will learn many of them in these challenges. One fundamental method is app.listen(<port>). It tells your server to listen on a given port, putting it in running state. You can see it at the bottom of the file. It is inside comments because for testing reasons we need the app to be running in background. All the code that you may want to add goes between these two fundamental parts. Gomix stores the port number in the environemet variable process.env.PORT. Its value is 3000.",
|
||||
"Let’s serve our first string ! In Express, routes takes the following structure: app.METHOD(PATH, HANDLER). METHOD is an http method in lowercase. PATH is a relative path on the server (it can be a string, or even a regular expression). HANDLER is a function that Express calls when the route is matched.",
|
||||
@@ -77,7 +77,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb0367417b2b2512bef",
|
||||
"title": "Serve an HTML file",
|
||||
"title": "Serve an HTML File",
|
||||
"description": [
|
||||
"We can respond with a file using the method res.sendFile(<file>).",
|
||||
"You can put it inside the app.get('/', ...) route handler. Behind the scenes this method will set the appropriate headers to instruct your browser on how to handle the file you want to send, according to its type. Then it will read and send the file. This method needs an absolute file-path. We recommend you to use the node global variable __dirname to calculate the path.",
|
||||
@@ -100,7 +100,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb0367417b2b2512bf0",
|
||||
"title": "Serve Static assets",
|
||||
"title": "Serve Static Assets",
|
||||
"description": [
|
||||
"An HTML server usually has one or more directories that are accessible by the user. You can place there the static assets needed by your application (stylesheets, scripts, images). In Express you can put in place this functionality using the middleware express.static(<public-dir-absolute_path>). If don’t know what a midleware is, don’t worry. We’ll discuss about it later in details. Basically middleware are function that intercept route handlers, adding some kind of information. A middleware needs to be mounted using the method app.use([optional-path], <mware function>). The first path argument is optional. If you don’t pass it, the middleware will be executed for all the requests.",
|
||||
"Mount the express.static() middleware for all the requests with app.use(). The absolute path to the assets folder is __dirname + /public.",
|
||||
@@ -121,7 +121,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb1367417b2b2512bf1",
|
||||
"title": "Serve JSON on a specific route",
|
||||
"title": "Serve JSON on a Specific Route",
|
||||
"description": [
|
||||
"While an HTML server serves (you guessed it!) HTML, an API serves data. A <dfn>REST</dfn> (representational state transfer) API allows data exchange in a simple way, without the need for clients to know any detail about the server. The client only needs to know where the resource is (the URL), and the action it wants to perform on it (the verb). The GET verb is used when you are fetching some information, without modifying anything. These days, the preferred data format for moving information around the web is JSON. Simply put, JSON is a convenient way to represent a JavaScript object as a string, so it can be easily transmitted.",
|
||||
"Let's create a simple API by creating a route that responds with JSON at the path <code>/json</code>. You can do it as usual, with the <code>app.get()</code> method. Inside the route handler use the method <code>res.json()</code>, passing in an object as an argument. This method closes the request-response loop, returning the data. Behind the scenes it converts a valid Javascript object into a string, then sets the appropriate headers to tell your browser that you are serving JSON, and sends the data back. A valid object has the usual structure <code>{key: data}</code>. Data can ba a number, a string, a nested object or an array. Data can also be a variable or the result of a function call; in which case it will be evaluated before being converted into a string.",
|
||||
@@ -142,7 +142,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb1367417b2b2512bf2",
|
||||
"title": "Use the .env file",
|
||||
"title": "Use the .env File",
|
||||
"description": [
|
||||
"The <code>.env</code> file is a hidden file that is used to pass environment variables to your application. This file is secret, no one but you can access it, and it can be used to store data that you want to keep private or hidden. For example, you can store API keys from external services or your database URI. You can also use it to store configuration options. By setting configuration options, you can change the behavior of your application, without the need to rewrite some code.",
|
||||
"The environment variables are accessible from the app as <code>process.env.VAR_NAME</code>. The <code>process.env</code> object is a global Node object, and variables are passed as strings. By convention, the variable names are all uppercase, with words separated by an underscore. The <code>.env</code> is a shell file, so you don’t need to wrap names or values in quotes. It is also important to note that there cannot be space around the equals sign when you are assigning values to your variables, e.g. <code>VAR_NAME=value</code>. Usually, you will put each variable definition on a separate line.",
|
||||
@@ -163,7 +163,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb1367417b2b2512bf3",
|
||||
"title": "Implement a Root-level Request Logger Middleware",
|
||||
"title": "Implement a Root-Level Request Logger Middleware",
|
||||
"description": [
|
||||
"Before we introduced the express.static() middleware function. Now it’s time to see what middleware is, in more detail. Middleware functions are functions that take 3 arguments: the request object, the response object, and the next function in the application’s request-response cycle. These functions execute some code that can have side effects on the app, and usually add informations to the request or response objects. They can also end the cycle sending the response, when some condition is met. If they don’t send the response, when they are done they start the execution of the next function in the stack. This is triggered calling the 3rd argument next(). More information here in the express documentation.",
|
||||
"Look at the following example :",
|
||||
@@ -279,7 +279,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb2367417b2b2512bf7",
|
||||
"title": "Use Body-Parser to Parse POST Requests",
|
||||
"title": "Use body-parser to Parse POST Requests",
|
||||
"description": [
|
||||
"Besides GET there is another common http verb , it is POST. POST is the default method used to send client data with HTML forms. In the REST convention POST is used to send data to create new items in the database (a new user, or a new blog post). We don’t have a database in this project, but we are going to learn how to handle POST requests anyway.",
|
||||
"In these kind of request the data doesn’t appear in the URL, it is hidden in the request body. This is a part of the HTML request, also called payload. Since HTML is text based, even if you don’t see the data, it doesn’t mean that they are secret. The raw content of an HTTP Post is shown below:",
|
||||
|
@@ -31,7 +31,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb3367417b2b2512bfb",
|
||||
"title": "Using Package.json, The Core of Any Node.js Project or npm Package",
|
||||
"title": "How to Use package.json, the Core of Any Node.js Project or npm Package",
|
||||
"description": [
|
||||
"The file package.json is the center of any Node.js project or npm package. It stores information about your project just like the <head>-section in a HTML document describes the content of a webpage. The package.json consists of a single JSON-object where information is stored in \"key\": value-pairs. There are only two required fields in a minimal package.json - name and version - but it’s a good practice to provide additional information about your project that could be useful to future users or maintainers.",
|
||||
"The author-field",
|
||||
@@ -117,7 +117,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb4367417b2b2512bfe",
|
||||
"title": "Add a license to your package.json",
|
||||
"title": "Add a License to Your package.json",
|
||||
"description": [
|
||||
"TODO: This challenge could be used to inspire more people to develop OSS - we should really improve this description.",
|
||||
"The license-field is where you inform users of your project what they are allowed to do with it.",
|
||||
@@ -166,7 +166,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb4367417b2b2512c00",
|
||||
"title": "Expand your project with external packages from npm",
|
||||
"title": "Expand Your Project with External Packages from npm",
|
||||
"description": [
|
||||
"One of the biggest reasons to use a package manager is their powerful dependency management. Instead of manually having to make sure that you get all dependencies whenever you set up a project on a new computer, npm automatically installs everything for you. But how can npm know exactly what your project needs? Meet the dependencies-section of your package.json.",
|
||||
"In the dependencies-section, packages your project require are stored using the following format:",
|
||||
@@ -233,7 +233,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb5367417b2b2512c02",
|
||||
"title": "Use the tilde-character to always use the latest patch version of a dependency",
|
||||
"title": "Use the Tilde-Character to Always Use the Latest Patch Version of a Dependency",
|
||||
"description": [
|
||||
"In the last challenge, we told npm to only include a specific version of a package. That’s a useful way to freeze your dependencies if you need to make sure that different parts of your project stay compatible with each other. But in most use cases you don’t want to miss bug fixes, since they often include important security patches and (hopefully) don’t break things in doing so.",
|
||||
"To allow a npm dependency to get updated to the latest PATCH-version, you can prefix the dependency’s version with the tilde-character (~). In package.json, our current rule for how npm may upgrade moment is to use a specific version only (2.10.2), but we want to allow the latest 2.10.x-version.",
|
||||
@@ -262,7 +262,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb5367417b2b2512c03",
|
||||
"title": "Use the caret-character to use the latest minor version of a dependency",
|
||||
"title": "Use the Caret-Character to Use the Latest Minor Version of a Dependency",
|
||||
"description": [
|
||||
"Similar to how the tilde (~) we learned about in the last challenge allow npm to install the latest PATCH for a dependency, the caret (^) allows npm to install future updates as well. The difference is that the caret will allow both MINOR updates and PATCHes.",
|
||||
"At the moment, your current version of moment should be ~2.10.2 which allows npm to install to the latest 2.10.x-version. If we instead were to use the caret (^) as our version prefix, npm would instead be allowed to update to any 2.x.x-version.",
|
||||
@@ -291,7 +291,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb5367417b2b2512c04",
|
||||
"title": "Remove a package from your dependencies",
|
||||
"title": "Remove a Package from Your Dependencies",
|
||||
"description": [
|
||||
"Now you’ve tested a few ways you can manage dependencies of your project by using the package.json's dependencies-section. You’ve included external packages by adding them to the file and even told npm what types of versions you want by using special characters as the tilde (~) or the caret (^).",
|
||||
"But what if you want to remove an external package that you no longer need? You might already have guessed it - Just remove the corresponding \"key\": value-pair for that from your dependencies.",
|
||||
|
@@ -117,7 +117,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb7367417b2b2512c0a",
|
||||
"title": "Create Many Records with Model.create()",
|
||||
"title": "Create Many Records with model.create()",
|
||||
"description": [
|
||||
"Sometimes you need to create many instances of your models, e.g. when seeding a database with initial data. Model.create() takes an array of objects like [{name: 'John', ...}, {...}, ...] as the first argument, and saves them all in the db. Create many people with Model.create(), using the function argument arrayOfPeople."
|
||||
],
|
||||
@@ -136,7 +136,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb7367417b2b2512c0b",
|
||||
"title": "Use Model.find()",
|
||||
"title": "Use model.find() to Search Your Database",
|
||||
"description": [
|
||||
"Find all the people having a given name, using Model.find() -> [Person]",
|
||||
"In its simplest usage, Model.find() accepts a query document (a JSON object ) as the first argument, then a callback. It returns an array of matches. It supports an extremely wide range of search options. Check it in the docs. Use the function argument personName as search key."
|
||||
@@ -156,7 +156,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb7367417b2b2512c0c",
|
||||
"title": "Use Model.findOne()",
|
||||
"title": "Use model.findOne() to Return a Single Matching Document from Your Database",
|
||||
"description": [
|
||||
"Model.findOne() behaves like .find(), but it returns only one document (not an array), even if there are items. It is especially useful when searching by properties that you have declared as unique. Find just one person which has a certain food in her favorites, using Model.findOne() -> Person. Use the function argument food as search key."
|
||||
],
|
||||
@@ -175,7 +175,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb7367417b2b2512c0d",
|
||||
"title": "Use Model.findById()",
|
||||
"title": "Use model.findById() to Search Your Database By _id",
|
||||
"description": [
|
||||
"When saving a document, mongodb automatically adds the field _id, and set it to a unique alphanumeric key. Searching by _id is an extremely frequent operation, so moongose provides a dedicated method for it. Find the (only!!) person having a given _id, using Model.findById() -> Person. Use the function argument personId as search key."
|
||||
],
|
||||
@@ -215,7 +215,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb8367417b2b2512c0f",
|
||||
"title": "Perform New Updates Using Model.findOneAndUpdate()",
|
||||
"title": "Perform New Updates on a Document Using model.findOneAndUpdate()",
|
||||
"description": [
|
||||
"Recent versions of mongoose have methods to simplify documents updating. Some more advanced features (i.e. pre/post hooks, validation) behave differently with this approach, so the Classic method is still useful in many situations. findByIdAndUpdate() can be used when searching by Id.",
|
||||
"Find a person by Name and set her age to 20. Use the function parameter personName as search key.",
|
||||
@@ -236,7 +236,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb8367417b2b2512c10",
|
||||
"title": "Delete one Record",
|
||||
"title": "Delete One Document Using model.findByIdAndRemove",
|
||||
"description": [
|
||||
"Delete one person by her _id. You should use one of the methods findByIdAndRemove() or findOneAndRemove(). They are like the previous update methods. They pass the removed document to the cb. As usual, use the function argument personId as search key."
|
||||
],
|
||||
@@ -255,7 +255,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb8367417b2b2512c11",
|
||||
"title": "Delete Many Records with Model.remove()",
|
||||
"title": "Delete Many Documents with model.remove()",
|
||||
"description": [
|
||||
"Model.remove() is useful to delete all the documents matching given criteria. Delete all the people whose name is “Mary”, using Model.remove(). Pass to it a query ducument with the “name” field set, and of course a callback.",
|
||||
"Note: Model.remove() doesn’t return the deleted document, but a JSON object containing the outcome of the operation, and the number of items affected. Don’t forget to pass it to the done() callback, since we use it in tests."
|
||||
@@ -275,7 +275,7 @@
|
||||
},
|
||||
{
|
||||
"id": "587d7fb9367417b2b2512c12",
|
||||
"title": "Chain Search Query Helpers",
|
||||
"title": "Chain Search Query Helpers to Narrow Search Results",
|
||||
"description": [
|
||||
"If you don’t pass the callback as the last argument to Model.find() (or to the other search methods), the query is not executed. You can store the query in a variable for later use. This kind of object enables you to build up a query using chaining syntax. The actual db search is executed when you finally chain the method .exec(). Pass your callback to this last method. There are many query helpers, here we’ll use the most ‘famous’ ones.",
|
||||
"Find people who like \"burrito\". Sort them by name, limit the results to two documents, and hide their age. Chain .find(), .sort(), .limit(), .select(), and then .exec(). Pass the done(err, data) callback to exec()."
|
||||
|
Reference in New Issue
Block a user