diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..b051c6c57 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +client 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] } } diff --git a/package.json b/package.json index a93714339..096863202 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,26 @@ "description": "A commenting platform from The Coral Project. https://coralproject.net", "main": "app.js", "scripts": { - "lint": "eslint .", "start": "./bin/www", "build": "webpack --config ./client/coral-embed-stream/webpack.config.js", + "lint": "eslint .", + "pretest": "npm install", + "test": "mocha tests", "embed-start": "node client/coral-embed-stream/dev-server.js" }, + "config": { + "pre-git": { + "commit-msg": [], + "pre-commit": [ + "npm run lint" + ], + "pre-push": [ + "npm test" + ], + "post-commit": [], + "post-merge": [] + } + }, "repository": { "type": "git", "url": "git+https://github.com/coralproject/talk.git" @@ -42,11 +57,15 @@ "babel-preset-es2015": "6.13.0", "babel-preset-es2015-minimal": "^2.1.0", "babel-preset-stage-0": "^6.16.0", + "chai": "^3.5.0", "copy-webpack-plugin": "^3.0.1", + "eslint": "^3.9.1", "exports-loader": "^0.6.3", "immutable": "^3.8.1", "imports-loader": "^0.6.5", "json-loader": "^0.5.4", + "mocha": "^3.1.2", + "pre-git": "^3.10.0", "pym.js": "^1.1.1", "react": "15.3.2", "react-dom": "15.3.2", @@ -54,6 +73,7 @@ "redux": "^3.6.0", "redux-thunk": "^2.1.0", "regenerator": "^0.8.46", + "supertest": "^2.0.1", "timeago.js": "^2.0.3", "webpack": "^1.13.2", "webpack-dashboard": "^0.2.0", diff --git a/swagger.yaml b/swagger.yaml index 3c154c6f7..a7fdc973d 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -11,35 +11,204 @@ 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 + 201: + description: "OK: Comment Added" + schema: + $ref: '#/definitions/Comment' + 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: + 201: + 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: + 204: + description: ModerationAction Added + /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 + enum: + - pending + - flagged + - rejected + - 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: + 204: + description: OK + + + definitions: + Item: + type: object + 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 + updated_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. 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); + }); + }); +});