项目作者: Faroukelkholy

项目描述 :
POC of hexagonal Architecture including a rest adapter and graphql adapter.
高级语言: TypeScript
项目地址: git://github.com/Faroukelkholy/device-service.git
创建时间: 2020-07-17T12:30:56Z
项目社区:https://github.com/Faroukelkholy/device-service

开源协议:

下载


device_management

Table of contents

Documentation

  • Component Diagram

    Component_Daigram

Technologies

Project is created with:

  • Typescript
  • Node
  • Express
  • Express-graphql
  • Graphql
  • Mongo
  • Docker
  • Jest

Deployment

Note: The app will start with a seeder.

  1. $ docker-compose up -d

Examples

Service will be up and running on port 8070:

  • Rest Endpoints
  1. $ curl http://localhost:8070/devices
  2. $ curl http://localhost:8070/devices/99b297dd-cb11-4513-b3b2-f798af12a83f
  3. $ curl -d '{"name": "curlTest","firmwareRevision": "0.1.0","firmwareVersion": "1.1.0"}' -H "Content-Type: application/json" -X POST http://localhost:8070/devices
  • Graphql playground examples

Navigate to localhost:8070/graphql, Start to play around with these examples

  1. #####Introspection Example
  2. {
  3. #Introspection all types available on the graph server, step1
  4. __schema {
  5. types {
  6. name
  7. }
  8. }
  9. #Introspection Device type, its description and fields, step2
  10. __type(name: "Device") {
  11. name
  12. description
  13. kind
  14. fields {
  15. name
  16. type {
  17. name
  18. kind
  19. }
  20. }
  21. }
  22. }
  23. ####
  24. #####Query Example
  25. {
  26. devices {
  27. deviceId
  28. name
  29. }
  30. device(deviceId: "a3eedb89-a923-4041-8f49-7e80d541486e") {
  31. name
  32. }
  33. # Trying out alias
  34. deviceDifferent: device(deviceId: "85214138-eb63-48e0-9d5e-75335433e6de") {
  35. name
  36. # Trying out fragment
  37. ...versionFields
  38. }
  39. }
  40. #defining fragment on Device type
  41. fragment versionFields on Device {
  42. firmwareVersion
  43. firmwareRevision
  44. }
  45. ####
  46. ###Mutation example
  47. mutation CreateDeviceMutation($device:CreateDeviceInput) {
  48. createDevice(device:$device){
  49. name
  50. }
  51. }
  52. #Variable
  53. {
  54. "device": {
  55. "name": "graphql test",
  56. "firmwareRevision": "1.0.0",
  57. "firmwareVersion": "1.0.0"
  58. }
  59. }
  60. ####

Testing

1.first get a bash shell in the container
2.excute the test cases

  1. $ docker-compose exec device bash
  2. $ npm test