API Documentation
Connection APIās
Section titled āConnection APIāsā- checkInstallation
- createDatabase
- createTable
- finalInstallCheck
- login
- siteDataRender
- sqlServicePing
- updateCredentials
- updateDatabase
Config APIās
Section titled āConfig APIāsā- imageUploader
checkInstallation
Section titled ācheckInstallationāRequest Type: GET()
Primary Function:
The checkInstallation API endpoint verifies the applicationās connection status to the SQL backend database. It examines local environment variables (accessed through process.env) and returns:
- The current connection status to the database
- A list of environment variables, indicating which are configured and which are missing or unconfigured
This endpoint is served through a popover component to help quickly identify configuration issues during setup or troubleshooting. It enables verification that all required database connection parameters are properly set before attempting to use the applicationās data-dependent features.
createDatabase
Section titled ācreateDatabaseāRequest Type: POST()
Primary Function:
The createDatabase API endpoint initializes the applicationās database infrastructure by:
- Creating a Primary database for the application.
- Establishing a
main
table within this databse with the following schema:
Table Name: mainTable Fields: user_id INT PRIMARY KEY AUTO_INCREMENT, user_email VARCHAR(255) NOT NULL UNIQUE, user_password VARCHAR(255) NOT NULL, full_name VARCHAR(255), location VARCHAR(255), app_title VARCHAR(255), about_app VARCHAR(255), pfp_image VARCHAR(255), app_image VARCHAR(255), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
Upon successful creation of both the database and table, this endpoint automatically updates the applicationās environment variables by writing the validated database connection details to an ENV file.
createTable
Section titled ācreateTableāRequest Type: POST()
Primary Function:
The createTable API endpoint handles the creation and management of database tables based on validated POST data from the application. Its key functions include:
- Validating the table specification data received in the POST request
- Determining whether a requested table already exists
- Creating new tables when they donāt exist, using the validated specifications
- Updating existing tables according to the provided schema when modifications are needed
finalInstallCheck
Section titled āfinalInstallCheckāRequest Type: GET() POST()
Primary Function:
The finalInstallCheck API endpoint serves a dual purpose through bouth GET and POST requests.
- GET() Request:
- Performs validation of database connectivity by executing SQL queries
- Evaluates each environment variable against relevant test cases to verify proper configuration
- Returns detailed diagnostics about the success or failure of each test, providing actionable feedback for troubleshooting
The results of this request are rendered by the FinaliseInstallation component.
- POST Request:
Upon receiving confirmation that all tests have passed successfully the POST() request writes a final environment variable that signals installation completion this enables the application to transition from setup mode to full operational functionality.
Request Type: POST()
Primary Function:
The login API endpoint processes authentication requests from the LoginForm component by:
- Accepting user credentials (typically email/username and password) from the form submission
- Validating these credentials against user records stored in the
main
database - Employing bcrypt to securely handle password verification through cryptographic comparison instead of plain text matching
- Generating and returning appropriate authentication tokens or session information upon successful validation
siteDataRender
Section titled āsiteDataRenderāRequest Type: GET()
Primary Function:
The siteDataRender API endpoint retrieves information from the main
database to render on relevant components. The current implementation returns:
- user_email
- full_name
- location
- app_title
- about_app
- pfp_image
- app_image
sqlServicePing
Section titled āsqlServicePingāRequest Type: GET()
Primary Function:
The sqlServicePing API endpoint essentially pings the SQL Server (based on details in env file) and returns a status of success or fail which in turn can be rendered in various ways. Currently it is being utlised to render the ServicePing component.
updateCredentials
Section titled āupdateCredentialsāRequest Type: POST()
Primary Function:
The updateCredentails API endpoint is used to create and store credentials (full name, user email, password) within the main
database allowing the user to login post installation. Should the user already exist the API will overwrite the current username and password with the updated details.
updateDatabase
Section titled āupdateDatabaseāRequest Type: POST()
Primary Function: The updateDatabse API endpoint is used to create and store information associated with the application in the main
database (location, app title, about app). Should information already exist the endpoint will overwrite details accordingly
imageUploader
Section titled āimageUploaderāRequest Type: POST()
Primary Function:
The image uploader API endpoint ensures that images are stored in the public/img folder
. It categorizes and datestamps each image to maintain a history for future reference. This system serves the most recently uploaded image as the primary profile picture for both users and applications, while also keeping previous versions accessible