{"id":24501488,"url":"https://github.com/ricin9/northwind-hono-api","last_synced_at":"2025-03-15T07:26:05.996Z","repository":{"id":255497865,"uuid":"850437971","full_name":"ricin9/northwind-hono-api","owner":"ricin9","description":"REST API uses popular sample database Northwind using Hono, Drizzle ORM","archived":false,"fork":false,"pushed_at":"2024-09-06T00:40:35.000Z","size":204,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T22:35:09.639Z","etag":null,"topics":["drizzle-orm","hono","northwind-database","rest-api"],"latest_commit_sha":null,"homepage":"https://northwind-api.miloudi.dev/","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/ricin9.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":"2024-08-31T19:09:44.000Z","updated_at":"2025-01-06T05:06:54.000Z","dependencies_parsed_at":"2025-01-21T22:39:40.143Z","dependency_job_id":null,"html_url":"https://github.com/ricin9/northwind-hono-api","commit_stats":null,"previous_names":["ricin9/northwind-hono-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricin9%2Fnorthwind-hono-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricin9%2Fnorthwind-hono-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricin9%2Fnorthwind-hono-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricin9%2Fnorthwind-hono-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricin9","download_url":"https://codeload.github.com/ricin9/northwind-hono-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243698164,"owners_count":20333068,"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","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":["drizzle-orm","hono","northwind-database","rest-api"],"created_at":"2025-01-21T22:29:32.308Z","updated_at":"2025-03-15T07:26:05.972Z","avatar_url":"https://github.com/ricin9.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Northwind API\n\nThis project is a REST API implementation of the Northwind sample database provided by Microsoft. The API offers CRUD operations on all resources with some business rules and constraints made up by me.\n\n## Live API\n\nThe API is hosted at: https://northwind-api.miloudi.dev/\n\n## Technologies Used\n\n- Hono.js\n- Drizzle ORM\n- Libsql/Turso DB\n- Zod and Zod to OpenAPI\n- Scalar for OpenAPI UI\n- Deployed on Cloudflare Workers\n\n## Getting Started\n\nTo run the project locally:\n\n```bash\npnpm install\npnpm run dev     # for local dev with wrangler\npnpm run dev:bun # for local dev with Bun\n```\n\nTo deloy the project to Cloudflare Workers:\n\n```bash\npnpm run deploy\n```\n\n## API Documentation\n\nThe API documentation is available at the root URL of the deployed API. It provides a comprehensive overview of all available endpoints, request/response schemas, and example usage.\n\n## Generic Filter Pagination Sort Method\n\nThe project includes a powerful generic method for filtering, pagination, and sorting, located in the `filter-pagination-sorting.ts` file. This method can be used with any Drizzle SQLite table and is designed to accommodate browser clients using URL search params to get a filtered, sorted, and paginated list.\n\nKey features of the generic method:\n\n1. Supports nested query parameters using the `qs` library.\n2. Generates a Zod schema for validating and parsing query parameters.\n3. Handles various filter operators: eq, ne, lt, lte, gt, gte, like, in, nin, and is (null/notnull).\n4. Automatically detects column data types and applies appropriate casting.\n5. Supports multiple sort fields and directions.\n6. Provides pagination with customizable page size.\n\nUsage example:\n\n```typescript\nconst filteringInput = c.req.valid(\"query\"); // query string parsed with qs library that supports nesting and arrays\nconst { data, totalCount } = await advancedQuery(table, filteringInput); // table is drizzle sqlite table\nconst metadata = generatePaginationMetadata(c, totalCount); // a utility to generate page count and navigation links\nreturn c.json({ metadata, data }, 200);\n```\n\nFor more details on the implementation, refer to the `src/util/filter-pagination-sorting.ts` file in the project.\n\nThis generic method provides a flexible and powerful way to handle complex querying requirements in your API, making it easy to implement advanced filtering, sorting, and pagination across different resources.\n\nFor questions or suggestions please send me a message or open a issue.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricin9%2Fnorthwind-hono-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricin9%2Fnorthwind-hono-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricin9%2Fnorthwind-hono-api/lists"}