{"id":31377988,"url":"https://github.com/antoniojvargas/smartcar","last_synced_at":"2026-04-13T06:03:04.314Z","repository":{"id":313987086,"uuid":"1053082048","full_name":"antoniojvargas/smartcar","owner":"antoniojvargas","description":"A Node.js and Express API that simulates Smartcar vehicle endpoints, including vehicle info, doors, fuel, battery, and engine control. Includes Swagger (OpenAPI) documentation and unit tests with Mocha, Chai, and Sinon.","archived":false,"fork":false,"pushed_at":"2025-09-19T17:38:06.000Z","size":207,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-19T19:56:54.396Z","etag":null,"topics":["chai","express","mocha","nodejs","openapi","rest-api","sinon","smartcar","swagger"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/antoniojvargas.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-09T01:02:49.000Z","updated_at":"2025-09-19T17:38:10.000Z","dependencies_parsed_at":"2025-09-09T23:52:27.984Z","dependency_job_id":"8b033cc5-1bb7-4b1d-94b9-408eebec0e44","html_url":"https://github.com/antoniojvargas/smartcar","commit_stats":null,"previous_names":["antoniojvargas/smartcar"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/antoniojvargas/smartcar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojvargas%2Fsmartcar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojvargas%2Fsmartcar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojvargas%2Fsmartcar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojvargas%2Fsmartcar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antoniojvargas","download_url":"https://codeload.github.com/antoniojvargas/smartcar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojvargas%2Fsmartcar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277326296,"owners_count":25799445,"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-09-28T02:00:08.834Z","response_time":79,"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":["chai","express","mocha","nodejs","openapi","rest-api","sinon","smartcar","swagger"],"created_at":"2025-09-28T05:03:12.389Z","updated_at":"2025-09-28T05:03:17.226Z","avatar_url":"https://github.com/antoniojvargas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smartcar# 🚗 Smartcar API\n\nA Node.js + Express implementation of a **Smartcar-like API** that provides vehicle information, security status, fuel/battery levels, and engine control.  \nThe project follows clean architecture principles with controllers, services, and logging integration.\n\n---\n\n## 📑 Features\n\n- **Vehicle Info** → `GET /vehicles/:id`\n- **Door Security Status** → `GET /vehicles/:id/doors`\n- **Fuel Level** → `GET /vehicles/:id/fuel`\n- **Battery Level** → `GET /vehicles/:id/battery`\n- **Start/Stop Engine** → `POST /vehicles/:id/engine`\n- Structured **logging** using [winston](https://github.com/winstonjs/winston).\n- Unit tests with **Mocha + Chai + Sinon**.\n- API documentation via **OpenAPI (Swagger)**.\n\n---\n\n## ⚙️ Installation\n\nClone the repository and install dependencies:\n\n```bash\ngit clone https://github.com/antoniojvargas/smartcar.git\ncd smartcar\n```\n\n## 🐳 Running with Docker\n\nThis project is containerized using Docker Compose.\nNo need to install Node.js locally — just run:\n\n```bash\ndocker-compose up -d --build\n```\n\nThis will:\n\n- Build the smartcar image\n\n- Start the container in development mode (nodemon)\n\n- Expose the API on http://localhost:3000\n\nTo stop the container:\n\n```bash\ndocker-compose down\n```\n\n---\n\n## 🧪 Testing\n\nRun the unit tests with Mocha + Chai + Sinon:\n\n```bash\nnpm test\n```\n\nThe test suite includes:\n\n- ✅ Happy path responses\n\n- ❌ Error handling (bad input, failed API responses)\n\n- ⚡ Edge cases (incomplete/malformed data)\n\n## 📘 API Endpoints\n\nVehicle Info\n\nGET /vehicles/:id\n\nExample\n\n```bash\ncurl -X GET http://localhost:3000/vehicles/1234\n```\n\nResponse\n\n```json\n{\n  \"vin\": \"1213231\",\n  \"color\": \"Metallic Silver\",\n  \"doorCount\": 4,\n  \"driveTrain\": \"v8\"\n}\n```\n\n---\n\nSecurity (Doors)\n\nGET /vehicles/:id/doors\n\nExample\n\n```bash\ncurl -X GET http://localhost:3000/vehicles/1234/doors\n```\n\nResponse\n\n```json\n[\n  { \"location\": \"frontLeft\", \"locked\": true },\n  { \"location\": \"frontRight\", \"locked\": true },\n  { \"location\": \"backLeft\", \"locked\": true },\n  { \"location\": \"backRight\", \"locked\": false }\n]\n```\n\n---\n\nFuel Range\n\nGET /vehicles/:id/fuel\n\nExample\n\n```bash\ncurl -X GET http://localhost:3000/vehicles/1234/fuel\n```\n\nResponse\n\n```json\n{ \"percent\": 30.2 }\n```\n\n---\n\nBattery Range\n\nGET /vehicles/:id/battery\n\nExample\n\n```bash\ncurl -X GET http://localhost:3000/vehicles/1234/battery\n```\n\nResponse\n\n```json\n{ \"percent\": 50.3 }\n```\n\n---\n\nStart/Stop Engine\n\nPOST /vehicles/:id/engine\nContent-Type: application/json\n\nExample\n\n```bash\ncurl -X POST http://localhost:3000/vehicles/1234/engine \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"action\":\"START\"}'\n```\n\nResponse\n\n```json\n{ \"status\": \"success\" }\n```\n\n---\n\n## 📖 📖 Interactive API Documentation (Swagger UI)\n\nYou can explore and test all endpoints using the built-in Swagger UI:\n\n➡️ http://localhost:3000/api-docs\n\nThis interactive documentation is automatically generated from the openapi.yml specification.\n\n---\n\n## 📂 Project Structure\n\n```bash\nsrc/\n  doc/                # API documentation files (e.g. OpenAPI/Swagger specs, markdown docs)\n  errors/             # Custom error classes (ValidationError, NotFoundError, etc.)\n  middleware/         # Express middleware (validation, sanitization, logging, etc.)\n  MMApi/\n  providers/          # External API providers (e.g. MM API integration layer)\n  routes/             # Express route definitions (map endpoints to controllers)\n  schemas/            # Joi schemas and validation logic\n  transformers/       # Transform raw API data\n  utils/logger.js     # Winston logger configuration and setup\n  validators          # Validate API responses (status codes, shapes)\n  app.js              # Express app setup (middleware, routes, error handling)\n  server.js           # Application entry point (starts the HTTP server)\ntests/                # Unit tests\n```\n\n---\n\n## 📝 Logging\n\nLogging is handled by Winston:\n\n- info → normal requests\n\n- warn → API/data issues\n\n- error → unexpected failures\n\nLogs are printed to the console, and can be extended to files or external monitoring services.\n\n---\n\n## 📜 License\n\nMIT License. Free to use and modify.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniojvargas%2Fsmartcar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoniojvargas%2Fsmartcar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniojvargas%2Fsmartcar/lists"}