|
1 | | -<<<<<<< HEAD |
| 1 | + |
2 | 2 | > Please help us improve and share your feedback! If you find better tutorials or links, please share them by opening a Pull Request. |
3 | 3 |
|
4 | 4 | # HackYourFuture - Node.js |
@@ -34,46 +34,4 @@ There are many languages for this. We might've heard of Java, C, C++, Go, Python |
34 | 34 |
|
35 | 35 | There are two reasons why we at HYF choose Node.JS over others: |
36 | 36 | 1) You already know JavaScript, so it's easier to get started than other languages |
37 | | -2) Node.js is great for making web APIs because it is asynchronous by nature and thus allows for high input/output. By this we mean that it allows many users to make very light requests at the same time. |
38 | | -======= |
39 | | -# TODO API |
40 | | - |
41 | | -This is an Express application using `bodyParser` middleware to convert the request body to JSON. |
42 | | - |
43 | | -There are currently four actions: |
44 | | - |
45 | | -- `list` (`GET /todos`): Lists all todos |
46 | | -- `create` (`POST /todos`): Creates a new todo |
47 | | -- `update` (`PUT /todos/:id`): Updates the description of a todo |
48 | | -- `remove` (`DELETE /todos/:id`): Deletes a todo |
49 | | - |
50 | | -## Directory structure |
51 | | - |
52 | | -- `actions`: Contains the actions as listed above, each as a express handler (function accepting request and response) |
53 | | -- `data`: Contains the data file `todos.json` |
54 | | -- `models`: Contains the Todo model class |
55 | | -- `util`: Utility functions |
56 | | -- `index.js` The application file |
57 | | - |
58 | | -## Request body format |
59 | | - |
60 | | -When calling the `create` or `update` actions, the request body should look like this: |
61 | | - |
62 | | -```json |
63 | | -{ |
64 | | - "todo": { |
65 | | - "description": "(todo description)" |
66 | | - } |
67 | | -} |
68 | | -``` |
69 | | - |
70 | | -Note that for these actions, the client should add the following header: |
71 | | - |
72 | | -- `Content-Type`: `application/json` |
73 | | - |
74 | | -In Postman, make sure to add this header, and set the Body type to "Raw". |
75 | | - |
76 | | -## UUIDs |
77 | | - |
78 | | -For IDs, this application uses "UUIDs" (Universally Unique IDs). They can be generated using the `uuid` package, and are guaranteed never to be the same. |
79 | | ->>>>>>> class7-nodejs-week3/master |
| 37 | +2) Node.js is great for making web APIs because it is asynchronous by nature and thus allows for high input/output. By this we mean that it allows many users to make very light requests at the same time. |
0 commit comments