{"id":27627154,"url":"https://github.com/pshycodr/code-first-test","last_synced_at":"2025-08-10T13:09:46.682Z","repository":{"id":286813747,"uuid":"962642589","full_name":"pshycodr/code-first-test","owner":"pshycodr","description":"This is for Community tests only.","archived":false,"fork":false,"pushed_at":"2025-04-08T13:14:29.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-01T02:25:18.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pshycodr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-08T13:09:34.000Z","updated_at":"2025-04-08T13:14:33.000Z","dependencies_parsed_at":"2025-04-08T14:35:58.458Z","dependency_job_id":null,"html_url":"https://github.com/pshycodr/code-first-test","commit_stats":null,"previous_names":["pshycodr/code-first-test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pshycodr/code-first-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshycodr%2Fcode-first-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshycodr%2Fcode-first-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshycodr%2Fcode-first-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshycodr%2Fcode-first-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pshycodr","download_url":"https://codeload.github.com/pshycodr/code-first-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshycodr%2Fcode-first-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269728372,"owners_count":24465641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-23T13:53:16.232Z","updated_at":"2025-08-10T13:09:46.630Z","avatar_url":"https://github.com/pshycodr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 💡 Idea API — RESTful Backend with Hono + Cloudflare Workers\n\nA simple REST API built using the [Hono](https://hono.dev) framework and deployed on Cloudflare Workers. This API allows users to submit and view ideas for an offline event. Data is stored **in-memory** for the duration of the server’s runtime.\n\n---\n\n## API:  https://codefirsttest.aroy262692.workers.dev/ideas\n\n## 📌 API Endpoints\n\n### ➕ POST `/ideas`\nCreate a new idea.\n\n#### ✅ Request Body (JSON)\n```json\n{\n  \"title\": \"Workshop on Creativity\",\n  \"description\": \"A deep dive into design thinking.\"\n}\n```\n\n#### 🟢 Success Response\n- **Status Code:** `201 Created`\n- **Response:**\n```json\n{\n  \"id\": 1,\n  \"title\": \"Workshop on Creativity\",\n  \"description\": \"A deep dive into design thinking.\"\n}\n```\n\n#### 🔴 Error Response (Invalid Input)\n- **Status Code:** `400 Bad Request`\n- **Response:**\n```json\n{\n  \"error\": \"Title and description are required and must be non-empty strings.\"\n}\n```\n\n---\n\n### 📥 GET `/ideas`\nRetrieve all submitted ideas.\n\n#### 🟢 Success Response\n```json\n[\n  {\n    \"id\": 1,\n    \"title\": \"Workshop on Creativity\",\n    \"description\": \"A deep dive into design thinking.\"\n  },\n  ...\n]\n```\n\n---\n\n## ❓ Conceptual Questions\n\n### 1. What are the main HTTP methods used in REST APIs, and what is the typical purpose of each?\n\n- **GET**: Retrieves data from the server.\n- **POST**: Creates a new resource on the server.\n- **PUT**: Updates an existing resource entirely.\n- **PATCH**: Partially updates a resource.\n- **DELETE**: Removes a resource from the server.\n\nThese methods correspond to CRUD (Create, Read, Update, Delete) operations:\n- **Create**: POST\n- **Read**: GET\n- **Update**: PUT/PATCH\n- **Delete**: DELETE\n\n---\n\n### 2. Why is input validation important for a backend API?\n\nInput validation is crucial because it:\n- Prevents **bad or malformed data** from entering your system.\n- Protects against **security threats** like injection attacks.\n- Ensures **data consistency**.\n- Helps return **meaningful error messages** to clients.\n- Prevents server crashes due to unexpected input types or structures.\n\nWithout validation, the server could process incorrect data or become vulnerable to malicious attacks.\n\n---\n\n## 🚀 How to Run the Server Locally\n\n### 🧰 Prerequisites\n- Node.js\n- `npm`\n- `wrangler` (Cloudflare's developer CLI)\n\nInstall Wrangler globally:\n```bash\nnpm install -g wrangler\n```\n\n### ⚙️ Setup\n\n1. Clone the repo:\n```bash\ngit clone https://github.com/pshycodr/code-first-test.git\ncd idea-api-hono\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Start development server locally:\n```bash\nnpm run dev\n```\n\n4. Deploy to Cloudflare Workers:\n```bash\nnpm run deploy\n```\n\u003e [!IMPORTANT]\n\u003e Make sure to set up your Cloudflare account and configure `wrangler.toml` with your account details.\n\n---\n\n## 📁 Project Structure\n\n```\nidea-api-hono/\n│\n├── src/\n│   └── index.ts         # API logic (Hono app)\n├── wrangler.toml        # Cloudflare config\n├── tsconfig.json        # TypeScript config\n├── package.json         # Dependencies \u0026 scripts\n└── README.md            # This file\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpshycodr%2Fcode-first-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpshycodr%2Fcode-first-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpshycodr%2Fcode-first-test/lists"}