Sha256: 63af014c70d1ca24b8bad81b4a9a891260fde967a5ff636409112a0503bf60a7

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

const Gamedig = require('gamedig');
const Hapi = require('@hapi/hapi');

const server = Hapi.server({
    port: 24445,
    host: 'localhost'
});

const init = async () => {

    server.route({
        method: 'GET',
        path: '/exit',
        handler: async (request, h) => {
            server.stop();
            process.exit(0);
            return '';
        }
    });

    server.route({
        method: 'GET',
        path: '/{type}/{ip}',
        handler: async (request, h) => {

            const { type, ip } = request.params;
            const [ host, port ] = ip.split(':')

            const serverData = await Gamedig.query({
                type: type,
                host,
                port
            });
            return serverData;
        }
    });

    await server.start();
};

process.on('unhandledRejection', (err) => {
    console.error(err);
});

init();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
game_dig-0.1.0 lib/node/gamedig-service.js