From f64d6d293afb117e11cf704b23daf06651fddfb2 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 2 Nov 2016 08:54:33 -0300 Subject: [PATCH 1/7] running lint before commiting --- package.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/package.json b/package.json index 9f70a3f54..12cb1bfef 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,17 @@ "start": "./server/bin/www", "lint": "eslint ." }, + "config": { + "pre-git": { + "commit-msg": [], + "pre-commit": [ + "npm run lint" + ], + "pre-push": [], + "post-commit": [], + "post-merge": [] + } + }, "repository": { "type": "git", "url": "git+https://github.com/coralproject/talk.git" @@ -27,5 +38,11 @@ "debug": "^2.2.0", "express": "^4.14.0", "mongoose": "^4.6.5" + }, + "devDependencies": { + "chai": "^3.5.0", + "mocha": "^3.1.2", + "pre-git": "^3.10.0", + "supertest": "^2.0.1" } } From ac80d2683dd0dbc5a8bd2b010fab90513ae3e12f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 2 Nov 2016 08:58:31 -0300 Subject: [PATCH 2/7] Adding eslint as devDep --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 12cb1bfef..dbee39dd4 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ }, "devDependencies": { "chai": "^3.5.0", + "eslint": "^3.9.1", "mocha": "^3.1.2", "pre-git": "^3.10.0", "supertest": "^2.0.1" From 61e9e30ac58133638938e172197442b06e8c2ba2 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 2 Nov 2016 09:02:34 -0300 Subject: [PATCH 3/7] Adding test script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index dbee39dd4..333f6b98e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "./server/bin/www", "scripts": { "start": "./server/bin/www", - "lint": "eslint ." + "lint": "eslint .", + "test": "mocha" }, "config": { "pre-git": { From 265be1898d03e21d19ccb1a2a3d8d1003074f63b Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 2 Nov 2016 09:57:18 -0300 Subject: [PATCH 4/7] Adding mock test --- package.json | 7 +++++-- tests/index.js | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/index.js diff --git a/package.json b/package.json index 422caa613..a4b4d603c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "start": "./bin/www", "lint": "eslint .", - "test": "mocha" + "pretest": "npm install", + "test": "mocha tests" }, "config": { "pre-git": { @@ -14,7 +15,9 @@ "pre-commit": [ "npm run lint" ], - "pre-push": [], + "pre-push": [ + "npm test" + ], "post-commit": [], "post-merge": [] } diff --git a/tests/index.js b/tests/index.js new file mode 100644 index 000000000..0a212b7a4 --- /dev/null +++ b/tests/index.js @@ -0,0 +1,12 @@ +/* eslint-env node, mocha */ +'use strict'; + +const expect = require('chai').expect; + +describe('Comment', () => { + describe.only('#add', () => { + it('should add a comment', () => { + expect(0).to.be.equal(0); + }); + }); +}); From f0f6963aa5618be26c4ea3757b57c207d4ca2500 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 2 Nov 2016 14:09:10 -0600 Subject: [PATCH 5/7] add more rules to eslint file --- .eslintrc.json | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index a28ebd512..f92aa27b1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,6 +23,29 @@ "semi": [ "error", "always" - ] + ], + "no-template-curly-in-string": [1], + "no-unsafe-negation": [1], + "array-callback-return": [1], + "eqeqeq": [2], + "no-eval": [2], + "no-global-assign": [2], + "no-implied-eval": [2], + "no-script-url": [2], + "no-throw-literal": [2], + "yoda": [1], + "no-path-concat": [2], + "no-process-exit": [2], + "camelcase": [1], + "eol-last": [1], + "no-continue": [1], + "no-nested-ternary": [1], + "no-tabs": [2], + "no-unneeded-ternary": [1], + "object-curly-spacing": [1], + "space-infix-ops": ["error"], + "no-const-assign": [2], + "no-duplicate-imports": [2], + "prefer-template": [1] } } From 98bf6e48b18de010593c7ee5bad39d7fbe26d108 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 2 Nov 2016 17:34:06 -0300 Subject: [PATCH 6/7] first draft swagger --- swagger.yaml | 195 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 179 insertions(+), 16 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 3c154c6f7..4685a4774 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -11,35 +11,198 @@ produces: - application/json paths: /comments: - get: - summary: Comment Types - description: | - This endpoint retrieves comments + # get: + # tags: + # - Comments + # produces: + # - application/json + # summary: Comment Types + # description: | + # This endpoint retrieves comments + # parameters: + # - name: id + # in: query + # description: Comment by id + # required: false + # type: string + # responses: + # 200: + # description: An array of comments + # schema: + # type: array + # items: + # $ref: '#/definitions/Comment' + post: + description: Add a new comment parameters: - - name: id - in: query - description: Comment by id - required: false - type: string - tags: - - Products + - name: body + in: body + description: Body + required: true + schema: + $ref: '#/definitions/Comment' responses: 200: - description: An array of comments + description: "OK: Comment Added" + 500: + description: "Error" + /comments/{comment_id}/actions: + post: + tags: + - Comments + description: Add a action + parameters: + - name: comment_id + in: path + description: Comment ID + required: true + type: string + - name: body + in: body + description: comment + required: true + schema: + $ref: '#/definitions/Action' + responses: + 200: + description: Action Added schema: type: array items: $ref: '#/definitions/Comment' + /comments/{comment_id}/status: + post: + tags: + - Comments + description: Add a new status + parameters: + - name: comment_id + in: path + description: Comment ID + required: true + type: string + - name: body + in: body + description: comment + required: true + schema: + $ref: '#/definitions/ModerationAction' + responses: + 200: + description: ModerationAction Added + schema: + type: array + items: + $ref: '#/definitions/ModerationAction' + /queue: + get: + tags: + - Queue + description: Queue + parameters: + - name: type + in: query + description: + "pending: no status | flagged: flagged action + no status | rejected: rejected status" + required: true + type: string + - name: limit + in: query + description: Queue limit + required: false + type: integer + - name: skip + in: query + description: Skip + required: false + type: integer + responses: + 200: + description: ModerationAction Added + schema: + type: array + items: + $ref: '#/definitions/ModerationAction' + /stream: + get: + tags: + - Stream + description: Stream + parameters: + - name: asset_id + in: query + description: Description + required: true + type: string + responses: + 200: + description: OK + schema: + type: array + items: + $ref: '#/definitions/Item' + /settings: + get: + tags: + - Settings + description: Settings + responses: + 200: + description: OK + put: + tags: + - Settings + description: Settings + responses: + 200: + description: OK + + + definitions: + Item: + type: string + ModerationAction: + type: string Comment: type: object properties: id: type: string description: Unique identifier - description: + body: type: string - description: Description of comment. - display_name: + description: Description of comment + created_at: + type: string + format: date-time + description: Display name of comment + user_id: + type: string + description: Display name of comment + parent_id: + type: string + description: Display name of comment + asset_id: + type: string + description: Display name of comment + # Actions: + # type: object + # properties: + # item_id: + # type: string + # item_type: + # type: string # comment, user... + # type: + # type: string # flagged, likes, upvotes... + # count: + # type: integer + # current_user: + # type: boolean + Action: + type: object + properties: + type: + type: string + user_id: type: string - description: Display name of comment. From 6310fea2a5d1429b868cb15ba1a87826d82fc73f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 2 Nov 2016 18:09:57 -0300 Subject: [PATCH 7/7] changes --- swagger.yaml | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 4685a4774..a7fdc973d 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -42,8 +42,10 @@ paths: schema: $ref: '#/definitions/Comment' responses: - 200: + 201: description: "OK: Comment Added" + schema: + $ref: '#/definitions/Comment' 500: description: "Error" /comments/{comment_id}/actions: @@ -64,7 +66,7 @@ paths: schema: $ref: '#/definitions/Action' responses: - 200: + 201: description: Action Added schema: type: array @@ -88,12 +90,8 @@ paths: schema: $ref: '#/definitions/ModerationAction' responses: - 200: + 204: description: ModerationAction Added - schema: - type: array - items: - $ref: '#/definitions/ModerationAction' /queue: get: tags: @@ -106,6 +104,10 @@ paths: "pending: no status | flagged: flagged action + no status | rejected: rejected status" required: true type: string + enum: + - pending + - flagged + - rejected - name: limit in: query description: Queue limit @@ -154,14 +156,14 @@ paths: - Settings description: Settings responses: - 200: + 204: description: OK definitions: Item: - type: string + type: object ModerationAction: type: string Comment: @@ -177,6 +179,10 @@ definitions: type: string format: date-time description: Display name of comment + updated_at: + type: string + format: date-time + description: Display name of comment user_id: type: string description: Display name of comment @@ -186,19 +192,19 @@ definitions: asset_id: type: string description: Display name of comment - # Actions: - # type: object - # properties: - # item_id: - # type: string - # item_type: - # type: string # comment, user... - # type: - # type: string # flagged, likes, upvotes... - # count: - # type: integer - # current_user: - # type: boolean + Actions: + type: object + properties: + item_id: + type: string + item_type: + type: string # comment, user... + type: + type: string # flagged, likes, upvotes... + count: + type: integer + current_user: + type: boolean Action: type: object properties: