Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Express API #528

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1c99173
Initial commit
joheri1 Dec 5, 2024
9922cf5
Add a new json of elves. Import file to server.js and save port 1224.
joheri1 Dec 7, 2024
9ad54d5
Install npm install express-list-endpoints and add to documentation
joheri1 Dec 7, 2024
ddffbbe
Import import expressListEndpoints from 'express-list-endpoints' to t…
joheri1 Dec 7, 2024
0174836
Add first route that shows the API documentation
joheri1 Dec 7, 2024
46b6952
Fix typos
joheri1 Dec 7, 2024
0beb5c5
Add route to server.js that filters elves
joheri1 Dec 7, 2024
1bac1f0
add rount for filter elves by id
joheri1 Dec 7, 2024
3078fb8
Change filtered elves since the previous one did not work
joheri1 Dec 7, 2024
68d146f
Change elves filter from query param to path param
joheri1 Dec 7, 2024
45b10fc
Fix errors in code like missing curly brace
joheri1 Dec 7, 2024
d51a71a
Change order of content in server.js
joheri1 Dec 7, 2024
f5f6e89
change name on our titles to Backend Dasher :D
joheri1 Dec 7, 2024
6213141
Add more info to readme
joheri1 Dec 7, 2024
92ab7da
Add description to server.js. Change one route (endpoint) to GET all …
joheri1 Dec 7, 2024
29d6c43
Add more documentation to README
joheri1 Dec 7, 2024
5856efa
Adjust the project description since I am not using slice().
joheri1 Dec 7, 2024
9b79fc4
Removed and changed some data in the json file
joheri1 Dec 7, 2024
6f4757a
Change order in the documentation endpoint to show description before…
joheri1 Dec 7, 2024
477520c
Fix nesting
joheri1 Dec 7, 2024
fa991bf
Add route /elves/top-twelves to use .slice(), that GET the top 12 elves
joheri1 Dec 8, 2024
c217dbe
Update documentation
joheri1 Dec 8, 2024
53368c5
Change message for testing the server
joheri1 Dec 8, 2024
625da6e
Change name from event to elf to make code easier to understadn
joheri1 Dec 8, 2024
e2ae9f6
Change event to record to make the code more readable
joheri1 Dec 8, 2024
51808de
Save any unsaved changes
joheri1 Dec 8, 2024
e4ce776
Save any unsaved changes
joheri1 Dec 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 68 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,76 @@
# Project Express API

Replace this readme with your own information about your project.
This project marks the beginning of my backend journey with Express.js, featuring RESTful endpoints that return data from a hard-coded JSON file.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
Array methods like .find(), .filter(), and .slice() are used to manipulate the data. While pre-made datasets are available, I chose to create my own for a personalized touch.

## The problem
My crew of elves, the Backend Dashers, can be found at /elves/title/backend%20dasher or at /elves/top-twelves

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?
## Requirements:
1. The API should have at least 3 routes.
This API has the following routes:
- /: Returns documentation of the API using express-list-endpoints.[Express List Endpoints](https://www.npmjs.com/package/express-list-endpoints).
- /elves/all - Get all elves
- /elves/top-twelves - Get top TwElves using .slice()
- /elves/:id: - Get a specific elf by ID using .find()
- /elves/titles/:title: - Get elves by title using .filter()
- /test - Test endpoint
2. A minimum of one endpoint to return a **collection** of results (array of elements).
- elves/all: Returns a collection of elves.
- /elves/top-twelves - Get top TwElves.
- /elves/titles/:title: Returns elves by their title.
3. A minimum of one endpoint to return a **single** result (single element).
- /elves/:id: Returns a single elf by ID.
4. Your API should be RESTful.
- Routes (elves) are defined with endpoints such as /elves/:id, and /elves/titles/:title.
- HTTP methods are used (GET).
- Responses are structured in JSON format.
5. You should follow the guidelines on how to write clean code.
- Variable names are clear and descriptive (e.g. request, response, title).
- Each functionality is separated into its own endpoint.
- express.json() and cors() to handle JSON parsing and CORS issues

## Dependency Installation & Startup Development Server
This project uses npm (Node Package Manager) and Express.js to manage dependencies and run the development server. Follow these steps to get started:
1. Install Project Dependencies
Run the following commands to install necessary packages and set up the development environment:
```bash
npm install
npm run dev
npm run build
```
2. If Express.js is not already installed, initialize your project and install it:
```bash
npm init -y
npm install express
```
3. Start your server
Launch the server:
```bash
node server.js
```
4. The package used to generate a list of all available API endpoints automatically (shown on the endpoint /). Install it with:
```bash
npm install express-list-endpoints
```

## The problem
This was my first backend project, and I found it a bit confusing to figure out what to install and why. I’m also not used to working without a UI, which made it tricky to test everything properly without clickable links or visual "feedback".

## If I had more time - Stretch goals

### Intermediate Stretch Goals
- On routes which return a single item, handle when the item doesn't exist and return some useful data in the response.

- Accept filters via query parameters to filter the data you return from endpoints which return an array of data.

- Create some empty/dummy endpoints which could contain more complex operations in the future. Find good names for them (think RESTful).

### Advanced Stretch Goals
- Build a frontend which uses your API in some way to show the data in a nice way (use Vite to get up and running fast).

- If your dataset is large, try implementing 'pages' using `.slice()` to return only a selection of results from the array. You could then use a query parameter to allow the client to ask for the next 'page'.

## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
[Check out the Elf's API here!](https://project-express-api-gyq9.onrender.com/)
Loading