This project provides a simple HTTP API to perform search queries using Deno.
- Deno installed.
First, clone the repository to your local machine:
git clone https://github.com/PrakharDoneria/Playground-Ai-Search-REST-API.git
cd Playground-Ai-Search-REST-API
Deno manages dependencies via URLs, so there are no additional steps needed for installation beyond cloning the repository.
Since Deno is interpreted and runs TypeScript natively, there's no traditional build step required. However, you can use the following commands to check your code formatting and linting:
-
Format code:
deno fmt
-
Lint code:
deno lint
To start the server, run the following command:
deno task start
This command will start the HTTP server, and you should see the following output indicating that the server is running:
HTTP webserver running. Access it at: http://localhost:8000/
To perform a search, send a GET request to the /search
endpoint with a query parameter q
.
You can use curl
to test the endpoint:
curl "http://localhost:8000/search?q=test"
The API will return a JSON response with the search results. If no results are found, or if there is an error, appropriate error messages will be returned.
The project directory is structured as follows:
Playground-Ai-Search-REST-API/
│
├── index.ts
├── deno.json
└── README.md
This is the main file containing the server code. It sets up an HTTP server and handles search requests.
Specifies files and directories that should be ignored by Git.
Configuration file for Deno, defining custom tasks, formatting options, and linting rules.
This file. Provides an overview of the project, setup instructions, and usage examples.
The project uses a deno.json
file for configuration. This includes custom tasks, formatting options, and linting rules.
{
"tasks": {
"start": "deno run --allow-net index.ts"
},
"fmt": {
"options": {
"useTabs": false,
"lineWidth": 80,
"indentWidth": 2,
"singleQuote": true,
"proseWrap": "always"
}
},
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}