{"id":18995279,"url":"https://github.com/aadamsx/meteor-web-app-test","last_synced_at":"2026-05-12T23:33:37.220Z","repository":{"id":73137117,"uuid":"97166447","full_name":"aadamsx/meteor-web-app-test","owner":"aadamsx","description":"fine-rest example in Meteor","archived":false,"fork":false,"pushed_at":"2017-07-28T17:44:36.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T11:57:13.545Z","etag":null,"topics":["example","javascript","meteor","web-api","web-app"],"latest_commit_sha":null,"homepage":"https://github.com/aadamsx/fine-rest","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/aadamsx.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-13T21:30:28.000Z","updated_at":"2017-07-28T03:26:18.000Z","dependencies_parsed_at":"2023-02-23T18:00:12.229Z","dependency_job_id":null,"html_url":"https://github.com/aadamsx/meteor-web-app-test","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/aadamsx/meteor-web-app-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aadamsx%2Fmeteor-web-app-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aadamsx%2Fmeteor-web-app-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aadamsx%2Fmeteor-web-app-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aadamsx%2Fmeteor-web-app-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aadamsx","download_url":"https://codeload.github.com/aadamsx/meteor-web-app-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aadamsx%2Fmeteor-web-app-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32961784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"ssl_error","status_checked_at":"2026-05-12T23:30:18.191Z","response_time":102,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["example","javascript","meteor","web-api","web-app"],"created_at":"2024-11-08T17:29:51.123Z","updated_at":"2026-05-12T23:33:37.203Z","avatar_url":"https://github.com/aadamsx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meteor Web API Examples using [fine-rest](https://github.com/aadamsx/fine-rest)\n\n## TOC:\n\n### [Getting started](#getting-started-1)\n\n### [Create Bearer Token](#create-bearer-token-1)\n### [Debugging Web API](#debugging-web-api-1)\n\n### [Issues](#issues-1)\n### [Outstanding](#outstanding-1)\n### [Ideas Sandbox](#ideas-sandbox-1)\n### [Change Log](#change-log-1)\n\n.\n\n## Getting started:\n\n#### 1) Open a shell session and get the test app:\n\n```bash\n$ git clone https://github.com/aadamsx/meteor-web-app-test.git\n```\n\nTwo different projects, one Web API and one the Client to the Web API.\n\n\n#### 2) Now cd into the web-api-user directory and run npm install:\n\n```bash\n$ cd /web-api-uer\n$ meteor npm install --save\n```\n\n#### 3) Now cd into the web-api \u0026 web-api/fine-rest directories and run npm install:\n\n```bash\n$ cd /web-api\n$ meteor npm install --save\n$ cd /web-api/fine-rest  \n$ meteor npm install --save\n```\n\n#### 4) Open two shell sessions and run the npm command below to start:\n\n\n#### For the Web API:\n\n```bash\n$ cd /web-api\n$ npm run web-app-test\n```\n\nBy default the Web API will run on ```--port 4500```\n\n#### For the Web API Client:\n\n```bash\n$ cd /web-api-user\n$ npm run web-app-test\n```\n\nBy default the Web API client will run on ```--port 3101```\n\n#### 5) To test the Web API is running:\n\n```bash\ncurl -X POST \\\n  http://localhost:4500/test-route \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json'\n```\n\nSecurity checks are NOT implemented for the above route, so you will not have to call out to the API ```/users/login``` first.  For routes under ```/api``` you must first get a valid token. An example is provided under [Create Bearer Token](#create-bearer-token-1).  Options for database are ```database_1``` or ```database_2``` defined in the ```settings.json``` file.\n\n\n## Create Bearer Token:\n\n\nIn order to check the fine-rest lib will return a Bearer token you must do the following:\n\n#### 1) Stand up a MongoDB local service @ localhost:27017/web-api-2\n\nNote: The default database is simpley ```web-api```, yet when calling a route under ```/api/```, specifically ```/api/test-route2``` you must specify either ```database_1``` corresponding to web-api-1 or ```database_2``` corresponding to web-api-2.\n\n#### 2) Create users in this database with the Meteor [accounts-password](https://docs.meteor.com/api/passwords.html) package.\n#### 3) Pass in the username and password from one of these users into the Web API like so:\n\n```bash\ncurl -X POST \\\n  http://localhost:4500/users/login \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d 'email=test@test.com\u0026password=12345'\n```\n\nA NEW option is to log in with a temp token:\n\n```bash\ncurl -X POST \\\n  http://localhost:4500/users/token-login \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d 'dbId=database_1\u0026loginToken=123'\n\n```\nFor this option only the temporary login token is required, the databaseId is optional and requires a database URL in the settings.json file (please see the code for more details).\n\n\nYou should get a response:\n\n```bash\n{\n    \"id\": \"456\",\n    \"token\": \"123\",\n    \"tokenExpires\": \"2017-10-19T04:10:18.644Z\"\n}\n```\n\nThis token is your Bearer token that you have to use for all subsequent Web API calls.\n.\n\n## Debugging Web API:\n\n#### 1) Make sure before running this command you have attached debugger; comments where you want to \"hook\" into your code, for example:\n\n```javascript\nJsonRoutes.add('POST', '/test-route/', function(req, res, next) {\n  debugger; // =\u003e the server will pause for debugging if the 'test-route' is called!\n  JsonRoutes.sendResult(res, {\n    code: 200,\n    data: {\n      result: \"OK\"\n    }\n  });\n});\n```\n\n#### 2) To debug the server side Web API you must specify the debug port and start Meteor like so:\n\n```\nMONGO_URL=mongodb://localhost:27017/meteor meteor --debug-port 3200 --port 3100 --settings settings.json\n```\n\nNote: by default running ```npm web-app-test``` will run with debug turned on.\n\n#### 3) After running this command you must go to the following URL in order to attach to the server process:\n\n```\nhttp://localhost:5422/?port=3200\n```\n\n#### 4) Now call the route again with curl and start debugging the server side Web API:\n\n```bash\ncurl -X POST \\\n  http://localhost:3100/api/test-route2 \\\n  -H 'authorization: Bearer 123' \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d 'userId=456\u0026dbId=database_2'\n```\n\nNote: For this route, security is on, this means the ```Bearer token``` must be valid (in the user's collection record), the ```userId``` must be valid (again in the user's collection record) for the ```databaseId``` passed in, either ```database_1``` or ```database_2```.\n\n.\n\n## Issues:\n\n- [x] Could not get middleware to run on exceptions.\n- [x] Could not add a code to sendResult() without the requestor (web-api-user project) hanging.\n\n.\n\n## Outstanding:\n\n- [x] Engineer the auto retrieval of the Bearer token from the Web API.\n- [x] Engineer the storage of Bearer token in order for client to use the Web API.\n  - [x] MongoDB storage of Bearer token.\n- [x] Middleware that only runs for a particular route.\n- [x] Ability to retrieve data from multiple databases.\n- [x] Added login token ability (instead of user name and password).\n- [x] Get CORS working.\n  - [ ] CORS working for specific domains.\n- [ ] Add a check for user Roles to see if they have permission on an endpoint.\n- [ ] Add rate limiter to avoid request overload.\n- [ ] React Native client to Web API?\n- [ ] Logging in middleware for all requests.\n- [ ] Consider removing Meteor Accounts dependency\n- [ ] Add \"Web Hooks\" on the client to get response status from long-running service.\n- [ ] Singleton and Concurrency concepts:\n  - [ ] Singleton: One connection to a database = one module = one class within that module, must all be unique per HTTP request (cannot have one request, stepping on another, by overwriting the next).\n  - [ ] Concurrency: Web App must be able to handle concurrent HTTP requests reading from and writing to a database.\n\n.\n\n## Ideas Sandbox:\n\n\n#### Looking at Web Hooks:\n\n- We could send an immediate response to the user with the URL to the file and set a flag inside the \"shared\" database with the status of the operation.\n- But the issue is we'd still have to periodically check the status.  I think Web Hooks on the Web API allow you to get alerted when the status changes?\n\n- I think as it stands, the code is synchronous and thus does not require me to use webhooks?\n\n\n.\n\n## Change log:\n\n#### 0.2.0\n\n- fine-rest in this example has been updated with the option to log in with a token.  The new route is named ```/users/token-login``` and has the option to pass in a database ID for multi-database use.  I will update the NPM version of fine-rest to reflect this changes at some point soon.\n- The example ```web-api-user``` client application now checks for a Bearer token server side inside a MongoDB collection named ```Globals``` -- if its there it uses it for Web API calls, if not it goes and gets a new one from the Web API.\n\n\n#### 0.1.1\n\n-  The Meteor Web API now talks to (3) MongoDBs. The first DB named ```web-api``` is the default for the Web API.  The second and third DBs options are stored in the ```settings.json``` file.\n-  Added requirement to pass in databaseId.  There are two databases to choose from, web-api-1 and web-api-2.\n-  Added imports directory where the People class and Mono collections are defined.\n-  Added new ```/api/test-route2```.\n-  All security checks are not under the new ```/api``` route.\n\n#### 0.1.0\n\n- Temporarily added [fine-rest](https://github.com/aadamsx/fine-rest) package locally to the web-api project for debugging purposes.\n\n#### 0.0.1 - 0.0.8\n\n- Worked on [Original issues](#original-issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faadamsx%2Fmeteor-web-app-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faadamsx%2Fmeteor-web-app-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faadamsx%2Fmeteor-web-app-test/lists"}