From 300eb752b85263194aeeee61c7c3d1ef971148f2 Mon Sep 17 00:00:00 2001 From: Shub1427 Date: Sun, 14 Apr 2019 14:03:25 +0530 Subject: [PATCH] feat: support npm scripts and OPTIONS redirect for mockserver --- Readme.md | 5 +++-- mocks/goals/OPTIONS.mock | 9 +++++++++ package.json | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 mocks/goals/OPTIONS.mock diff --git a/Readme.md b/Readme.md index dba39a6..68ede3e 100644 --- a/Readme.md +++ b/Readme.md @@ -3,7 +3,7 @@ - Install node and npm (in case if you haven't). - Open terminal and navigate to the folder and execute below commands. - `npm install` -- `mockserver -p 9000 -m mocks` +- `npx mockserver -p 9000 -m mocks` OR `npm start 9000` - That should start a mock server and should show as below. - Mockserver serving mocks {verbose:true} under `mocks` at `http://localhost:9000` - change the port number in case if you are using `9000` for anything else. @@ -11,5 +11,6 @@ # Now you can do following API calls: - GET - `http://localhost:9000/goals` - gets all the goals +- OPTIONS - `http://localhost:9000/goals` - verifies the request by redirect. - POST - `http://localhost:9000/goals` - creates a goal -- DELETE - `http://localhost:9000/goals` - deletes a goal \ No newline at end of file +- DELETE - `http://localhost:9000/goals` - deletes a goal diff --git a/mocks/goals/OPTIONS.mock b/mocks/goals/OPTIONS.mock new file mode 100644 index 0000000..49909ab --- /dev/null +++ b/mocks/goals/OPTIONS.mock @@ -0,0 +1,9 @@ +HTTP/1.1 200 OK +content-encoding: gzip +transfer-encoding: chunked +access-control-allow-origin: * +access-control-allow-credentials: true +strict-transport-security: max-age=31536000; includeSubDomains +access-control-max-age: 3600 +access-control-allow-headers: expires,origin,language,pragma,accept,last-modified,x-xsrf-token,x-requested-with,content-type,location,cache-control,content-language +access-control-allow-methods: POST, DELETE diff --git a/package.json b/package.json index 623c842..567ab9b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "mockable APIs", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "start": "mockserver -m mocks -p " }, "keywords": [ "mocker",