This is a demo backend application that provides simple CRUD API to use during teaching frontend principles
- Clone the repository
cd
to cloned repository- Run
yarn
to install dependencies - Run
yarn build
to build the application - Run
yarn start
to start the server - API should be available under localhost:3001
- Remember to adjust proxy configuration of your frontend dev server tool to map to this backend
All routes accept json payload only, remember to set correct Content-Type header.
Routes | HTTP | Request JSON Payload | Response | Description |
---|---|---|---|---|
/api/auth/signup | POST |
{ |
Route used to register a new user | |
/api/auth/login | POST |
{ |
Logins the user initializing session | |
/api/auth/logout | POST |
--- | Logs out current user | |
/api/auth/me | GET |
--- | { |
Returns current user or 403 if not logged in |
To use this routes (other than GET
ones) you need to be logged in.
Routes | HTTP | Request JSON Payload | Response | Description |
---|---|---|---|---|
/api/posts | GET |
--- | Array of posts | Returns all posts |
/api/posts/:id | GET |
--- | { |
Returns a post of id passed in url |
/api/posts/ | POST |
{ |
Adds new post | |
/api/posts/:id | PUT |
{ |
Modifies the post of id passed in url | |
/api/posts/:id | DELETE |
Deletes the post of id passed in url |