{"id":50294730,"url":"https://github.com/chrisrobison/simple-api","last_synced_at":"2026-05-28T08:04:00.196Z","repository":{"id":286201764,"uuid":"960701750","full_name":"chrisrobison/simple-api","owner":"chrisrobison","description":"A simple, RESTful node.js API that provides basic CRUD functionality for various backend data stores such as mysql, mongodb, the file system, json files, and more.","archived":false,"fork":false,"pushed_at":"2025-04-04T22:43:37.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T23:26:29.407Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisrobison.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-04T22:38:17.000Z","updated_at":"2025-04-04T22:43:41.000Z","dependencies_parsed_at":"2025-04-04T23:36:37.402Z","dependency_job_id":null,"html_url":"https://github.com/chrisrobison/simple-api","commit_stats":null,"previous_names":["chrisrobison/simple-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chrisrobison/simple-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrobison%2Fsimple-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrobison%2Fsimple-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrobison%2Fsimple-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrobison%2Fsimple-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisrobison","download_url":"https://codeload.github.com/chrisrobison/simple-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisrobison%2Fsimple-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33599494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"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":"2026-05-28T08:03:58.833Z","updated_at":"2026-05-28T08:04:00.184Z","avatar_url":"https://github.com/chrisrobison.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple API\n\nA flexible and modular REST API that provides a standardized interface to various backend data stores. Built with Node.js, Express, and MySQL, this API automatically generates endpoints for your database tables and handles relationships between entities.\n\n## Features\n\n- 🚀 Automatic REST endpoint generation for database tables\n- 🔄 Full CRUD operations support\n- 🤝 Built-in relationship management via Clamp table\n- 📝 Dynamic query filtering\n- 📄 Pagination support\n- 🔌 Modular design for multiple database backends\n- 🔒 Environment-based configuration\n\n## Prerequisites\n\n- Node.js (v14 or higher)\n- MySQL (v5.7 or higher)\n- npm or yarn\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/simple-api.git\ncd simple-api\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Create a `.env` file in the project root:\n```bash\ncp .env.example .env\n```\n\n4. Update the `.env` file with your database credentials:\n```env\nDB_HOST=localhost\nDB_USER=your_username\nDB_PASSWORD=your_password\nDB_NAME=simple_api\nDB_PORT=3306\n```\n\n## Usage\n\n### Starting the Server\n\n```bash\nnpm start\n```\n\nThe server will start on port 3000 by default. You can modify this by setting the `PORT` environment variable.\n\n### API Endpoints\n\nThe API automatically generates the following endpoints for each table in your database:\n\n- `GET /api/TABLE_NAME` - Get all records\n- `GET /api/TABLE_NAME?pg=0\u0026cnt=100` - Get paginated records\n- `GET /api/TABLE_NAME/:id` - Get a specific record\n- `PUT /api/TABLE_NAME` - Create a new record\n- `POST /api/TABLE_NAME/:id` - Update a record\n- `DELETE /api/TABLE_NAME/:id` - Delete a record\n- `GET /api/TABLE_NAME/clamp/:localId/:remoteTable/:remoteId` - Create a relationship\n\n### Example Requests\n\n#### Create a New User with Related Employee Record\n\n```json\nPUT /api/User\n{\n    \"User\": [{\n        \"UserID\": \"new\",\n        \"User\": \"jsmith\",\n        \"Password\": \"securepass\",\n        \"Name\": \"John Smith\",\n        \"Phone\": \"415-555-1212\",\n        \"Employee\": {\n            \"EmployeeID\": \"new\",\n            \"Employee\": \"John Smith\",\n            \"Address\": \"123 Main St\",\n            \"City\": \"San Francisco\",\n            \"State\": \"CA\",\n            \"Zip\": \"94105\"\n        }\n    }]\n}\n```\n\n#### Update a User\n\n```json\nPOST /api/User/17\n{\n    \"User\": [{\n        \"UserID\": \"17\",\n        \"Password\": \"newpassword\",\n        \"Name\": \"John Smith Jr\"\n    }]\n}\n```\n\n#### Search Users\n\n```json\nGET /api/search\n{\n    \"search\": {\n        \"User\": {\n            \"Name\": \"%john%\",\n            \"Active\": 1\n        }\n    }\n}\n```\n\n## Database Schema\n\nThe API uses a Clamp table for managing relationships:\n\n```sql\nCREATE TABLE Clamp (\n    id INT PRIMARY KEY AUTO_INCREMENT,\n    local VARCHAR(255) NOT NULL,\n    local_id INT NOT NULL,\n    remote VARCHAR(255) NOT NULL,\n    remote_id INT NOT NULL,\n    context VARCHAR(255)\n);\n```\n\n## Development\n\n### Adding Custom Controllers\n\nYou can extend the base controller for custom table handling:\n\n```javascript\nclass CustomUserController extends Boss {\n    async beforeCreate(data) {\n        // Custom logic before creating a user\n        data.Password = await bcrypt.hash(data.Password, 10);\n        return data;\n    }\n}\n```\n\n### Running Tests\n\n```bash\nnpm test\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nFor support, please open an issue in the GitHub repository or contact the maintainers.\n\n## Acknowledgments\n\n- Express.js team for the excellent web framework\n- MySQL team for the robust database system\n- All contributors who have helped with the project\n\n## Security\n\nPlease note that this is a basic implementation. For production use, you should:\n\n- Implement proper authentication\n- Add input validation\n- Use HTTPS\n- Implement rate limiting\n- Add proper error handling\n- Sanitize SQL queries\n- Implement proper password hashing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisrobison%2Fsimple-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisrobison%2Fsimple-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisrobison%2Fsimple-api/lists"}