{"id":29639165,"url":"https://github.com/neotomadb/api_nodetest","last_synced_at":"2025-07-21T20:08:22.896Z","repository":{"id":17009891,"uuid":"91914528","full_name":"NeotomaDB/api_nodetest","owner":"NeotomaDB","description":"node.js and express implementation for the Neotoma API","archived":false,"fork":false,"pushed_at":"2025-07-12T09:00:10.000Z","size":9097,"stargazers_count":2,"open_issues_count":37,"forks_count":0,"subscribers_count":5,"default_branch":"production","last_synced_at":"2025-07-12T11:25:23.348Z","etag":null,"topics":["api","express","neotoma","neotoma-api","neotoma-database","nodejs","paleoecology","swagger"],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/NeotomaDB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-20T20:26:29.000Z","updated_at":"2025-07-04T20:16:35.000Z","dependencies_parsed_at":"2023-02-13T21:45:28.331Z","dependency_job_id":"174565a8-2fc8-4a28-bb20-1d87409c2087","html_url":"https://github.com/NeotomaDB/api_nodetest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/NeotomaDB/api_nodetest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeotomaDB%2Fapi_nodetest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeotomaDB%2Fapi_nodetest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeotomaDB%2Fapi_nodetest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeotomaDB%2Fapi_nodetest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NeotomaDB","download_url":"https://codeload.github.com/NeotomaDB/api_nodetest/tar.gz/refs/heads/production","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeotomaDB%2Fapi_nodetest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266371486,"owners_count":23918862,"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-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["api","express","neotoma","neotoma-api","neotoma-database","nodejs","paleoecology","swagger"],"created_at":"2025-07-21T20:08:18.455Z","updated_at":"2025-07-21T20:08:22.887Z","avatar_url":"https://github.com/NeotomaDB.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9788/badge)](https://www.bestpractices.dev/projects/9788)\n[![lifecycle](https://img.shields.io/badge/lifecycle-active-orange.svg)] [![DOI](https://zenodo.org/badge/91914528.svg)](https://zenodo.org/badge/latestdoi/91914528)\n\n[![NSF-1550707](https://img.shields.io/badge/NSF-1550707-blue.svg)](https://nsf.gov/awardsearch/showAward?AWD_ID=1550707) [![NSF-1541002](https://img.shields.io/badge/NSF-1541002-blue.svg)](https://nsf.gov/awardsearch/showAward?AWD_ID=1541002)\n\n# Neotoma API Implementation\n\nThis repository is intended to act as the core repository for the Neotoma API version 1.5 and greater.  There are two main branches, `master` and `dev`.  Master is intended as the production branch, while `dev` is the main testing and development branch.  For documentation of the Neotoma Paleoecology Database see [this](http://neotoma-manual.readthedocs.io/en/latest/neotoma_introduction.html) and of the community see [this](https://www.neotomadb.org/).  Version 1 of the API is documented [here](http://wnapi.neotomadb.org/doc/home).\n\nCurrently [https://api.neotomadb.org](https://api.neotomadb.org) is the home for the API, and will resolve to a [OpenAPI](http://swagger.io) landing page with API documentation and search functionality. The documentation is generated dynamically from the [openapi.json]() yaml file using the OpenAPI standard.\n\nTests for the API are implemented using mocha/chakram and also make use of `oatts`, which generates tests directly from the `swagger.json` documentation.  To autogenerate the test suite, we use the bash script `genoatt.sh`, which provides base-level implementation of the `oatts` module, along with some fixes to modify values in the testing suite to ensure consistency with the API.  Once the tests have been generated we use `runmochabatch.sh` which tests each module and returns an HTML file (placed in the `public/` folder) that can be used to examine individual structural errors in the API (or documentation).\n\n## Development\n\n* [Simon Goring](http://goring.org): University of Wisconsin - Madison [![orcid](https://img.shields.io/badge/orcid-0000--0002--2700--4605-brightgreen.svg)](https://orcid.org/0000-0002-2700-4605)\n* Mike Stryker: Pennsylvania State University\n\n## Contribution\n\nWe welcome user contributions to this project.  All contributors are expected to follow the [code of conduct](https://github.com/Neotomadb/api_nodetest/blob/master/code_of_conduct.md).  Contributors should fork this project and make a pull request indicating the nature of the changes and the intended utility.  Further information for this workflow can be found on the GitHub [Pull Request Tutorial webpage](https://help.github.com/articles/about-pull-requests/).\n\n## Description\n\nThis codebase is generated using `node.js`, `express` and `pg-promise` to interact with the Neotoma `postgres` database. The API endpoints are organized conceptually by applications (apps), data, and direct access to specific tables (dbtables). This project is based on and replaces an existing API implemented with .NET and SQLServer.\n\nThis code is currently in preliminary release.\n\n### Required Files/Services\n\n#### Database Snapshot\n\nThe code in this repository is run directly against the production database on the Neotoma servers at the Center for Environmental Informatics at Penn State.  It is possible to run this repository on a local server (on your own machine) or on a remote server (using cloud services or a university server) by installing Postgres and restoring one of the [Neotoma Database Snapshots](https://www.neotomadb.org/snapshots).  If you are planning to run the application in this way, please ensure that you have set appropriate security measures, and have these documented in the `db_connect.json` file, as described below.\n\n#### Connection File\n\nAlong with the files in this repository a user will need a file called `db_connect.json`, to be located in the database directory.\n\n```json\n{\n   \"host\": \"localhost\",\n   \"port\": 5432,\n   \"database\": \"YOUR_DATABASE_NAME\",\n   \"user\": \"postgres\",\n   \"password\": \"postgres\"\n}\n```\n\nFor security reasons this file is not included in the GitHub repository, but can be made available.\n\n### To Run\n\nTo start the server locally you must first clone the repository.  Once the repository is cloned you must use the `npm` package installer to download the required packages.  The required packages are listed in `package.json`.  You can use the command `npm install` to install the packages locally.\n\nOnce the directory is set up and the packages have been installed, use `npm start` to start the server locally.  This will create a local server, serving data to `localhost:3000`.\n\n```\n$ npm start\n\n\u003e api-nodetest@0.0.0 start /home/simon/Documents/GitHub/api_nodetest\n\u003e node ./bin/www\n\n```\n\n#### Testing\n\nThe API uses `mocha` as a test package.  Tests are located in the [test folder](https://github.com/NeotomaDB/api_nodetest/tree/master/test) and can be run using `mocha test` from the command line once the server is running:\n\n```\n$ mocha test\n\n Get taxon data:\n    ✓ An empty query redirects to the api documentation.\n    ✓ A single taxon should be returned by id: (80ms)\n    ✓ Taxon queries should be case insensitive: (120ms)\n```\n\n### Adding or Editing an API Endpoint\n\nThe current API reflects the needs of certain users who have directly communicated their needs to the development team.  Future users, or groups may wish to support services from Neotoma that are currently not implemented.  Adding a new service to the API should be done in a new fork of the repository, and includes the following steps:\n\n#### Create a `helpers` folder\n\nYour new service, for example `example`, will have its own folder in the `[helpers](https://github.com/NeotomaDB/api_nodetest/tree/master/v2.0/helpers)` folder.  This is to ensure that all the resources are kept well organized in one place.  In general that folder will contain a `js` file (`example.js`) and a SQL file, that will directly query the database (`example.sql`).\n\nIf the query is very simple (a simple `SELECT * FROM xxx.xxxxx` query), it is possible to use only a `js` file, as in `[helpers/frozen/frozen.js](https://github.com/NeotomaDB/api_nodetest/blob/master/v2.0/helpers/frozendata/frozen.js#L9)`.\n\nThe existing files and folders in the `helpers` directory can easily be used as a template for new API endpoints.  Feel free to make changes to the code.  In particular, if there are new endpoints required, or changes in the way data are returned or documentation is provided, please let us know, or contribute directly.\n\nOnce the desired SQL query is written and the `js` file to access it from nod/express is implemented we then need to edit the file that handles requests to the `data` route.  We can find this file in `[v2.0/handlers/data_handlers.js](https://github.com/NeotomaDB/api_nodetest/blob/master/v2.0/handlers/data_handlers.js)`.  You are defining a function name here, that will be called by the router.\n\nThe router is in `[routes/data.js](https://github.com/NeotomaDB/api_nodetest/blob/master/v2.0/routes/data.js)`. It lets us know what function and parameters are associated with each URL route.  For example, someone calling our API using: `http://api-dev.neotomadb.org/v2.0/data/sites/132/contacts` would be directed to the function defined in the `handler.js` file called `contactsbysiteid`, since our routing file includes the call: `[router.get('/sites/:siteid/contacts', handlers.contactsbysiteid);](https://github.com/NeotomaDB/api_nodetest/blob/master/v2.0/routes/data.js#L20)`.  We also know that within the `contactsbysiteid()` function (in `helpers/contacts`) there would be a parameter called `siteid`\n\n## Funding\n\nThis work is funded by NSF grants to Neotoma: NSF Geoinformatics - [1550707](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1550707\u0026HistoricalAwards=false)/[1948926](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1948926\u0026HistoricalAwards=false) and NSF EarthCube [1541002](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1541002\u0026HistoricalAwards=false).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneotomadb%2Fapi_nodetest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneotomadb%2Fapi_nodetest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneotomadb%2Fapi_nodetest/lists"}