Skip to content

penky776/osf_hackathon_1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

api for managing an online forum

TODO

  • handle DELETE requests
  • secure user authentication
  • Error handling
  • make documentation and more descriptive readme for the api

Table of Contents

Dependencies

The only dependencies are rust and cargo.

Usage

git clone [email protected]:penky776/osf_hackathon_1.git
# OR
git clone https://github.com/penky776/osf_hackathon_1.git

To start the server, cd into the directory and:

cargo run

Documentation

1. Authenticate

Log in

POST /login

curl --location 'http://localhost:3000/login' \
--data-urlencode 'username=USERNAME' \
--data-urlencode 'password=PASSWORD' -v

Register

POST /register

curl --location 'http://localhost:3000/register' \
--data-urlencode 'username=USERNAME' \
--data-urlencode 'password=PASSWORD' -v

2. User

Delete User

DELETE /deleteuser

curl --location --request DELETE 'http://localhost:3000/deleteuser' \
--header 'Cookie: session_token=SESSION_TOKEN; username=USERNAME'

Get CSRF Token

GET /get-csrf-token

curl --location 'http://localhost:3000/get-csrf-token' \
--header 'Cookie: session_token=SESSION_TOKEN; username=USERNAME'

3. Posts

Add Post

POST /addpost

curl --location 'http://localhost:3000/addpost' \
--header 'Cookie: session_token=SESSION_TOKEN; username=USERNAME' \
--data-urlencode 'csrf_token=CSRF_TOKEN' \
--data-urlencode 'title=POST_TITLE' \
--data-urlencode 'body=POST_BODY'

Delete Post

POST /deletepost

curl --location 'http://localhost:3000/deletepost' \
--header 'Cookie: session_token=SESSION_TOKEN; username=USERNAME' \
--data-urlencode 'id=POST_ID' \
--data-urlencode 'csrf_token=CSRF_TOKEN'

4. Comments

Add Comment

POST /addcomment

curl --location 'http://localhost:3000/addcomment' \
--header 'Cookie: session_token=SESSION_TOKEN; username=USERNAME' \
--data-urlencode 'body=COMMENT_BODY' \
--data-urlencode 'post_id=POST_ID' \
--data-urlencode 'csrf_token=CSRF_TOKEN'

Delete Comment

POST /deletecomment

curl --location 'http://localhost:3000/deletecomment' \
--header 'Cookie: session_token=SESSION_TOKEN; username=USERNAME' \
--data-urlencode 'id=COMMENT_ID' \
--data-urlencode 'csrf_token=CSRF_TOKEN'

About

api for managing an online forum

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published