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

Create endpoints 6 #26

Open
4 tasks done
jessieh9 opened this issue Dec 3, 2024 · 0 comments · May be fixed by #30
Open
4 tasks done

Create endpoints 6 #26

jessieh9 opened this issue Dec 3, 2024 · 0 comments · May be fixed by #30
Assignees

Comments

@jessieh9
Copy link
Collaborator

jessieh9 commented Dec 3, 2024

Setup

Before you can work on the repo, you need to add the secrets.
For the Frontend .env, put it in /client.
For the Backend .env, put it in /server.

You also need to add this file in /server/config

Task

Create the following API endpoints:

POST      /comments
PUT       /comments/:id
DELETE    /comments/:id
GET       /clients

For a description of each of these endpoints, see the DB model.
Follow proper API conventions and return status codes along with your response. Namely 200, 404, 500, etc.

Put your endpoints into /server/routes/[FILENAME].js
Replace FILENAME with the name of the DB table that the endpoint is for.

Don't Forget: use the keysToCamel function, as seen in the sample users.ts file, to make the SQL keys into camel case

Some sample files have been provided. They are in TS not JS, but you can ignore the TS stuff (and work in JS)

Steps

  1. Create file for each endpoint (comments/clients)
  2. Create a router for this file (see examples)
  3. Import and place this router into /server/src/App.ts (see line 40)
  4. Create the functions for get/post/delete/put

Example

GET /users/:id
Place this into /server/routes/users.js
See users.ts for the best examples.

Testing

To test your implementation, you can use Postman like we have in the bootcamps.

If you put your endpoints in sample.js (for example only), then you will need to send requests to:
127.0.0.1:3001/sample/<your endpoint>

Resources

Secrets (.env)
PostgreSQL DB Login
DB Schema

Checklist

  • Create all endpoints
  • Test all endpoints
  • Commit changes
  • Push changes, create PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants