{"id":21393573,"url":"https://github.com/cmwylie19/node-rest-service","last_synced_at":"2026-04-12T03:36:52.778Z","repository":{"id":40764836,"uuid":"271010454","full_name":"cmwylie19/node-rest-service","owner":"cmwylie19","description":"NodeJS Rest Service with TypeScript","archived":false,"fork":false,"pushed_at":"2023-01-24T02:54:58.000Z","size":42812,"stargazers_count":1,"open_issues_count":25,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T14:16:10.584Z","etag":null,"topics":["express","expressjs","javascript","jest","jest-coverage","nodejs","openapi","typescript"],"latest_commit_sha":null,"homepage":"https://cmwylie19.github.io/node-rest-service/","language":"HTML","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/cmwylie19.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":"2020-06-09T13:29:16.000Z","updated_at":"2020-07-01T18:14:28.000Z","dependencies_parsed_at":"2023-02-13T13:45:57.462Z","dependency_job_id":null,"html_url":"https://github.com/cmwylie19/node-rest-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cmwylie19/node-rest-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmwylie19%2Fnode-rest-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmwylie19%2Fnode-rest-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmwylie19%2Fnode-rest-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmwylie19%2Fnode-rest-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmwylie19","download_url":"https://codeload.github.com/cmwylie19/node-rest-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmwylie19%2Fnode-rest-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31703501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T21:17:31.016Z","status":"online","status_checked_at":"2026-04-12T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["express","expressjs","javascript","jest","jest-coverage","nodejs","openapi","typescript"],"created_at":"2024-11-22T14:12:21.665Z","updated_at":"2026-04-12T03:36:52.740Z","avatar_url":"https://github.com/cmwylie19.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Node.js CI](https://github.com/cmwylie19/node-rest-service/workflows/Node.js%20CI/badge.svg)  \n[![codecov](https://codecov.io/gh/cmwylie19/node-rest-service/branch/master/graph/badge.svg)](https://codecov.io/gh/cmwylie19/node-rest-service)\n\n# 360 Enablement\n\nThe purpose of this repo is to demo and describe the use cases around some tooling and libraries in the contract first development space. One of the tools that we are going to analyze, hmt, has the ability to proxy actual backend requests and generate a spec based on the proxy logs, which is why we have a simple backend service written in NodeJS. We will also use the NodeJS service top perform fuzz testing with `unmock`\n\n\n## NodeJS User Service\nA dead simple, well tested,, object-oriented implementation of a webserver that can perform CRUD operations on a `user object`. \n\nSimple rest endpoints\n```\nPOST   /users\nGET    /users\nGET    /users/:email\nPUT    /users/:email\nDELETE /users/:email\n```\n\nThe user object interface\n```\nenum IUser {\n    email: string,\n    name: string,\n    role: string\n}\n```\nInstall the dependencies for the application.\n```\nnpm i \n````\n\nRun the unit tests.\n```\nnpm run test:unit\n```\n![GitHub Logo](tests.png)\n\nRun the application locallu.\n```\nnpm run dev\n```\n\nThe postman collection  is the `ApiMockServer.postman_collection.json` file in the root of the repo, import the collection and run the app to start manipulating users.\n\n\n## fakeit \n[fakeit](https://github.com/JustinFeng/fakeit)\n\nThis OpenAPI mock server built with the motivation to control response generation in a non intrusive manner to support development against a contract. \n\n\n### Installation\n_make sure you are using ruby v2.7.1, if you have rvm use `rvm install 2.7.1` first_\n```\ngem install fakeit\n```\n\n### Features\n- ran return random responses\n- can return object type defs\n- can return example responses\n\nNow would be a good time to import the postman collection into postman and follow along but you can also follow along with `curl`.\n#### Return Type Defs\nWe are going to run faker, supply the --spec argument for the OpenAPI spec file, -p to run the mock server on port 3333 and --static to return static responses\n```\nfakeit --spec openapi.yml -p 3333 --static       \n```\nNow in a different terminal hit the `GET` /users with a curl\n```\ncurl -G http://localhost:3333/users\n```\nand `fakeit` will return the type definition of the `user` object.\n\n```\n{\n    \"name\": \"string\",\n    \"role\": \"string\"\n}\n```\n#### Return Random Reponses\nThe next way we are going to use `fakeit` is to return random responses, start fakeit from the terminal, --spec openapi.yml, -p 3333, --static-types\n```\nfakeit --spec openapi.yml -p 3333 --static-types\n```\nYour mock api server will now return random values of the given type specified in the OpenAPI spec.\n\n```\ncurl -G http://localhost:3333/users\n```\nand `fakeit` will return a random string for name and a random string for role.\n\n```\n{\n    \"name\": \"Things Fall Apart\",\n    \"role\": \"Dulce et Decorum Est\"\n}\n```\n#### Return Example Responses\nIn the event you want fakeit to return the example responses defined in the OpenAPI spec you can specify the `--use-example`\n```\nfakeit --spec openapi.yml -p 3333 --use-example\n```\nIn another terminal\n```\ncurl -G http://localhost:3333/users\n```\nand `fakeit` will return the example specified in the response of the spec\n\n```\n{\n    \"name\": \"Test User\",\n    \"role\": \"Role\"\n}\n```\n\n\n## apisprout\n\nOpenAPI 3 mock server written in golang. apisproute returns _only the example responses defined in the OpenAPI spec_.\n\n### Features\n- health check\n- log req.hostname\n\n### Installation\n_make sure you have golang in your path_\n```\ngo get github.com/danielgtaylor/apisprout\n```\n\n#### Return Example Responses\nStart apisprout mock server listening on port 3333 and return example responses defined in the OpenAPI spec.\n```\n./apisproute -p 3333 openapi.yml\n\n```\nin another terminal \n```\ncurl -G http://localhost:3333/users/test@user.com\n```\nresults in the following response \n```\n{\n    \"name\": \"Test User\",\n    \"role\": \"test\"\n}\n```\n\nnow lets check the health of the mock server, you can expect a 200 response. \n```\ncurl -G http://localhost:3333/users/__health\n```\n\n## openapi-mock \n[openapi-mock github](https://github.com/penx/openapi-mock)\n\nThis tool is another mock server that generates random data. \n\n### Usage\nThis tool does not have any extra features other than serving mock data based on the OAS.\n```\n./openapi-mock --specification-url openapi.yml\n```\nNow in a different terminal hit the `GET` /users with a curl\n```\ncurl -G http://localhost:8000/users\n```\n\n\n## HMT\n\nHttp Mocking Toolkit (HMT). Tool that mocks HTTP APIs for use in sandboxes as well as automated and explatoratory testing. It uses a combo of API definitions, recorded traffic and code in order to make crafting mocks as enjoyable as possible. _Provides a quick way to get up and running from an existing backend_\n\n### Features\n- create mocks of APIs from server traffic and OpenAPI specs.\n\n\n### Installation\n_make sure you have python in your path_\n```\npip install hmt (Python 3.6+)\nOR\nbrew tap meeshkan/tap\nbrew install hmt\n```\n##### Usage\n\n    $ hmt --help\n\n    example:\n    In 3 different terminals\n    terminal 1: $ sudo hmt record\n    terminal 2: $ npm run dev\n    terminal 3: $ wget http://localhost:8000/http://localhost:3333/users/casewylie@gmail.com\n    terminal 3: wget http://localhost:8000/http://localhost:3333/users/cwylie@redhat.com\n\n    $ hmt build logs/localhost\\:3333-recordings.jsonl --mode gen\n    $ sudo hmt mock openapi.yml\n\n## unmock\n\nTesting library for JavaScript. Fuzz test your rest calls. It works similar to the mock api servers that serve random data.\n```\nfuzz test - a form of testing where you verify the correctness of code by asserting that it behaves correctly with variable and unexpected input.\n```\n\n### Features\n- Integrates well with Jest, Mocka, Jasmine, Tap and Ava\n- provides a way to override rest endpoints to provide variable and optional responses in additional to different status codes.\n\n\n\n### Installation\n```\nnpm i --save-dev unmock\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmwylie19%2Fnode-rest-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmwylie19%2Fnode-rest-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmwylie19%2Fnode-rest-service/lists"}