@hyperone/resource-provider

1.1.1 • Public • Published

Resource Provider Framework

Versions

  • 1.1.1 - Fix compatibility check in bulkEmitMetric
  • 1.1.0 - Updated protocol & signature in bulkEmitMetric in region.js to write multiple points of resource per request
  • 1.0.0 - Added support for bulkEmitMetric in region.js
  • 1.0.0 - Added support for emit metric to metric_uri via passport file
  • 1.0.0 - Added AuthPasswordOrToken to authenticate & authorize request via IAM / password

OpenAPI

const {openapi} = require('apf');
const Koa = require('koa');
const Router = require('koa-router');
const app = new Koa();
const router = new Router();

const swagger = openapi({
    router: router,
    info: require('./package.json'),
});

swagger.api.addSchema('containerCreate', openapi.props({
    id: {type: 'string'},
    state: {
        type: 'string',
        enum: ['Online', 'Attached', 'Detached', 'Unknown'],
        'x-rbx-field-type': ['state', 'live'],
    },
}));

swagger.addEndpoint({
    method: 'get',
    url: '/resource/:id',
    handler: async (ctx) => {
        ctx.body = await ctx.backend.containerShow(ctx.params.id);
    },
    responses: {
        200: {
            description: 'resource state',
            content: {
                'application/json': {
                    schema: openapi.refComp('container'),
                },
            },
        },
    },
});

router.stack
    .map(route => route.methods.map(method => `AGENT ${method} ${route.path}`)
    .forEach(v => console.log(v)));

app
    .use(router.routes())
    .use(router.allowedMethods());

Readme

Keywords

none

Package Sidebar

Install

npm i @hyperone/resource-provider

Weekly Downloads

14

Version

1.1.1

License

none

Unpacked Size

30.5 kB

Total Files

14

Last publish

Collaborators

  • frederico.silva