Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1238 lines (927 sloc) 69 KB

Contributing to readme-inspector

PRs Welcome We welcome contributors, issues, and pull requests.

Request a feature Report a defect

Table of contents

1. Contributions: a brief "how-to"

Contributions start with community conversations that lead to positive change. readme-inspector's open source collaboration model has five steps:
1. Issues
Start community conversations that determine whether proposed changes add value and should be made.
2. Pull Requests (PRs)
Inform and manage community code reviews for approved changes in-progress.
3. Merges
Incorporate approved PR changes into the product.
4. Releases
Make changes available for community consumption.
5. Support
Improves the product with refactorings and defect fixes.


  • Collaboration starts with Issues. Changes happen through Pull Requests.

    View readme-inspector's collaboration and contribution flowcharts:

    Help Toggle view of the Issue workflow flowchart.

    Issue flowchart

    Help Toggle view of the Pull Request workflow flowchart.

    Pull Request flowchart

  • 1.1. Create Issues for feature requests and defects.


    readme-inspector follows an issue-driven product delivery model. Before any work is done, create an Issue, first. This starts a conversation about features, defects ("bugs"), refactoring, product delivery improvements, etc.

    Go ahead! Get started now:

  • 1.2. Format titles with type(scope): subject.


    type categorizes product changes. Valid types are:

    • build: Changes that affect the build system or external dependencies.
    • ci: Changes related to continuous integration, delivery, and deployment tasks.
    • docs: Documentation changes.
    • feat: A new feature.
    • fix: Defect (bug) repair.
    • perf: Performance enhancements.
    • refactor: Source code design improvements that don't affect product behavior.
    • style: Changes involving graphics, typography, etc., as well as source code beautification.
    • test: Tests added to increase code coverage, or corrected due to errors.
  • 1.3. Fill out the issue template.


    ⌦It keeps communication consistent and unambiguous.

  • 1.4. Label the issue (optional).


    ⌦ We use git-labelmaker to categorize Issues (and Pull Requests) consistently. There are four label categories:

    • type: the "kind" of product change.
    • status: the state of a change.
    • priority: the importance and value of a change.
  • 1.5. Monitor your issue for questions.


    ⌦ The team might need more clarification.

  • 1.6. Your issue will be either accepted for work, or declined.


    ⌦ It's up to the Product Owner to agree to proposed changes. If they believe your issue add value, the issue will be approved, and we'll ask someone to volunteer to do the work.

    Otherwise, your issue will be politely declined.

2. Git

Git Logo

  • 2.1. Rules

    readme-inspector manages contributions with the feature-branch-workflow.

  • 2.1.1. Makes changes in a topic branch.


    ⌦ Use an isolated topic branch for parallel product development. Topic branches allow you to submit multiple pull requests without confusion. You can iterate without polluting the master branch with potentially unstable, unfinished code. The readme-inspector team uses:

  • 2.1.2. Favor the topic branch naming convention GH-{ISSUE_NUMBER}-type-scope.


    ⌦ Although not required, our team prefixes branches with the GitHub issue number, followed by the type of change being introduced, followed by the scope of changes.


    • feat: a new feature, e.g., GH-1-feat-cli-add-authz.
    • fix: a defect/bug repair, e.g., GH-2-fix-api-logging-error.
    • build: changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm), e.g., GH-8-build-add-markdown-toc.
    • chore: changes that don't modify src or test files, e.g., GH-10-remove-unused-files.
    • ci: changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs), e.g., GH-9-ci-travis-deploy-semantic-release.
    • docs: documentation changes, e.g., GH-3-docs-readme-revise-api.
    • perf: change that improves performance GH-6-perf-quicksort.
    • refactor: code changes that improve design, but neither fixes a bug nor adds a feature, e.g., GH-5-refactor-extract-class.
    • revert: reverts a previous commit, e.g., GH-11-revert-7f87cc2.
    • style: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc), e.g., GH-4-style-lint.
    • test: add missing tests or correct existing tests, e.g., GH-7-test-complete-coverage.
  • 2.1.3. Branch out from master.


    readme-inspector follows the feature-branch-workflow.

  • 2.1.4. Never push into the master branch. Always submit a Pull Request.


    ⌦ It notifies team members whenever changes occur and allows the community to review your changes at any time..

    It also enables easy peer-review of the code and dedicates forum for discussing the proposed feature.

  • 2.1.5. Submit a Pull Request as soon as possible.


    ⌦ Pull Requests declare work in progress. Frequent pushes to a Pull Request notify your team members about change, and gives them the opportunity to provide feedback more often.

    Pull Request pushes also trigger automated CI-services, which help you fail fast and assess quality.

  • 2.1.6. Rebase your local master branch before you ask for PR approvals.


    ⌦ Rebasing will merge in the requested branch (master or develop) and apply the commits that you have made locally to the top of the history without creating a merge commit (assuming there were no conflicts). This results in a nice and clean history.

  • 2.1.7. Resolve rebase conflicts before Pull Request reviews.


    ⌦ Rebasing will merge in the master branch and apply the commits that you have made locally to the top of it.

  • 2.1.8. Add reviewers and the label Status: Needs Review when the topic branch is ready.


    ⌦ When you add a Reviewer, GitHub (or Bitbucket) notifies teammates that your topic branch meets all Acceptance Criteria and is ready to be merged into master.

    Add the label "Status: Review Needed" formally declares the status of your topic branch, and helps teams filter through issues.

  • 2.1.9. Delete local and remote topic branches after merging.


    ⌦ Topic branches should only exist while work is in-progress. Merged topic branches clutter up your list of branches with dead branches. Topic branch deletion also insures that you only ever merge back into master.

  • 2.1.10. Protect your master branch.


    ⌦ Branch protection prevents production-ready branches from incorporating unexpected and irreversible changes. Learn more about

  • 2.2. Feature-branch-workflow

    We use the feature-branch-workflow. We recommend interactive rebasing, too, but that's not required.

  • 2.2.1. Initialize a Git repository in the product directory (for new repositories only).

    For subsequent features and changes, this step should be ignored.

    cd <product-repo-directory>
    git init
  • 2.2.2. Checkout a new feature or fix branch.

    # For a new feature branch:
    git checkout -b GH-<issueId>-feat-scope-of-change
    # For branches that address defects:
    git checkout -b GH-<issueId>-fix-scope-of-change
  • 2.2.3. Make Changes.

    git add
    git commit -a


    git commit -a will start an editor which lets you separate the subject from the body. Read more about it in section 1.3.

  • 2.2.4. Follow the Conventional Commits Specification for commit messages.

    This project enforces AngularJS Git Commit Guidelines (which is now an extension of the Conventional Commits Specfication) with commitplease pre-commit hooks.


    Consistent, legible Git logs not only facilitate communication, but also enable automated CHANGELOG generation and semantic versioning with standard-version.

    View all conventional commit message templates.

    • BREAKING CHANGE commit messages

      A change that breaks the product's public API.

      <type>(<scope>): <subject>
      <BLANK LINE>
      BREAKING CHANGE: summary of change.
      <BLANK LINE>
      <BLANK LINE>
    • build commit messages

      Issues related to product builds.

      build(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • chore commit messages

      Issues related to miscellaneous non-functional changes (usually "maintenance" changes).

      chore(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • ci commit messages

      Issues related to continuous integration, delivery, and deployment tasks.

      ci(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • docs commit messages

      Issues related to documentation.

      docs(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • feat (feature) commit messages

      New feature or enhancement requests.

      feat(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • fix commit messages

      Defect (bug) repair issues.

      fix(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • perf (performance) commit messages

      Performance improvement issues.

      perf(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • refactor commit messages

      Source code design improvements that do not affect product behavior.

      refactor(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • revert commit messages

      Tasks that revert to a previous commit hash. Your message should begin with revert:, followed by the header of the reverted commit.

      In the body it should say: This reverts commit <hash>., where the hash is the SHA of the commit being reverted.

      revert: <hash>
      <BLANK LINE>
      This reverts commit <hash>.
      <BLANK LINE>
    • style commit messages

      Issues related to style guideline compliance, especially ESLint errors and warnings.

      style(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>
    • test commit messages

      Test coverage tasks.

      test(<scope>): <subject>
      <BLANK LINE>
      <BLANK LINE>

  • 2.2.5. Sync with remote to get changes you’ve missed.

    git checkout master
    git pull


    ⌦ This will give you a chance to deal with conflicts on your machine while rebasing(later) rather than creating a Pull Request that contains conflicts.

  • 2.2.6. Update your topic branch with the latest changes from master by interactive rebase.

    git checkout <branchname>
    git rebase -i --autosquash master


    ⌦ You can use --autosquash to squash all your commits to a single commit. Nobody wants many commits for a single feature in develop branch.

    Learn more about autosquashing Git commits.

  • 2.2.7. Resolve conflicts (if any occur), and continue rebase.

    git add <file1> <file2> ...
    git rebase --continue

    Learn more about resolving conflicts.

  • 2.2.8. Push your branch with the -f flag (if necessary).

    Rebase changes history, so you might need to force changes into the remote branch with the -f flag. If someone else is working on your branch, use the less destructive --force-with-lease.

    git push -f


    ⌦ When you do a rebase, you are changing the history on your topic branch. As a result, Git will reject normal git push. Instead, you'll need to use the -f or --force flag.

    Learn more about --force-with-lease.

  • 2.2.9. Submit a Pull Request.

  • 2.2.10. Once accepted, the Pull request will be merged, closed, and deleted by an administrator.

  • 2.2.11. Remove your local topic branch if you're done.

    git branch -d <branchname>

    to remove all branches which are no longer on remote

    git fetch -p && \
      for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; \
        do git branch -D $branch; \
  • 3. Code standards

    JavaScript Style Guide ESLint logo

    • 3.1. Use the Standard JS Style.

      readme-inspector follows the Standard JS Style.

    • 3.2. Use ESLint to analyze source code.


      ESLint evaluates JavaScript code (and --fixes what it can) whenever npm test runs. You can run ESLint directly with:

      npm run lint:js

      View readme-inspector's ESLint rules and their enforcement.

    4. Unit testing

    Jest JavaScript Testing

    • 4.1. Write Jest tests.


      ⌦ Behavior-driven development specifications are executable documentation.

      • Put test files in the **test** directory.

      • Use the .spec.js suffix for all tests.

    • 4.2. Reach 100% code coverage.


      ⌦ Full coverage makes automated dependency drift updates safer.

      • View a test coverage summary in the Terminal:

        npm test
        > jest --config=jest.config.json
          PASS  **tests**/app.js
            ✓ creates files (1ms)
        Test Suites: 1 passed, 1 total
        Tests:       1 passed, 1 total
        Snapshots:   0 total
        Time:        2.595s
        Ran all test suites.
        File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
        All files |      100 |      100 |      100 |      100 |                |
         index.js |      100 |      100 |      100 |      100 |                |
      • Open /coverage/lcov-report/index.html in a Web browser to view detailed coverage reports.

    5. Directory structure

    node_modules has been excluded for brevity.


    6. Logging

    readme-inspector uses bunyan for logging.

    7. Dependencies

    7.1. Production

    readme-inspector requires the following dependencies to operate.

    Dependency Description Version License Type
    @octokit/rest@15.2.6 GitHub REST API client for Node.js 15.2.6 MIT production
    bunyan@1.8.12 a JSON logging library for node.js services 1.8.12 MIT production
    bunyan-format@0.2.1 Writable stream that formats bunyan records that are piped into it. 0.2.1 [object Object] production
    dotenv@5.0.1 Loads environment variables from .env file 5.0.1 BSD-2-Clause production
    dotenv-extended@2.0.2 A module for loading .env files and optionally loading defaults and a schema for validating all values are present. 2.0.2 MIT production
    got@8.3.0 Simplified HTTP requests 8.3.0 MIT production
    insight@0.10.1 Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics or Yandex.Metrica 0.10.1 BSD-2-Clause production
    lodash.camelcase@4.3.0 The lodash method _.camelCase exported as a module. 4.3.0 MIT production
    lodash.mapkeys@4.6.0 The lodash method _.mapKeys exported as a module. 4.6.0 MIT production
    lodash.noop@3.0.1 The lodash method _.noop exported as a module. 3.0.1 MIT production
    meow@5.0.0 CLI app helper 5.0.0 MIT production

    7.2. Development

    readme-inspector uses the the following dependencies to build, test, or deploy:

    Dependency Description Version License Type
    @semantic-release/changelog@2.0.1 Set of semantic-release plugins for creating or updating a changelog file 2.0.1 MIT dev
    @semantic-release/git@4.0.2 Set of semantic-release plugins to publish to a git repository 4.0.2 MIT dev
    @semantic-release/npm@3.2.4 Set of semantic-release plugins to publish to a npm registry 3.2.4 MIT dev
    ajv@6.4.0 Another JSON Schema Validator 6.4.0 MIT dev
    ajv-keywords@3.2.0 Custom JSON-Schema keywords for Ajv validator 3.2.0 MIT dev
    codacy-coverage@3.0.0 Code Coverage reporter for 3.0.0 MIT dev
    commitplease@3.2.0 Validates strings as commit messages 3.2.0 MIT dev
    coveralls@3.0.0 takes json-cov output into stdin and POSTs to 3.0.0 BSD-2-Clause dev
    eslint@4.19.1 An AST-based pattern checker for JavaScript. 4.19.1 MIT dev
    eslint-config-prettier@^2.4.0 Turns off all rules that are unnecessary or might conflict with Prettier. 2.9.0 MIT dev
    eslint-config-scanjs@1.0.0-beta4 umbrella config to get scanjs-like functionality from eslint 1.0.0-beta4 MPL-2.0 dev
    eslint-config-standard@11.0.0 JavaScript Standard Style - ESLint Shareable Config 11.0.0 MIT dev
    eslint-config-xo@0.20.1 ESLint shareable config for XO 0.20.1 MIT dev
    eslint-plugin-import@2.11.0 Import with sanity. 2.11.0 MIT dev
    eslint-plugin-jsdoc@3.6.3 JSDoc linting rules for ESLint. 3.6.3 BSD-3-Clause dev
    eslint-plugin-json@1.2.0 Lint JSON files 1.2.0 ISC dev
    eslint-plugin-no-unsafe-innerhtml@1.0.16 custom ESLint rule to disallows unsafe innerHTML, outerHTML and insertAdjacentHTML 1.0.16 MPL-2.0 dev
    eslint-plugin-node@6.0.1 Additional ESLint's rules for Node.js 6.0.1 MIT dev
    eslint-plugin-prettier@^2.2.0 Runs prettier as an eslint rule 2.6.0 MIT dev
    eslint-plugin-promise@3.7.0 Enforce best practices for JavaScript promises 3.7.0 ISC dev
    eslint-plugin-security@1.4.0 Security rules for eslint 1.4.0 Apache-2.0 dev
    eslint-plugin-standard@3.1.0 ESlint Plugin for the Standard Linter 3.1.0 MIT dev
    eslint-plugin-unicorn@4.0.3 Various awesome ESLint rules 4.0.3 MIT dev
    eslint-plugin-xss@0.1.9 Validates XSS related issues of mixing HTML and non-HTML content in variables. 0.1.9 ISC dev
    fixpack@2.3.1 cli tool that cleans up package.json files. 2.3.1 MIT dev
    husky@^0.14.3 Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...) 0.14.3 MIT dev
    jest@22.4.3 Delightful JavaScript Testing. 22.4.3 MIT dev
    jsdoc@3.5.5 An API documentation generator for JavaScript. 3.5.5 Apache-2.0 dev
    lec@^1.0.1 Command Line Wrapper for Line Ending Corrector (An utility that makes sure your files have consistent line endings) 1.0.1 MIT dev
    lint-staged@7.0.5 Lint files staged by git 7.0.5 MIT dev
    lodash.isundefined@3.0.1 The modern build of lodash’s _.isUndefined as a module. 3.0.1 MIT dev
    lodash.set@4.3.2 The lodash method _.set exported as a module. 4.3.2 MIT dev
    markdown-magic@0.1.21 Automatically update markdown files with content from external sources 0.1.21 MIT dev
    markdown-magic-dependency-table@1.3.2 Generate table of information about dependencies automatically in markdown 1.3.2 MIT dev
    markdown-magic-install-command@1.3.1 Print install command for markdown file 1.3.1 MIT dev
    markdown-magic-package-scripts@1.2.1 Print list of scripts in package.json with descriptions 1.2.1 MIT dev
    minami@1.2.3 Clean and minimal JSDoc 3 Template / Theme 1.2.3 UNLICENSED dev
    nsp@^3.2.1 The Node Security ( command line interface 3.2.1 Apache-2.0 dev
    prettier@1.12.1 Prettier is an opinionated code formatter 1.12.1 MIT dev
    semantic-release@15.1.7 Automated semver compliant package publishing 15.1.7 MIT dev
    standard-markdown@4.0.2 Test your Markdown files for Standard JavaScript Style™ 4.0.2 MIT dev
    standard-version@4.3.0 replacement for npm version with automatic CHANGELOG generation 4.3.0 ISC dev

    7.3. Optional

    Dependency Description Version License Type

    8. APIs


    • 8.1 API design


      ⌦ Because we try to enforce development of sanely constructed RESTful interfaces, which team members and clients can consume simply and consistently.


      ⌦ Lack of consistency and simplicity can massively increase integration and maintenance costs. Which is why API design is included in this document.

    • We mostly follow resource-oriented design. It has three main factors: resources, collection, and URLs.

      • A resource has data, gets nested, and there are methods that operate against it.
      • A group of resources is called a collection.
      • URL identifies the online location of resource or collection.


      ⌦ This is a very well-known design to developers (your main API consumers). Apart from readability and ease of use, it allows us to write generic libraries and connectors without even knowing what the API is about.

    • Use kebab-case for URLs.

    • Use camelCase for parameters in the query string or resource fields.

    • Use plural kebab-case for resource names in URLs.

    • Always use a plural nouns for naming a url pointing to a collection: /users.


      ⌦ Basically, it reads better and keeps URLs consistent. read more...

    • In the source code convert plurals to variables and properties with a List suffix.


      ⌦ Plural is nice in the URL but in the source code, it’s just too subtle and error-prone.

    • Always use a singular concept that starts with a collection and ends to an identifier:

    • Avoid URLs like this:

      GET /blogs/:blogId/posts/:postId/summary


      ⌦ This is not pointing to a resource but to a property instead. You can pass the property as a parameter to trim your response.

    • Keep verbs out of your resource URLs.


      ⌦ Because if you use a verb for each resource operation you soon will have a huge list of URLs and no consistent pattern which makes it difficult for developers to learn. Plus we use verbs for something else.

    • Use verbs for non-resources. In this case, your API doesn't return any resources. Instead, you execute an operation and return the result. These are not CRUD (create, retrieve, update, and delete) operations:



      ⌦ Because for CRUD we use HTTP methods on resource or collection URLs. The verbs we were talking about are actually Controllers. You usually don't develop many of these. read more...

    • The request body or response type is JSON then please follow camelCase for JSON property names to maintain the consistency.


      ⌦ This is a JavaScript project guideline, Where Programming language for generating JSON as well as Programming language for parsing JSON are assumed to be JavaScript.

    • Even though a resource is a singular concept that is similar to an object instance or database record, you should not use your table_name for a resource name and column_name resource property.


      ⌦ Because your intention is to expose Resources, not your database schema details.

    • Again, only use nouns in your URL when naming your resources and don’t try to explain their functionality.


      ⌦ Only use nouns in your resource URLs, avoid endpoints like /addNewUser or /updateUser . Also avoid sending resource operations as a parameter.

    • Explain the CRUD functionalities using HTTP methods:


      GET: Retrieve a representation of a resource.

      POST: Create new resources and sub-resources.

      PUT: Replace existing resources.

      PATCH: Update existing resources. It only updates the fields that were supplied, leaving the others alone.

      DELETE: Delete existing resources.

    • For nested resources, use the relation between them in the URL. For instance, using id to relate an employee to a company.


      ⌦ This is a natural way to make resources explorable.


      GET /schools/2/students , should get the list of all students from school 2.

      GET /schools/2/students/31 , should get the details of student 31, which belongs to school 2.

      DELETE /schools/2/students/31 , should delete student 31, which belongs to school 2.

      PUT /schools/2/students/31 , should update info of student 31, Use PUT on resource-URL only, not collection.

      POST /schools , should create a new school and return the details of the new school created. Use POST on collection-URLs.

    • Use a simple ordinal number for a version with a v prefix (v1, v2). Move it all the way to the left in the URL so that it has the highest scope:


      ⌦ When your APIs are public for other third parties, upgrading the APIs with some breaking change would also lead to breaking the existing products or services using your APIs. Using versions in your URL can prevent that from happening. read more...

    • Response messages must be self-descriptive. A good error message response might look something like this:

        "code": 404,
        "level": "ERROR",
        "logger": "[http-logger]",
          "No resource found at URL /archetypes/v1/locales/iso-country-codes/BS",
        "timestamp": 1504878062000

      or for validation errors:

        "code": 400,
        "logger": "[registration-form-logger]",
        "level": "ERROR",
        "timestamp": 1504878062000,
        "message": "Validation Failed",
        "stack": [
            "code": 1233,
            "field": "email",
            "message": "Invalid email"
            "code": 1234,
            "field": "password",
            "message": "No password provided"


      ⌦ Developers depend on well-designed errors at the critical times when they are troubleshooting and resolving issues after the applications they've built using your APIs are in the hands of their users.

      Note: Keep security exception messages as generic as possible. For instance, Instead of saying ‘incorrect password’, you can reply back saying ‘invalid username or password’ so that we don’t unknowingly inform user that username was indeed correct and only the password was incorrect.

    • Use only these 8 status codes to send with you response to describe whether everything worked, The client app did something wrong or The API did something wrong.

      Which ones:

      200 OK response represents success for GET, PUT or POST requests.

      201 Created for when new instance is created. Creating a new instance, using POST method returns 201 status code.

      304 Not Modified response is to minimize information transfer when the recipient already has cached representations.

      400 Bad Request for when the request was not processed, as the server could not understand what the client is asking for.

      401 Unauthorized for when the request lacks valid credentials and it should re-request with the required credentials.

      403 Forbidden means the server understood the request but refuses to authorize it.

      404 Not Found indicates that the requested resource was not found.

      500 Internal Server Error indicates that the request is valid, but the server could not fulfill it due to some unexpected condition.


      ⌦ Most API providers use a small subset HTTP status codes. For example, the Google GData API uses only 10 status codes, Netflix uses 9, and Digg, only 8. Of course, these responses contain a body with additional information.There are over 70 HTTP status codes. However, most developers don't have all 70 memorized. So if you choose status codes that are not very common you will force application developers away from building their apps and over to wikipedia to figure out what you're trying to tell them. read more...

    • Provide total numbers of resources in your response.

    • Accept limit and offset parameters.

    • The amount of data the resource exposes should also be taken into account. The API consumer doesn't always need the full representation of a resource.Use a fields query parameter that takes a comma separated list of fields to include:

      GET /student?fields=id,name,age,class
    • Pagination, filtering, and sorting don’t need to be supported from start for all resources. Document those resources that offer filtering and sorting.

    • 8.2 API security

      These are some basic security best practices:

      • Don't use basic authentication unless over a secure connection (HTTPS). Authentication tokens must not be transmitted in the URL: GET /users/123?token=asdf....


        ⌦ Because Token, or user ID and password are passed over the network as clear text (it is base64 encoded, but base64 is a reversible encoding), the basic authentication scheme is not secure. read more...

      • Tokens must be transmitted using the Authorization header on every request: Authorization: Bearer xxxxxx, Extra yyyyy.

      • Authorization Code should be short-lived.

      • Reject any non-TLS requests by not responding to any HTTP request to avoid any insecure data exchange. Respond to HTTP requests by 403 Forbidden.

      • Consider using Rate Limiting.


        ⌦ To protect your APIs from bot threats that call your API thousands of times per hour. You should consider implementing rate limit early on.

      • Setting HTTP headers appropriately can help to lock down and secure your web application. read more...

      • Your API should convert the received data to their canonical form or reject them. Return 400 Bad Request with details about any errors from bad or missing data.

      • All the data exchanged with the ReST API must be validated by the API.

      • Serialize your JSON.


        ⌦ A key concern with JSON encoders is preventing arbitrary JavaScript remote code execution within the browser... or, if you're using node.js, on the server. It's vital that you use a proper JSON serializer to encode user-supplied data properly to prevent the execution of user-supplied input on the browser.

      • Validate the content-type and mostly use application/*json (Content-Type header).


        ⌦ For instance, accepting the application/x-www-form-urlencoded mime type allows the attacker to create a form and trigger a simple POST request. The server should never assume the Content-Type. A lack of Content-Type header or an unexpected Content-Type header should result in the server rejecting the content with a 4XX response.

    • 8.3 API documentation

      • Fill the API Reference section in template for API.
      • Describe API authentication methods with a code sample.
      • Explaining The URL Structure (path only, no root URL) including The request type (Method).

      For each endpoint explain:

      • URL Params If URL Params exist, specify them in accordance with name mentioned in URL section:

        Required: id=[integer]
        Optional: photo_id=[alphanumeric]
      • If the request type is POST, provide working examples. URL Params rules apply here too. Separate the section into Optional and Required.

      • Success Responses. What should be the status code and is there any return data? This is useful when people need to know what their callbacks should expect:

        Code: 200
        Content: { id : 12 }
      • Error Responses. Most endpoints have many ways to fail. From unauthorized access to wrongful parameters etc. All of those should be listed here. It might seem repetitive, but it helps prevent assumptions from being made. For example:

        • HTTP status code

          404 Not Found
        • Response body

            "code": 404,
            "level": "ERROR",
            "logger": "[http-logger]",
              "No resource found at URL /archetypes/v1/locales/iso-country-codes/BS",
            "timestamp": 1504878062000
        • Response headers

          accept-ranges: bytes
          access-control-allow-headers: Authorization
          access-control-allow-methods: GET, HEAD, OPTIONS
          access-control-allow-origin: *
          cache-control: public, no-transform, must-revalidate
          connection: keep-alive
          content-encoding: gzip
          content-language: en-US
          content-length: 149
          content-type: application/json
          date: Fri, 08 Sep 2017 06:41:02 GMT
          last-modified: Tue, 1 Oct 2014 10:10:10 GMT
          server: nginx/1.12.1
          vary: Accept-Encoding
      • Use API design tools, There are lots of open source tools for good documentation such as API Blueprint and Swagger.

    9. Licensing


    Make sure you use resources that you have the rights to use. If you use libraries, remember to look for MIT, Apache or BSD but if you modify them, then take a look into license details. Copyrighted images and videos may cause legal problems.

    You can’t perform that action at this time.