This documentation describes the HTTP API operations currently supported by the backend. Each operation is outlined with its purpose, URL, HTTP method, and additional details like headers and body (if applicable).
Creates a new project with a specified owner and name.
- Method:
POST
- URL:
http://localhost:3000/project/new
- Headers:
Content-Type: application/json
- Response Codes:
- 200: Successfully created project
- 400: Malformed body
- 409: Duplicate project
- Body:
- Use JSON to specify the initial visibility of the project.
- if
private
istrue
the project will not be visible
POST http://localhost:3000/project/new
Content-Type: application/json
{
"private": false,
"ownerId": "AVeryCoolDude",
"name": "MyCoolNewProject"
}
{
"id": 211,
"name": "MyCoolNewProject",
"ownerId": "AVeryCoolDude",
"private": false,
"slug": "my-cool-new-project"
}
Renames an existing project by its ID.
- Method:
PUT
- URL:
http://localhost:3000/project/settings/name/{projectId}
- Headers:
Content-Type: application/json
- Response Codes:
- 204: Successfully renamed project
- 400: Malformed project id or body
- 409: Duplicate or unknown project
- Query Parameters (optional):
- ownerId: only rename the project if it is owned by the specified user/org
- Details:
- Replace
{projectId}
with the ID of the project to rename.
- Replace
- Body:
- Use JSON to specify the new name of the project.
-
Rename project with id 1 by the specified user
PUT http://localhost:3000/project/rename/1?ownerId=test Content-Type: application/json { "name": "test test test" }
-
Rename project with id 1
PUT http://localhost:3000/project/rename/1 Content-Type: application/json { "name": "test test test" }
Checks if a project slug is available for use.
- Method:
HEAD
- URL:
http://localhost:3000/project/settings/slug/{slug}
- Response Codes:
- 204: Slug is available
- 409: Slug is already in use
- Details:
- Replace
{slug}
with the project slug to check
- Replace
HEAD http://localhost:3000/project/settings/slug/my-cool-project
Updates the icon for a specific project.
- Method:
PUT
- URL:
http://localhost:3000/project/settings/icon/{projectId}
- Headers:
Content-Type: application/json
- Response Codes:
- 204: Successfully updated project icon
- 304: Project not found or no changes were made
- 400: Malformed project id or body
- Query Parameters (optional):
- ownerId: only update the project if it is owned by the specified user/org
- Body:
- Use JSON to specify the new icon for the project.
PUT http://localhost:3000/project/settings/icon/1?ownerId=test
Content-Type: application/json
{
"icon": "rocket"
}
Updates the preview chart settings for a specific project.
- Method:
PUT
- URL:
http://localhost:3000/project/settings/preview/{projectId}
- Headers:
Content-Type: application/json
- Response Codes:
- 204: Successfully updated preview chart settings
- 304: Project not found or no changes were made
- 400: Malformed project id or body
- 404: Project doesn't contain the given chart
- Query Parameters (optional):
- ownerId: only update the project if it is owned by the specified user/org
- Body:
- Use JSON to specify the new settings for the preview chart.
PUT http://localhost:3000/project/settings/preview/1?ownerId=test
Content-Type: application/json
{
"chart": "total_servers"
}
Updates the URL settings for a specific project.
- Method:
PUT
- URL:
http://localhost:3000/project/settings/url/{projectId}
- Headers:
Content-Type: application/json
- Response Codes:
- 204: Successfully updated project URL settings
- 304: Project not found or no changes were made
- 400: Malformed project id or body
- Query Parameters (optional):
- ownerId: only update the project if it is owned by the specified user/org
- Body:
- Use JSON to specify the new URL settings for the project.
PUT http://localhost:3000/project/settings/url/1?ownerId=test
Content-Type: application/json
{
"url": "https://new-project-url.example.com"
}
Updates the visibility settings for a specific project.
- Method:
PUT
- URL:
http://localhost:3000/project/settings/private/{projectId}/{private}
- Response Codes:
- 204: Successfully updated visibility settings
- 304: Project not found or no changes were made
- 400: Malformed project id
- Query Parameters (optional):
- ownerId: only update the project if it is owned by the specified user/org
-
Update a project with id 1 by a specific user/org to private
PUT http://localhost:3000/project/settings/private/1/true?ownerId=test
-
Update a project with id 1 to public
PUT http://localhost:3000/project/settings/private/1/false
Updates the slug for a specific project.
- Method:
PUT
- URL:
http://localhost:3000/project/settings/slug/{projectId}/{slug}
- Response Codes:
- 204: Successfully updated project slug
- 304: Project not found or no changes were made
- 400: Malformed project id or slug
- Query Parameters (optional):
- ownerId: only update the project if it is owned by the specified user/org
- Slug Pattern:
^(?=.{3,32}$)[a-z0-9]+(-[a-z0-9]+)*$
-
Update the slug of a project with id 1:
PUT http://localhost:3000/project/settings/slug/1/new-slug
-
Update the slug of a project with id 1 for a specific owner:
PUT http://localhost:3000/project/settings/slug/1/new-slug?ownerId=test
Lists projects based on filters such as public/private visibility, user, and pagination.
- Method:
GET
- URL:
http://localhost:3000/projects/list/{offset}/{limit}
- Response Codes:
- 200: Successfully listed
- 400: Malformed offset, limit, or body
- Query Parameters (optional):
- publicOnly: list projects by visibility
- ownerId: list projects by a specific user/org
- Details:
- If
publicOnly
istrue
only public projects will be listed, iffalse
only private projects, and if omitted both public and private projects are listed - If
ownerId
is undefined projects of all users and orgs are listed offset
defines how many projects should be skipped (allowing pagination)limit
defines how many projects may be listed at max
- If
-
List 20 public projects skipping the first 10:
GET http://localhost:3000/projects/list/10/20?publicOnly=true
-
List 10 public projects by a specific user:
GET http://localhost:3000/projects/list/0/10?publicOnly=true&ownerId=testUser
-
List 10 public and private projects by a specific user:
GET http://localhost:3000/projects/list/0/10?ownerId=testUser
-
List 10 private projects by a specific user:
GET http://localhost:3000/projects/list/0/10?publicOnly=false&ownerId=testUser
[
{
"icon": "gem",
"id": 1,
"name": "MyCoolNewsProjects",
"ownerId": "AVeryCoolDude",
"private": false,
"slug": "cool-project",
"url": "https://project.example.com"
},
{
"icon": "white-flag",
"id": 4,
"name": "test test test",
"ownerId": "AVeryCoolDude",
"private": true,
"slug": "test"
}
]
Returns the total number of projects by a specific owner or global.
- Method:
GET
- URL:
http://localhost:3000/projects/count
- Response Codes:
- 200: Successfully retrieved projects count
- Query Parameters (optional):
- ownerId: count only the projects owned by the specified user/org
- Details:
- If
ownerId
is not provided, the count will include all projects.
- If
-
Count all projects
GET http://localhost:3000/projects/count
-
Count projects of a specific user
GET http://localhost:3000/projects/count?ownerId=AVeryCoolDude
-
All projects
{ "count": 24423 }
-
For a specific user
{ "count": 2 }
Retrieve a project by its ID.
- Method:
GET
- URL:
http://localhost:3000/project/{projectId}
- Response Codes:
- 200: Successfully retrieved project
- 400: Malformed project id
- 404: Project not found
- Query Parameters (optional):
- ownerId: retrieve the project only if it is owned by the specified user/org
- Details:
- Replace
{projectId}
with the ID of the project to retrieve.
- Replace
-
Retrieve the project with id 1 if it is owned by a specific user
GET http://localhost:3000/project/1?ownerId=AVeryCoolDude
-
Retrieve the project with id 1
GET http://localhost:3000/project/1
{
"icon": "gem",
"id": 1,
"name": "MyCoolNewsProjects",
"ownerId": "AVeryCoolDude",
"private": false,
"slug": "cool-project",
"layout": [
{
"chart": "total_servers",
"name": "Total Servers",
"type": "line_chart",
"color": "#1da1f2"
}
],
"previewChart": "total_servers",
"url": "https://project.example.com"
}
Deletes a project by its ID.
- Method:
DELETE
- URL:
http://localhost:3000/project/delete/{projectId}
- Response Codes:
- 204: Successfully deleted project
- 400: Malformed project id
- 404: Project not found
- Query Parameters
- ownerId: only delete the project if it is owned by the specified user/org
- Details:
- Replace
{projectId}
with the ID of the project to delete.
- Replace
-
Delete the project with id 1 if it is owned by a specific user
DELETE http://localhost:3000/project/delete/1?ownerId=AVeryCoolDude
-
Delete the project with id 1
DELETE http://localhost:3000/project/delete/1
To run the project with Docker, follow these steps:
-
Set up the Environment:
- Ensure you have Docker and Docker Compose installed on your system.
- If not, refer to the official Docker Installation Guide and Docker Compose Installation Guide.
-
Start the Services:
- Use the provided
docker-compose.yml
file to spin up the necessary containers (backend and MongoDB). - Run the following command in the directory where the
docker-compose.yml
file is located:
docker-compose up --build
- Use the provided
-
Access the Application:
- The backend service will be accessible at http://localhost:3000.
- MongoDB is configured as a dependency and will automatically be linked to the backend container.
-
Environment Variables:
- The
MONGODB_URL
environment variable is set tomongodb://user:password@mongodb:27017/
. - The backend server will run on port
3000
, mapped to the host machine.
- The
-
Persistent Data:
- The MongoDB data is stored in a Docker volume (
mongodb
) to ensure persistence across restarts.
- The MongoDB data is stored in a Docker volume (
-
Stop the Services:
- To stop the running containers, press
CTRL+C
or run:
docker-compose down
- To stop the running containers, press
-
Restart Containers:
- If you’ve made changes to the code or configuration, restart the containers using:
docker-compose up --build
-
Health Check:
- The MongoDB service includes a
healthcheck
to verify that the database is ready and responsive before the backend service starts. - You can verify container health by running:
docker ps
- The MongoDB service includes a
This setup ensures the backend and MongoDB are easily started, linked, and maintained using Docker Compose.