@server-status/api

    0.2.1 • Public • Published

    Server Status API

    GraphQL API server for retrieving server status information

    Use

    Add @server-status/api to dependencies in package.json

    $ npm install @server-status/api

    or

    $ yarn add @server-status/api

    Create file e.g. index.js

    const ServerStatus = require('@server-status/api')
     
    const config = {
      plugins: [
        {
          name: 'auth',
          config: {
            users: [
              {
                name: 'dragon',
                pass: 'dragon',
              }
            ],
            secret: 'pancake-is-the-best-dragon',
          }
        },
        {
          name: 'systeminformation',
        },
        {
          name: 'my-awesome-plugin',
          plugin: require('./myPlugins/my-awesome-plugin'),
        },
      ],
      listen: {
        port: 4000,
        host: 'localhost',
      },
      // apolloServerConfig: {},
    }
     
    ServerStatus(config).listen()
     

    And run server

    $ node index.js

    Built-in plugins

    apache2

    Plugin for retrieving information about running virtual host via apache2.

    const config = {
      plugins: [
        {
          name: 'apache2',
          // config: {
          //   user: 'username',
          //   pass: 'password',
          // }
        },
      ],
    }

    auth

    Plugin for for simple authorization to server-status

    const config = {
      plugins: [
        {
          name: 'auth',
          config: {
            users: [
              {
                name: 'dragon',
                pass: 'dragon',
              }
            ],
            secret: 'pancake-is-the-best-dragon',
          }
        },
      ],
    }

    caddy

    Plugin for retrieving information about running virtual host via Caddy Server.

    const config = {
      plugins: [
        {
          name: 'caddy',
          // config: {
          //   user: 'username',
          //   pass: 'password',
          //   port: 2019,
          // }
        },
      ],
    }

    pm2

    Plugin for retrieving information about running app via PM2.

    const config = {
      plugins: [
        {
          name: 'pm2',
        },
      ],
    }

    service

    Plugin for retrieving information about running services.

    const config = {
      plugins: [
        {
          name: 'services',
          config: {
            services: [
              {
                name: 'ServerStatus',
                port: '4000',
              },
              {
                name: 'OneTwoThere',
                port: '123',
              },
            ],
            hosts: [
              'localhost'
            ]
          }
        },
      ],
    }

    systeminformation

    Plugin for retrieving server system information from package systeminformation.

    const config = {
      plugins: [
        {
          name: 'systeminformation',
        },
      ],
    }

    status

    Plugin for retrieving information about running plugins. Auto loaded. You can manually add to specify frontend layout.

    const config = {
      plugins: [
        {
          name: 'status',
          config: {
            layout: [
              {
                "board-3": [
                  {
                    "div": [
                      "system",
                      "loadAverage"
                    ]
                  },
                  {
                    "div": [
                      "memory",
                      "fileSystem"
                    ]
                  }
                ]
              },
              {
                "div": [
                  "pm2",
                  "docker",
                  {
                    "board-2": [
                      {
                        "div": [
                          "network",
                          "services"
                        ]
                      },
                      {
                        "div": [
                          "virtualHosts"
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        },
      ],
    }

    Using YAML instead of JSON

    yarn add @server-status/api yaml
    const ServerStatus = require('@server-status/api')
    const YAML = require('yaml')
    const fs = require('fs')
     
    try {
      const config = YAML.parse(fs.readFileSync('./config.yml', 'utf8'))
     
      ServerStatus(config).listen()
    } catch (e) {
      console.log(e)
    }

    Licence

    MIT

    Install

    npm i @server-status/api

    DownloadsWeekly Downloads

    26

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    106 kB

    Total Files

    115

    Last publish

    Collaborators

    • adam-zielonka