Skip to content

Commit 6437ed0

Browse files
committed
Update README for full_server
1 parent d62a3d2 commit 6437ed0

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

0x05-Node_JS_basic/full_server/README.md

+16-13
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* Create `2` directories within:
55
* `controllers`
66
* `routes`
7-
* Create a file `full_server/utils.js`, in the file create a function named `readDatabase` that accepts a file path as argument:
7+
* Create a file [full_server/utils.js](./utils.js), in the file create a function named `readDatabase` that accepts a file path as argument:
88
* It should read the database asynchronously
99
* It should return a promise
1010
* When the file is not accessible, it should reject the promise with the error
1111
* When the file can be read, it should return an object of arrays of the firstname of students per fields
1212

1313
### 8.2 Write the App controller
14-
Inside the file `full_server/controllers/AppController.js`:
14+
Inside the file [full_server/controllers/AppController.js](./controllers/AppController.js):
1515

1616
* Create a class named `AppController`. Add a static method named `getHomepage`
1717
* The method accepts `request` and `response` as argument. It returns a `200` status and the message `Hello Holberton School!`
1818

1919
### 8.3 Write the Students controller
20-
Inside the file `full_server/controllers/StudentsController.js`, create a class named `StudentsController`. Add two static methods:
20+
Inside the file [full_server/controllers/StudentsController.js](./controllers/StudentsController.js), create a class named `StudentsController`. Add two static methods:
2121

2222
The first one is `getAllStudents`:
2323

@@ -28,33 +28,36 @@ The first one is `getAllStudents`:
2828
* And for each field (*order by alphabetic order case insensitive*), a line that displays the number of students in the field, and the list of first names (*ordered by appearance in the database file*) with the following format: `Number of students in FIELD: 6. List: LIST_OF_FIRSTNAMES`
2929
* If the database is not available, it should return a status `500` and the error message `Cannot load the database`
3030

31-
The second one is getAllStudentsByMajor:
31+
The second one is `getAllStudentsByMajor`:
3232

33-
* The method accepts request and response as argument
34-
* It should return a status 200
35-
* It uses a parameter that the user can pass to the browser major. The major can only be CS or SWE. If the user is passing another parameter, the server should return a 500 and the error Major parameter must be CS or SWE
36-
* It calls the function readDatabase from the utils file, and display in the page the list of first names for the students (ordered by appearance in the database file) in the specified field List: LIST_OF_FIRSTNAMES_IN_THE_FIELD
37-
* If the database is not available, it should return a status 500 and the error message Cannot load the database
33+
* The method accepts `request` and `response` as argument
34+
* It should return a status `200`
35+
* It uses a parameter that the user can pass to the browser `major`.
36+
The `major` can only be `CS` or `SWE`.
37+
If the user is passing another parameter,
38+
the server should return a `500` and the error `Major parameter must be CS or SWE`
39+
* It calls the function `readDatabase` from the `utils` file, and display in the page the list of first names for the students (*ordered by appearance in the database file*) in the specified field `List: LIST_OF_FIRSTNAMES_IN_THE_FIELD`
40+
* If the database is not available, it should return a status `500` and the error message `Cannot load the database`
3841

3942
### 8.4 Write the routes
40-
Inside the file `full_server/routes/index.js`:
43+
Inside the file [full_server/routes/index.js](./routes/index.js):
4144

4245
* Link the route `/` to the `AppController`
4346
* Link the route `/students` and `/students/:major` to the `StudentsController`
4447

4548
### 8.5 Write the server reusing everything you created
46-
Inside the file named `full_server/server.js`, create a small `Express` server:
49+
Inside the file named [full_server/server.js](./server.js), create a small `Express` server:
4750

4851
* It should use the routes defined in `full_server/routes/index.js`
49-
* It should use the port `1245`
52+
* It should use the port `1245`
5053

5154
### 8.6 Update `package.json` (if you are running it from outside the folder full_server)
5255
If you are starting node from outside of the folder `full_server`, you will have to update the command `dev` by: `nodemon --exec babel-node --presets babel-preset-env ./full_server/server.js ./database.csv`
5356

5457
#### Warning:
5558

5659
* Don’t forget to export your express app at the end of `server.js` (`export default app;`)
57-
* The database filename is passed as argument of the `server.js` BUT, for testing purpose, you should retrieve this filename at the execution (when `getAllStudents` or g`etAllStudentsByMajor` are called for example)
60+
* The database filename is passed as argument of the `server.js` **BUT**, for testing purpose, you should retrieve this filename at the execution (when `getAllStudents` or g`etAllStudentsByMajor` are called for example)
5861

5962
**In terminal 1**:
6063
```

0 commit comments

Comments
 (0)