Skip to content

anhtuansggd/CoSP

Repository files navigation

CoSP

A Java-based web application that utilizes the Spring Boot framework for backend development. It features a RESTful API for managing code snippets, which are stored as entities in a database.
The application supports operations such as retrieving a specific code snippet by its UUID, and fetching the latest code snippets. Each code snippet entity has properties such as time of creation, time restriction, view restriction, and last accessed time.
The application also includes exception handling for scenarios such as invalid UUID or exceeding view restrictions.

API Documentation

Endpoints
POST /api/code/new
Parameters
name type data type description
code required string Secret code
time required int Time in seconds
views required int Number of views
Request Body
{
    "code": "Secret code",
    "time": 60,
    "views": 5
}
URL

http://localhost:8889/api/code/new

Responses
Code Description
200 OK
{
    "id": uuid
}
GET /code/{id}
Parameters
name type data type description
id required string id
URL

http://localhost:8889/code/{id}

Responses
Code Description
200 OK

Note: HTML will be returned.

GET /api/code/{id}
URL

http://localhost:8889/api/code/{id}

Parameters
name type data type description
id required string id
Responses
Code Description
200 OK
{
    "code": string,
    "date": date type,
    "time": int,
    "views": int
}
GET /api/code/latest
No parameters
URL

http://localhost:8889/api/code/latest

Responses
Code Description
200 OK

Notes: this endpoint return json object of all codes.

{
    "code": string,
    "date": date type,
    "time": int,
    "views": int
}
GET /code/latest
No parameters
URL

http://localhost:8889/code/latest

Responses
Code Description
200 OK

Notes: this endpoint return HTML of all codes.

GET /code/new
No parameters
URL

http://localhost:8889/code/new

Responses
Code Description
200 OK

Notes: this endpoint return a form to input code.

About

A Java Code Sharing Platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published