{"id":23143606,"url":"https://github.com/digitalinteraction/ongoingness-api","last_synced_at":"2025-08-17T14:33:44.904Z","repository":{"id":51800438,"uuid":"171446748","full_name":"digitalinteraction/ongoingness-api","owner":"digitalinteraction","description":"API for the Ongoingness Project","archived":false,"fork":false,"pushed_at":"2021-05-09T23:12:27.000Z","size":39001,"stargazers_count":0,"open_issues_count":8,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-21T08:07:17.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalinteraction.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-19T09:40:16.000Z","updated_at":"2020-01-29T13:16:54.000Z","dependencies_parsed_at":"2022-08-17T15:31:30.912Z","dependency_job_id":null,"html_url":"https://github.com/digitalinteraction/ongoingness-api","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fongoingness-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fongoingness-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fongoingness-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fongoingness-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalinteraction","download_url":"https://codeload.github.com/digitalinteraction/ongoingness-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230136107,"owners_count":18178813,"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-12-17T15:13:50.463Z","updated_at":"2024-12-17T15:13:50.537Z","avatar_url":"https://github.com/digitalinteraction.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ongoingess API\n\u003e API for the [Ongoingness](https://ongoingness.cargocollective.com/) project.\n\n![BSD-3 license](https://img.shields.io/badge/License-BSD3-blue.svg)\n\n## Build\nThe API requires the following envrionment variables, store these in a `.env` file at the route of the directory,\nor pass them in through Docker. Boolean env variables are either `true` or `false`. Uppercase will not be detected.\n\n| **Name**               | **Type**| **Description**                                                                             |\n|------------------------|---------|---------------------------------------------------------------------------------------------|\n| DEBUG                  | Boolean | Returns full error messages if `true`                                                       |\n| APP_SECRET             | String  | Application secret for generating JWT tokens                                                |\n| LOCAL                  | Boolean | Uses local files rather than AWS S3 for file management if `true`, better for testing       |\n| TEST                   | Boolean | Restricts API calls if `true` for testing. Automatically set by unit tests if tests are ran |\n| APP_PRODUCTION         | Boolean | Limits print outs if `true`                                                                 |\n| APP_PORT               | Integer | Port to start application on                                                                |\n| MONGODB_USER           | String  | Username for MongoDB                                                                        |\n| MONGODB_PASS           | String  | Password for MongoDB                                                                        |\n| MONGODB_DATABASE       | String  | Database for MongoDB                                                                        |\n| MONGO_URI              | String  | URI for MongoDB                                                                             |\n| MONGO_URI_LOCAL        | String  | URI for local MongoDB, necessary for unit testing.                                          |\n| DB_TYPE                | String  | Selects database to use, for mongo enter `MONGO`.                                           |\n| AWS_ACCESS_KEY_ID      | String  | Access key for AWS                                                                          |\n| AWS_SECRET_ACCESS_KEY  | String  | Secret key for AWS                                                                          |\n| AWS_BUCKET             | String  | AWS S3 bucket name                                                                          |\n| ORIENTDB_ROOT_PASSWORD | String  | Root password for OrientDB                                                                  |\n| ORIENTDB_DATABASE      | String  | Database name for OrientDB                                                                  |\n| ORIENTDB_USER          | String  | Username to use for database access for OrientDB                                            |\n| ORIENTDB_PASSWORD      | String  | Password to use for database access for OrientDB                                            |\n| ORIENTDB_PORT          | Integer | Port to use for OrientDB access                                                             |\n\n\nUse docker compose to build and run, this will create a mongo instance if you use the local `docker-compose.yml` file.\nOr the image can be built using `docker build .`, or can be pulled from `openlab/ongoingness-api`.\n\n## Route Structure\n# /\nFull docs for routes are found here.\n\n## Auth\n| Route | Method | Description |\n|-------|--------|-------------|\n| /api/auth/authenticate | POST | Returns a JWT token |\n| /api/auth/register | POST | Register a user |\n| /api/auth/mac | POST | Authenticate with a MAC address |\n\n## Media\n\n| Route | Method | Description |\n|-------|--------|-------------|\n| /api/media/links | POST | Store a link |\n| /api/media/links/:id | GET | Get all links for an item of media |\n| /api/media/:id | GET | Get an image from the server. To get an image you must pass your access token as a url query `token=\u003cYOUR_TOKEN\u003e`. You can also pass a `size` query to specify the image size, between `1024` and `100` pixels. |\n\n## Generic Resources\nIf `x` is the generic resource, then the following routes apply. Routes are in the plural form of the word.\nFor example a resource such as `device` would be `/api/devices/`.\nMedia also has these, and the above routes are added on.\n\n| Route | Method | Description |\n|-------|--------|-------------|\n| /api/x/ | GET | Get all instances of `x`, if `x` is owned resource then it will return all the instances belonging to the user |\n| /api/x/ | POST | Will store a record of `x`|\n| /api/x/:id | POST | Will update a record of `x` |\n| /api/x/:id | DELETE | Will delete `x` |\n| /api/x/:id | GET | Will return an instance of `x` |\n| /api/x/search/:field/:term | GET | Will return all instances where a field of `x` contains the term |\n| /api/x?y=z | GET | Will return all instances of `x` where the field `y` exactly matches `z`. Multiple terms can be applied |\n| /api/get/:page/:limit | GET | Will return a subset of `x` for pagination |\n| /api/media/links/:id | GET | Get all links for an item of media |\n\n## Testing\nMake sure the necessary env parameters for testing are supplied. These are outlined above. Testing is done\nwithin the docker container, to give access to a dockerised MongoDB. First enter the container, then run:\n```bash\nnpm test\n```\n\n## Project Structure\n### services/\nThese service files are used to deploy the project without Docker, setting the API and database up as a \nsystem service.\n\n### static/\nDestination for autogenerated API docs.\n\n### test/\nHouses unit tests\n\n### web/\nCore logic for the API.\n\n#### web/controllers/\nControllers to handle logic associated with resources, do not query or manipulate stored resources.\n\n#### web/middleware/\nMiddleware for the API. Handles checking JWT tokens, user roles, error handling etc.\n\n#### web/repositories/\nRepositories for manipulating and querying stored resources. Custom implementations can be written for different\ndatastores, see `MongoResourceRepository` as an example. Repositories must implement `IResourceRepository`.\n\n#### web/routes/\nRouters for API. For resources the route should be outlined in `RouterSchema`, which will auto generate endpoints\nfor `CRUD` for that resource. Custom routers can be added but must implement `IResourceRouter` if they are a \nresource, see `MediaRouter` as an example, and all should extend `BaseRouter`.\n\n#### web/schemas/\nUsed to model resources for Mongo. Should all implement `IBaseMongoResource`. For different data structures a\nnew data source dependant data structure should be written, and `repositories/RepositoryFactory.ts` should be\nextended to use the new interface.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalinteraction%2Fongoingness-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalinteraction%2Fongoingness-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalinteraction%2Fongoingness-api/lists"}