npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mtr-apidoc

v1.0.7

Published

Meteor Platform API Documentation Formatting Library w/ Swagger

Downloads

2

Readme

API Documentation Formatting Library

Meteor Platform API Documentation Formatting Library w/ Swagger.

Installation

npm i git+ssh://[email protected]/mtr-platform/libs/apidoc#v1.0.7

Penggunaan

Buat file doc.js di dalam root folder atau index.js di dalam folder doc dengan format seperti berikut:

const description = 'API description';
const schemes = ['https', 'http']; // Options are https & http
const tags = [
  {
    name: 'Tag Name',
    description: 'Tag description.',
  },
];
const paths = {
  'path-name': {
    get: { // Method type, options are get, post, put & delete
      tags: ['Tag Name'],
      description: 'Endpoint description',
      auth: true, // If set true then will add an Authorization field on headers
      dataTable: [ // Will automatically generate basic query parameters
        { name: 'id', searchable: true },
        { name: 'name', searchable: true },
        { name: 'phone', searchable: true },
        { name: 'email', searchable: true },
      ],
      parameters: [ // Can be used to add additional query parameters
        {
          name: 'status',
          in: 'query',
          type: 'string',
          default: '',
          description: 'Index only specific status',
        },
      ],
      results: {
        200: {
          total: 1,
          total_filtered: 1,
          total_displayed: 1,
          total_page: 1,
          page: 1,
          data: [
            {
              id: '3ec79570-75f7-11e9-8901-3778b1fc30d4',
              name: 'John Doe',
              phone: '88801426139',
              email: '[email protected]',
            },
          ],
        },
      },
    },
  },
  '/path-name/{id}': {
    post: {
      tags: ['Tag Name'],
      description: 'Endpoint description',
      auth: true,
      parameters: [
        {
          name: 'id',
          in: 'path',       // Options are path, query, header & formData
                            // If value is 'path' then the parameter's name must exist in the endpoint,
                            // in this example is 'id' on '/path-name/{id}'
          type: 'string',   // Options are string, number, integer & boolean
          required: true,   // If not set then the field parameter is optional
          default: '2017ace8-3785-11ea-b295-84ef18e0817f',
          description: 'Parameter description',
          validation: ['Not empty', 'ID is in pathIDs'], // Validation set on API, free test
        },
      ],
      results: {
        200: {
          id: '23b97ce8-1944-11e9-9620-d5ae65e64e7e', // String
          int: 1579586389,                            // Number
          arr: ['OK', 'YES'],                         // Array
          obj: { ok: 1, no: 0 },                      // Object
          is: true,                                   // Boolean
        },
        403: {
          auth_token: {
            value: 'jwt expired',
            msg: 'TokenExpiredError',
          },
        },
      },
      // Possible response code, options are 200, 400, 401, 403, 500
      // Response code value can be in String, Number, Object or Boolean
    },
  },
};

module.exports = {
  description, schemes, tags, paths,
};

Deklarasikan module library di dalam file xxx-gateway/api.js.

const jsonDoc = require('mtr-apidoc');

module.exports = (router) => {
  router.get('/', jsonDoc);
};