项目作者: psykzz

项目描述 :
A basic status api to track the status of things, via your API.
高级语言: JavaScript
项目地址: git://github.com/psykzz/status-api.git
创建时间: 2017-08-11T23:13:44Z
项目社区:https://github.com/psykzz/status-api

开源协议:

下载


Status API

A basic status api to track the status of things, via your API.

Run with docker-compose up.

Docker

A docker image is automatically built at https://hub.docker.com/r/psykzz/status-api.

Tests

No tests currently.

Examples

-> GET /api/v1/status

Shows all statuses

Response

  1. {
  2. "status": "ok",
  3. "response": [
  4. {
  5. "_id": "598dfe0e147a53001628364f",
  6. "name": "test-percent",
  7. "type": "percent",
  8. "last_update": {
  9. "_id": "598e2ebf3b408800161f6959",
  10. "status": {
  11. "percent": "75"
  12. },
  13. "created": "2017-08-11T22:25:03.984Z"
  14. },
  15. "updated": "2017-08-11T18:57:18.678Z"
  16. },
  17. {
  18. "_id": "598e1c90858ea5001674decb",
  19. "name": "test-percent2",
  20. "type": "percent",
  21. "updated": "2017-08-11T21:07:28.246Z"
  22. }
  23. ]
  24. }

-> POST /api/v1/status

Add a new status

Request

  1. {
  2. "name": "my-new-status",
  3. "type": "percent"
  4. }

Response

  1. {
  2. "status": "ok",
  3. "response": {
  4. "__v": 0,
  5. "name": "my-new-status",
  6. "type": "percent",
  7. "_id": "598e3b672ccaed001626f834",
  8. "history": [],
  9. "updated": "2017-08-11T23:19:03.099Z"
  10. }
  11. }

-> GET /api/v1/status/:statusName

Shows all status details for :statusName

Response

  1. {
  2. "status": "ok",
  3. "response": {
  4. "_id": "598e3bf52ccaed001626f835",
  5. "name": "my-new-status",
  6. "type": "percent",
  7. "last_update": {
  8. "_id": "598e3c1a2ccaed001626f83b",
  9. "status": {
  10. "percent": 100
  11. },
  12. "created": "2017-08-11T23:22:02.036Z"
  13. },
  14. "history": [
  15. {
  16. "_id": "598e3c1a2ccaed001626f83b",
  17. "status": {
  18. "percent": 100
  19. },
  20. "created": "2017-08-11T23:22:02.036Z"
  21. },
  22. {
  23. "_id": "598e3c172ccaed001626f83a",
  24. "status": {
  25. "percent": 55
  26. },
  27. "created": "2017-08-11T23:21:59.101Z"
  28. },
  29. {
  30. "_id": "598e3c142ccaed001626f839",
  31. "status": {
  32. "percent": 15
  33. },
  34. "created": "2017-08-11T23:21:56.518Z"
  35. },
  36. {
  37. "_id": "598e3c122ccaed001626f838",
  38. "status": {
  39. "percent": 5
  40. },
  41. "created": "2017-08-11T23:21:54.345Z"
  42. },
  43. {
  44. "_id": "598e3c0d2ccaed001626f837",
  45. "status": {
  46. "percent": 2
  47. },
  48. "created": "2017-08-11T23:21:49.457Z"
  49. }
  50. ],
  51. "updated": "2017-08-11T23:21:25.499Z"
  52. }
  53. }

-> POST /api/v1/status/:statusName

Add a new status history for :statusName

Request

  1. {
  2. "percent": 100
  3. }

Response

  1. {
  2. "status": "ok",
  3. "response": {
  4. "__v": 0,
  5. "status": {
  6. "percent": 100
  7. },
  8. "parent": {
  9. "_id": "598e3bf52ccaed001626f835",
  10. "name": "my-new-status",
  11. "type": "percent",
  12. "updated": "2017-08-11T23:21:25.499Z"
  13. },
  14. "_id": "598e3c382ccaed001626f83c",
  15. "created": "2017-08-11T23:22:32.490Z"
  16. }
  17. }

-> DELETE /api/v1/status/:statusName

Remove the status :statusName

Response

  1. {
  2. "status": "ok",
  3. "response": null
  4. }

-> GET /api/v1/status/:statusName/history

Show all history for :statusName

Request

  1. {
  2. "status": "ok",
  3. "response": {
  4. "_id": "598e3bf52ccaed001626f835",
  5. "name": "my-new-status",
  6. "type": "percent",
  7. "history": [
  8. {
  9. "_id": "598e3c382ccaed001626f83c",
  10. "status": {
  11. "percent": 100
  12. },
  13. "created": "2017-08-11T23:22:32.490Z"
  14. },
  15. {
  16. "_id": "598e3c1a2ccaed001626f83b",
  17. "status": {
  18. "percent": 100
  19. },
  20. "created": "2017-08-11T23:22:02.036Z"
  21. },
  22. {
  23. "_id": "598e3c172ccaed001626f83a",
  24. "status": {
  25. "percent": 55
  26. },
  27. "created": "2017-08-11T23:21:59.101Z"
  28. },
  29. {
  30. "_id": "598e3c142ccaed001626f839",
  31. "status": {
  32. "percent": 15
  33. },
  34. "created": "2017-08-11T23:21:56.518Z"
  35. },
  36. {
  37. "_id": "598e3c122ccaed001626f838",
  38. "status": {
  39. "percent": 5
  40. },
  41. "created": "2017-08-11T23:21:54.345Z"
  42. },
  43. {
  44. "_id": "598e3c0d2ccaed001626f837",
  45. "status": {
  46. "percent": 2
  47. },
  48. "created": "2017-08-11T23:21:49.457Z"
  49. },
  50. {
  51. "_id": "598e3c0a2ccaed001626f836",
  52. "status": {
  53. "percent": 1
  54. },
  55. "created": "2017-08-11T23:21:46.798Z"
  56. }
  57. ],
  58. "updated": "2017-08-11T23:21:25.499Z"
  59. }
  60. }

Response

  1. {
  2. "status": "ok",
  3. "response": {
  4. "__v": 0,
  5. "name": "signup-api-deploy",
  6. "type": "percent",
  7. "_id": "598e3b672ccaed001626f834",
  8. "history": [],
  9. "updated": "2017-08-11T23:19:03.099Z"
  10. }
  11. }