/
API documentation page
Renders the human-readable API documentation for this service, including endpoint groups, parameters and response examples.
Responses
-
200 HTML documentation page
A small REST service: GitHub commit search, a Mongoose-backed URL shortener, and Gemini text/image generation.
/
Renders the human-readable API documentation for this service, including endpoint groups, parameters and response examples.
/api/
Returns the same endpoint metadata as structured JSON. Useful for clients that want to fetch the docs programmatically.
/api/github/getCommits/:word
Searches recent GitHub commits (main public repositories) that contain the given word.
| Name | Type | Required | Description |
|---|---|---|---|
| word | string | yes | Keyword to search for in commit messages. |
/api/github/getCommitsByRepoAndOwner/:owner/:repo
Searches recent GitHub commits for a specific repository, identified by its owner and name.
| Name | Type | Required | Description |
|---|---|---|---|
| owner | string | yes | GitHub account or organization that owns the repository. |
| repo | string | yes | Repository name (without the .git suffix). |
/api/url
Fetches every URL currently stored in the database.
/api/url/create
Creates a new short URL for the provided original URL. If an existing short URL is found, it is returned; otherwise a new one is created.
| Name | Type | Required | Description |
|---|---|---|---|
| original_url | string | yes | The full URL to shorten. |
{
"original_url": "https://example.com/very-long-path",
"short_url": 12345,
"creation_date": "2026-01-01T00:00:00.000Z"
}
/api/url/:short_url
Fetches a single stored URL by its short code.
| Name | Type | Required | Description |
|---|---|---|---|
| short_url | string | yes | Short code identifying the stored URL. |
{
"original_url": "https://example.com",
"short_url": 12345,
"creation_date": "2026-01-01T00:00:00.000Z"
}
{
"error": "URL not found"
}
/api/url/delete/:short_url
Deletes a stored URL by its short code.
| Name | Type | Required | Description |
|---|---|---|---|
| short_url | string | yes | Short code of the URL to delete. |
{
"original_url": "https://example.com",
"short_url": 12345,
"creation_date": "2026-01-01T00:00:00.000Z"
}
{
"error": "URL not found"
}
/api/gemini/getFromText
Generates text using Gemini from a text-only prompt supplied as a query parameter.
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | string | yes | The prompt to send to the model. |
{
"error": "Prompt is required"
}
{
"status": 503,
"warning": "This service is temporarily unavailable"
}
/api/gemini/getChatFromText/:prompt
Generates a reply using Gemini, maintaining conversation history in the session to build context.
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | string | yes | The user message for this turn of the conversation. |
{
"status": 503,
"warning": "This service is temporarily unavailable"
}
/api/gemini/getFromImage
Generates text using Gemini from a multimodal input of an uploaded image plus an optional prompt. The uploaded file is deleted after processing.
| Name | Type | Required | Description |
|---|---|---|---|
| image | file | yes | Uploaded image (multipart/form-data), max 2 MB. |
| prompt | string | no | Optional text prompt to accompany the image. |
{
"error": "Prompt is required"
}
{
"status": 503,
"warning": "This service is temporarily unavailable"
}
The Express API behind my site. Three small services that each solve a real problem I had, kept behind a shared middleware stack and covered by tests.
All endpoints below are mounted under /api/ (see server.js). The JSON route catalog is served at GET /api/.
| Endpoint | Purpose |
|---|---|
GET /api/github/getCommits/:word |
Search my commit history by keyword |
GET /api/github/getCommitsByRepoAndOwner/:owner/:repo |
Commits for a specific repository |
GET /api/url · POST /api/url/create · GET /api/url/:short_url · DELETE /api/url/delete/:short_url |
Mongoose-backed URL shortener |
GET /api/gemini/getFromText · GET /api/gemini/getChatFromText/:prompt |
Gemini text and chat prompts |
POST /api/gemini/getFromImage |
Gemini image prompts, 2 MB upload cap |
The OpenAI endpoints (
/api/openai/getResponse/:text,/api/openai/getImage/:text) are commented out inapi/routes/index.jsand not currently exposed.
Every request passes through helmet, CORS, compression, express-rate-limit, express-session
and a single error-handling middleware, so no route does its own error plumbing. Controllers,
services and models stay in separate layers: controllers handle HTTP, services own the outbound
calls, models own the data.
To get started with the project, clone the repository and install the dependencies:
git clone https://github.com/Khanos/khanos.backend.git
cd khanos.backend
npm install
To start the application, use the following command:
npm start
The application will start and listen on port 3000.
To start the application in development mode, use the following command:
npm run dev
The application starts with hot reload and request logging enabled.
To run the tests and code coverage run the following command:
npm run test
To run the tests and watch for changes on the files, run the following command:
npm run test:watch
The project has the following structure:
Licensed under the GNU Lesser General Public License v3.0.