{"id":18647603,"url":"https://github.com/artcom/acms-api","last_synced_at":"2025-04-11T13:30:48.351Z","repository":{"id":58973204,"uuid":"348050468","full_name":"artcom/acms-api","owner":"artcom","description":"Manipulate content of JSON files in a git repository via HTTP.  API for https://github.com/artcom/acms-compose.","archived":false,"fork":false,"pushed_at":"2022-12-22T02:06:02.000Z","size":856,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-18T05:32:23.566Z","etag":null,"topics":[],"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/artcom.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}},"created_at":"2021-03-15T16:48:06.000Z","updated_at":"2023-01-31T21:41:42.000Z","dependencies_parsed_at":"2023-01-30T05:15:18.668Z","dependency_job_id":null,"html_url":"https://github.com/artcom/acms-api","commit_stats":null,"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Facms-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Facms-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Facms-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artcom%2Facms-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artcom","download_url":"https://codeload.github.com/artcom/acms-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223400069,"owners_count":17139314,"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-11-07T06:27:07.774Z","updated_at":"2024-11-07T06:27:08.431Z","avatar_url":"https://github.com/artcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ACMS API\n\nA JSON API to serve the contents of JSON files from a Git repo. All files in the repo are expected to be JSON files with a `.json` extension.\n\n## Configuration\n\n### Environment Variables\n\nThe service uses the following environment variables:\n\n* `REPO_URI` _(required)_ URI of the Git repository\n* `SIGNATURE_MAIL` _(optional)_ E-mail address used for generated commits\n* `REPO_TOKEN` _(optional)_ Token for accessing private repo\n* `ACMS_API_VAR_*`_(optional)_ A list of variables to be replaced in the content (see \"Variable Replacement\" for details)\n\n### Variable Replacement\n\nThe service replaces variables in files when serving and writing. All variables need to be environment variables prefixed with `ACMS_API_VAR_`. Example:\n```\nexport ACMS_API_VAR_MY_FANCY_VARIABLE=\"value\"\n```\n\nIf a variable occurs in the content it will be replaced by the given value. When writing to the repo values will also be replaced by their variable name.\n\n**Example**\n```\nContent:                          \"Hello ${properGreeting}.\"  \nACMS_API_VAR_PROPER_GREETING:     \"World\"  \nServed:                           \"Hello World.\"\n````\n\n## API\n\n### `GET /:version`\n\nReturns the contents of the repo at the given version as a single JSON object.\n\nVersion can either be a Git commit hash or a reference. The response will contain the Git commit hash in the `Git-Commit-Hash` header.\n\nThe returned object contains the contents of every file in the root of the repo in a property named like the file (without extension). For every directory, it contains another object with the same structure.\n\nIf a repo contains `file1.json`, `file2.json`, `directory/fileA.json` and `directory/subDirectory/fileB.json`, the response would be structured as follows:\n\n```json5\n// GET \u003curl\u003e/master\n{\n  \"directory\" : {\n    \"fileA\": {\n      \"foo\": \"bar\"\n    },\n    \"subDirectory\": {\n      \"fileB\": {\n        \"foo\": \"bar\"\n      }\n    }\n  },\n  \"file1\": {\n    \"min\": 1,\n    \"max\": 10\n  },\n  \"file2\": [\n    \"item1\",\n    \"item2\",\n    \"item3\"\n  ]\n}\n```\n\n### `GET /:version/path`\n\nOptionally, the previous route can be called with an additional path into the content to retrieve specific data.\n\n```json5\n// GET \u003curl\u003e/master/directory/fileA\n{\n  \"foo\": \"bar\"\n}\n```\n\n### `GET /:version/path?listFiles=true`\n\nThe `listFiles` parameter returns a flat structure with every file in `path` and in subdirectories where the file path is the `key` and the file content the `value`.\n\n```json5\n// GET \u003curl\u003e/master/directory?listFiles\n{\n  \"file1\": \n   {\n      \"foo\": \"bar\"\n   },\n   \"file2\": [1, 2, 3],\n   \"subDirectory/file3\": \"foo\"\n}\n```\n\n### `PUT /:version/path`\n\nThe content of a directory or single file can be replaced using a PUT request. The body is expected to contain JSON data for all files and subdirectories or a file. The intended workflow is to query a path using `GET /:version/path`, make the desired changes to the data and send the whole data back via `PUT /:parentVersion/path`.\n\nA new Git commit will be created and merged if necessary. The response will contain the hash of the new (merge) commit in the `Git-Commit-Hash` header. If the merge fails, an error will be returned.\n\n#### Examples\n\nThe body to replace everything inside directory looks like this:\n\n```json5\n// PUT \u003curl\u003e/master/directory\n{\n  \"files\": {\n    \"fileA\": {\n      \"foo\": \"bar\"\n    },\n    \"subDirectory/fileB\": {\n        \"foo\": \"bar\"\n      }\n    }\n  }\n}\n```\n\nThe body to replace a single file only looks like this:\n```json5\n// PUT \u003curl\u003e/master/file1\n{\n  \"fileContent\" : {\n    \"min\": 10,\n    \"max\": 30\n  }\n}\n```\n\nAdditional properties are:  \n`author`: Will be used as commit author.  \n`updateBranch`: The branch which should be updated to the new commit (default: \"master\").\n\n### `DELETE /:version/path`\n\nA directory or a single file can be deleted using a DELETE request. The body is expected to contain JSON data containing a `file` or `directory` property.\n\nA new Git commit will be created and merged if necessary. The response will contain the hash of the new (merge) commit in the `Git-Commit-Hash` header. If the merge fails, an error will be returned.\n\n#### Examples\n\nDelete single file:\n```json5\n// DELETE \u003curl\u003e/master/parentDirectory\n{\n  \"file\": \"fileToDelete\"\n}\n```\n\nDelete a directory:\n```json5\n// DELETE \u003curl\u003e/master/parentDirectory\n{\n  \"directory\": \"directoryToDelete\"\n}\n```\n\nAdditional properties are:  \n`author`: Will be used as commit author.  \n`updateBranch`: The branch which should be updated to the new commit (default: \"master\").\n\n## Development Setup\n\n```bash\nnpm install\nREPO_URI=\u003crepo-url\u003e npm run watch\n```\n\n## Deployment\n\n### Heroku/Dokku\n\nThe service is designed to be deployed using [Dokku](http://dokku.viewdocs.io/dokku/) and will probably also work with [Heroku](https://www.heroku.com/) and other compatible platforms.\n\n### Dockerfile\n\nThe service contains a Dockerfile to start it directly with Docker.\n\n## Troubleshooting\nOn Mac OS if you encounter this error: `error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?` when running `npm install` with node 16 try: `export CXXFLAGS=\"--std=c++17\" \u0026\u0026 npm install` (see this node-gyp [issue](https://github.com/nodejs/node-gyp/issues/2387)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartcom%2Facms-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartcom%2Facms-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartcom%2Facms-api/lists"}