A website to share code made using Spring Boot. Nearly at the end of development. Open for contributions.
- Swagger for API docs
- Deleting all posts of a user if a user is deleted
- Setting time limit so that code will be deleted if time limit is reached
- Setting view limit so that code will be deleted if view limit is reached
- Hashing of password for security
In terminal bash:
git clone https://github.com/ritish78/CodeShare.git
After the clone is sucessfull, then add this project as 'New Project from Existing Source' (depending upon the IDE) and add 'Maven' . Then, in terminal:
mvn clean install
Then run the 'CodeSharePlatformApplication.java' or in terminal:
mvn spring-boot:run
Tomcat should start on port 8080.
After running the spring boot application, go the url:
http://localhost:8080/v2/api-docs
Or, to get the info in UI from Swagger, go the url:
http://localhost:8080/swagger-ui.html
- GET /code/new
- POST /code/new
- GET /code/{uuid}
- GET /code/latest
- GET /code/last/{count}
For Code:
- POST /api/code/new
- GET /api/code/{uuid}
- GET /api/code/latest
- GET /api/code/last/{count}
- POST /api/code/addAll
- DELETE /api/code/{uuid}
For User:
- POST /api/user/new
- GET /api/user/{uuid}
- DELETE /api/user/{uuid}
- GET /api/user/{uuid}/code
- POST /api/code/{uuid}/new
You can create a User and create as many posts(Code in this website).
{
"username": "test",
"email": "[email protected]",
"password": "myPassword#1"
}
If the user is created suceessfully, the server will send a JSON reponse with the UUID of created user.
{
"uuid": "6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d"
}
The server will send a JSON file of deleted User's uuid. FEATURE: If a user has created posts, and if you delete the user then the associated posts of the user will also be deleted.
{
"uuid": "6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d"
}
To create a post (Code) for user, send a POST request to: localhost:8080/api/code/{uuid}/new with JSON:
{
"body": "Creating a post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"viewsLeft": 5,
"timeInSeconds": 120
}
If post is saved sucessfully, the server will send a JSON response with the UUID of created post by the user.
{
"uuid": "b2ab3374-b7c0-4818-b6b7-6c6011abb47d"
}
To get all the posts created by the user, send a GET request to: localhost:8080/api/user/{uuid}/code.
[
{
"body": "Creating a post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"dateTime": "2021-01-16 10:41:16",
"viewsLeft": 5,
"timeInSeconds": 120
},
{
"body": "Creating another post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"dateTime": "2021-01-16 10:41:17",
"viewsLeft": 5,
"timeInSeconds": 120
},
{
"body": "Creating third post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"dateTime": "2021-01-16 10:41:18",
"viewsLeft": 5,
"timeInSeconds": 120
}
]
The server will return the Username, email and the posts by the user
{
"username": "test",
"email": "[email protected]",
"codeList": [
{
"body": "Creating a post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"dateTime": "2021-01-16 10:41:16",
"viewsLeft": 5,
"timeInSeconds": 120
},
{
"body": "Creating another post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"dateTime": "2021-01-16 10:41:17",
"viewsLeft": 5,
"timeInSeconds": 120
},
{
"body": "Creating third post for the user of UUID: 6cd916ef-7e33-4fa5-b31b-fa94f0d32a3d",
"dateTime": "2021-01-16 10:41:18",
"viewsLeft": 5,
"timeInSeconds": 120
}
]
}
Added support for View Limit and Time Limit for code. Once the view limit or time limit is reached, the code will be deleted.
- GET /code/{uuid}
- GET /api/code/{uuid} Above end points activate the checking method