{"id":23864707,"url":"https://github.com/mohasinkr/micro-blog-backend","last_synced_at":"2026-04-13T04:39:30.624Z","repository":{"id":270117239,"uuid":"908737821","full_name":"mohasinkr/micro-blog-backend","owner":"mohasinkr","description":"Micro blog backend made using bun, express and ts 🐰","archived":false,"fork":false,"pushed_at":"2025-10-07T10:31:53.000Z","size":281,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"testing","last_synced_at":"2025-10-07T12:24:10.318Z","etag":null,"topics":["bun","docker","express","groq-ai","postgres","supabase","typescript","vine"],"latest_commit_sha":null,"homepage":"","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/mohasinkr.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-26T20:45:47.000Z","updated_at":"2025-05-27T08:37:14.000Z","dependencies_parsed_at":"2025-10-07T12:12:27.290Z","dependency_job_id":"01e9c62a-363a-4fee-88f2-8c06f0b67cca","html_url":"https://github.com/mohasinkr/micro-blog-backend","commit_stats":null,"previous_names":["mohasinkr/micro-blog-backend"],"tags_count":0,"template":false,"template_full_name":"mohasinkr/express-ts-starter-v1","purl":"pkg:github/mohasinkr/micro-blog-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohasinkr%2Fmicro-blog-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohasinkr%2Fmicro-blog-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohasinkr%2Fmicro-blog-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohasinkr%2Fmicro-blog-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohasinkr","download_url":"https://codeload.github.com/mohasinkr/micro-blog-backend/tar.gz/refs/heads/testing","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohasinkr%2Fmicro-blog-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31740266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T03:27:07.512Z","status":"ssl_error","status_checked_at":"2026-04-13T03:26:53.610Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bun","docker","express","groq-ai","postgres","supabase","typescript","vine"],"created_at":"2025-01-03T08:30:26.476Z","updated_at":"2026-04-13T04:39:30.619Z","avatar_url":"https://github.com/mohasinkr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro-Blog Backend\r\n\r\nA robust backend API for a micro-blogging platform built with Express.js, TypeScript, and Supabase. This project provides a complete set of RESTful endpoints for user authentication, post management, comments, file uploads, and AI-generated content.\r\n\r\n## Features\r\n\r\n- 🔐 **Authentication** - Secure user signup and login with JWT\r\n- 📝 **Posts Management** - Create, read, update, and delete posts\r\n- 💬 **Comments** - Add and retrieve comments on posts\r\n- 👍 **Likes** - Like and unlike posts\r\n- 🖼️ **File Uploads** - Upload and manage media files for posts\r\n- 🤖 **AI Integration** - Generate post content using Groq AI\r\n- 🛡️ **Security** - Rate limiting, CORS, and Helmet for protection\r\n- 🔍 **Validation** - Request validation using VineJS\r\n- 🚦 **Error Handling** - Comprehensive error handling system\r\n\r\n## Tech Stack\r\n\r\n- **Language**: TypeScript\r\n- **Runtime**: Node.js/Bun\r\n- **Framework**: Express.js\r\n- **Database**: Supabase (PostgreSQL)\r\n- **Authentication**: JWT + Supabase Auth\r\n- **Validation**: VineJS\r\n- **File Storage**: Supabase Storage\r\n- **AI**: Groq SDK\r\n- **Security**: Helmet, Express Rate Limit\r\n- **Logging**: Morgan\r\n- **Containerization**: Docker\r\n\r\n## Prerequisites\r\n\r\n- Node.js (v16+) or Bun runtime\r\n- Supabase account\r\n- Groq API key (for AI features)\r\n\r\n## Environment Variables\r\n\r\nCreate a `.env` file in the root directory with the following variables:\r\n\r\n```\r\nPORT=4500\r\nHOST=http://localhost\r\nENVIRONMENT=development\r\nJWT_SECRET=your_jwt_secret\r\nSUPABASE_URL=your_supabase_url\r\nSUPABASE_KEY=your_supabase_key\r\nGROQ_API_KEY=your_groq_api_key\r\nSALT=your_password_salt\r\n```\r\n\r\nYou can use the utility script to generate a secure JWT secret:\r\n\r\n```bash\r\nbun src/utils/secretKeyGen.js\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/yourusername/micro-blog-backend.git\r\ncd micro-blog-backend\r\n\r\n# Install dependencies\r\nnpm install\r\n# or with Bun\r\nbun install\r\n```\r\n\r\n## Running the Application\r\n\r\n```bash\r\n# Development mode with hot reload\r\nnpm run dev\r\n# or with Bun\r\nbun dev\r\n\r\n# Production mode\r\nnpm start\r\n# or with Bun\r\nbun start\r\n\r\n# Docker development\r\nnpm run docker:dev\r\n```\r\n\r\n## API Endpoints\r\n\r\n### Base URL\r\n\r\n```\r\nhttp://localhost:4500/api/v1\r\n```\r\n\r\n### Authentication\r\n\r\n| Method | Endpoint       | Description                | Auth Required |\r\n|--------|---------------|----------------------------|---------------|\r\n| POST   | /auth/signup   | Register a new user        | No           |\r\n| POST   | /auth/login    | Login a user               | No           |\r\n\r\n### Posts\r\n\r\n| Method | Endpoint       | Description                | Auth Required |\r\n|--------|---------------|----------------------------|---------------|\r\n| GET    | /posts         | Get all posts              | Yes          |\r\n| GET    | /posts/:id     | Get a specific post        | Yes          |\r\n| POST   | /posts         | Create a new post          | Yes          |\r\n| PATCH  | /posts/:id     | Update a post              | Yes          |\r\n| DELETE | /posts/:id     | Delete a post              | Yes          |\r\n| GET    | /posts/:id/likes | Get likes for a post      | Yes          |\r\n| POST   | /posts/:id/like | Like a post               | Yes          |\r\n| DELETE | /posts/:id/like | Unlike a post             | Yes          |\r\n| POST   | /posts/assets  | Upload media for a post    | Yes          |\r\n\r\n### Comments\r\n\r\n| Method | Endpoint       | Description                | Auth Required |\r\n|--------|---------------|----------------------------|---------------|\r\n| GET    | /comments/:id  | Get comments for a post    | Yes          |\r\n| POST   | /comments/:id  | Add a comment to a post    | Yes          |\r\n\r\n### AI Features\r\n\r\n| Method | Endpoint       | Description                | Auth Required |\r\n|--------|---------------|----------------------------|---------------|\r\n| GET    | /ai/generate-post | Generate post content using AI | No    |\r\n\r\n### Utility Endpoints\r\n\r\n| Method | Endpoint       | Description                | Auth Required |\r\n|--------|---------------|----------------------------|---------------|\r\n| GET    | /              | Server status              | No           |\r\n| GET    | /health-check  | Server health check        | No           |\r\n| GET    | /gen-error     | Test error handling        | No           |\r\n\r\n## Request \u0026 Response Examples\r\n\r\n### Authentication\r\n\r\n#### Signup\r\n\r\n```http\r\nPOST /api/v1/auth/signup\r\nContent-Type: application/json\r\n\r\n{\r\n  \"username\": \"user@example.com\",\r\n  \"password\": \"Password123!\",\r\n  \"password_confirmation\": \"Password123!\"\r\n}\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"status\": 200,\r\n  \"message\": \"A verification email has been sent to your email address. Please check your inbox for further instructions.\",\r\n  \"data\": {\r\n    \"token\": \"jwt_token_here\"\r\n  }\r\n}\r\n```\r\n\r\n#### Login\r\n\r\n```http\r\nPOST /api/v1/auth/login\r\nContent-Type: application/json\r\n\r\n{\r\n  \"username\": \"user@example.com\",\r\n  \"password\": \"Password123!\"\r\n}\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"status\": 200,\r\n  \"messages\": \"You have successfully logged in.\",\r\n  \"data\": {\r\n    \"token\": \"jwt_token_here\",\r\n    \"user\": {\r\n      \"id\": \"user_id\",\r\n      \"email\": \"user@example.com\"\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Posts\r\n\r\n#### Create Post\r\n\r\n```http\r\nPOST /api/v1/posts\r\nContent-Type: application/json\r\nAuthorization: Bearer jwt_token_here\r\n\r\n{\r\n  \"content\": \"This is my first post!\"\r\n}\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"status\": 201,\r\n  \"message\": \"Post created successfully.\"\r\n}\r\n```\r\n\r\n#### Get All Posts\r\n\r\n```http\r\nGET /api/v1/posts\r\nAuthorization: Bearer jwt_token_here\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n  \"success\": true,\r\n  \"status\": 200,\r\n  \"data\": [\r\n    {\r\n      \"id\": \"post_id\",\r\n      \"content\": \"This is my first post!\",\r\n      \"created_at\": \"2023-06-01T12:00:00Z\",\r\n      \"likes\": []\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n### File Upload\r\n\r\n```http\r\nPOST /api/v1/posts/assets\r\nContent-Type: multipart/form-data\r\nAuthorization: Bearer jwt_token_here\r\n\r\nfile: [binary data]\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n  \"message\": \"File uploaded successfully.\",\r\n  \"data\": {\r\n    \"path\": \"images/1623456789-a1b2c3d4.jpg\"\r\n  }\r\n}\r\n```\r\n\r\n## Error Handling\r\n\r\nThe API uses a standardized error response format:\r\n\r\n```json\r\n{\r\n  \"success\": false,\r\n  \"status\": 400,\r\n  \"message\": \"Error message here\"\r\n}\r\n```\r\n\r\nIn development mode, the response will also include a stack trace.\r\n\r\n## Security\r\n\r\n- **Authentication**: JWT-based authentication via Supabase Auth\r\n- **Rate Limiting**: 100 requests per 15 minutes\r\n- **CORS**: Configured to allow specific origins\r\n- **Helmet**: HTTP headers secured with Helmet middleware\r\n- **Input Validation**: All requests validated with VineJS\r\n\r\n## Docker Support\r\n\r\nThe project includes Docker configuration for easy deployment:\r\n\r\n```bash\r\n# Build the Docker image\r\ndocker build -t micro-blog-backend .\r\n\r\n# Run with Docker Compose\r\ndocker-compose up\r\n```\r\n\r\n## Development\r\n\r\n```bash\r\n# Type checking\r\nnpm run type-check\r\n\r\n# Linting\r\nnpm run lint\r\n\r\n# Formatting\r\nnpm run format\r\n\r\n# Fix linting issues (force)\r\nnpm run fix-force\r\n```\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## Author\r\n\r\nMohasin K.R","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohasinkr%2Fmicro-blog-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohasinkr%2Fmicro-blog-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohasinkr%2Fmicro-blog-backend/lists"}