Socket
Book a DemoInstallSign in
Socket

@byu-oit/fastify-bdp

Package Overview
Dependencies
Maintainers
13
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byu-oit/fastify-bdp

A fastify plugin to configure a BDP API

latest
Source
npmnpm
Version
0.1.8
Version published
Maintainers
13
Created
Source

Fastify BDP API Plugin

A fastify plugin to configure a BDP API

Installation

npm install @byu-oit/fastify-bdp

Usage Example

const Fastify = require('fastify')
const { Type } = require('@fastify/type-provider-typebox')
const { ByuLogger } = require('@byu-oit/logger')
const OpenApi = require('@fastify/swagger')
const OpenApiUi = require('@fastify/swagger-ui')
const { Modifier, BdpResource } = require('@byu-oit/bdp-api')

const byuId = {
    type: Type.String(),
    key: true,
    modifier: Modifier.READ_ONLY
}

const email = {
    type: Type.String(),
    modifier: Modifier.WRITABLE
}

const resource = { byuId, email }
const fastify = Fastify({ logger: ByuLogger() })

fastify.register(OpenApi, {
    swagger: {
        openapi: '3.1.0',
        info: {
            title: 'Example BDP API',
            version: '0.0.0'
        }
    }
})

fastify.register(OpenApiUi, {
    routePrefix: '/documentation'
})

fastify.register(BdpResource, { prefix: '/example/v1', resource, tableName: 'example' })

;(async () => {
    try {
        await fastify.listen({ port: 3000 })
    } catch (err) {
        fastify.log.error(err)
        process.exit(1)
    }
})()

/**
 * ByuJwt prevents SIGINT exit
 * Issue: https://github.com/byu-oit/byu-jwt-nodejs/issues/44
 */
process.on('SIGINT', () => process.exit())

FAQs

Package last updated on 24 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts