{"id":16823487,"url":"https://github.com/digitalbrainjs/rest","last_synced_at":"2025-04-05T10:12:48.598Z","repository":{"id":41749894,"uuid":"225674138","full_name":"DigitalBrainJS/rest","owner":"DigitalBrainJS","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-06T15:33:17.000Z","size":554,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T20:34:33.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/DigitalBrainJS.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}},"created_at":"2019-12-03T17:07:14.000Z","updated_at":"2022-12-13T18:23:53.000Z","dependencies_parsed_at":"2023-01-23T09:10:23.277Z","dependency_job_id":null,"html_url":"https://github.com/DigitalBrainJS/rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalBrainJS%2Frest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalBrainJS%2Frest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalBrainJS%2Frest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalBrainJS%2Frest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DigitalBrainJS","download_url":"https://codeload.github.com/DigitalBrainJS/rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"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":[],"created_at":"2024-10-13T11:08:09.197Z","updated_at":"2025-04-05T10:12:48.567Z","avatar_url":"https://github.com/DigitalBrainJS.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Installation\n- set proper config variables in *config/default.js* for mysql\u0026redis connections\n- run command *\"npm run generate\"* to generate mock data for mysql db\n- start REST server using command *\"npm run dev\"* (or use *\"npm start\"* to start the server in production environment)\n\n## Resources\n- Author (mounted at /api/v1/authors)\n    - `id: Integer`\n    - `name: String`    \n- Book ( mounted at /api/v1/books)\n    - `id: Integer`\n    - `title: String`\n    - `description: String`\n    - `author: Integer` - reference to author id\n    - `author_name: String` - reference to author name (read-only) \n    - `image: String`\n    - `date: Date`\n## REST endpoints\n**Books**\n- `[GET]` endpoint?[params list] - list books\n\n    params list:\n    - `offset: Integer` - If negative, it is treated as `totalLength - offset`\n    - `limit: Integer`\n    - `fields` - comma separated fields to retrieve (fields=title,description,date) \n    - `order` - comma separated fields, \"-\" before field name means desc sorting, asc otherwise (order=-date)\n    - `where` - comma separated expressions like `field:[operator]:[value]:[useOR]`\n        - `operator` supported operators: `like`, `eq` (default), `gt`, `lt`\n        - `useOR` if any value is present, conditions will be combined by the OR operator\n \n    \n- `[GET]` endpoint/:resourceId?[params] - get specific resource\n\n    params list:\n    - fields - (to simplify the code logic, field filtering is ignored when returning a cached entry)\n- `[POST]` endpoint (add resource)\n- `[PATCH]` endpoint/:resourceId (update the data for the specified resource)\n \n ## Cache remarks\n There are two kinds of caches here:\n - dumb caching that relies on the query string for a very short time (15 seconds) without any cache invalidation logic.\n - entity cache that relies on the id of each entity. Cache invalidation is performed on every entity updating.\n ## Some request examples\n - http://localhost:3000/api/v1/books/1\n - http://localhost:3000/api/v1/books/1?fields=title\n - http://localhost:3000/api/v1/books\n - http://localhost:3000/api/v1/books?fields=id,title,author_name\n - http://localhost:3000/api/v1/books?fields=id,title,date\u0026order=-date\n - http://localhost:3000/api/v1/books?fields=id,title,date\u0026order=-date\u0026where=date:gt:1980-01-01,date:lt:2000-01-01\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbrainjs%2Frest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalbrainjs%2Frest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbrainjs%2Frest/lists"}