UNPKG

@sodacore/ws

Version:

Sodacore ws is a core plugin that extends the Http plugin offering WebSocket support to the Sodacore framework.

26 lines (25 loc) 950 B
import { BasePlugin, Utils } from '@sodacore/core'; import { file } from 'bun'; import WsService from '../service/ws'; import UpgradeMiddleware from '../middleware/upgrade'; import WsConnections from '../provider/ws-connections'; const packageJson = file(Utils.resolve(import.meta.dirname, '../../package.json')); if (!await packageJson.exists()) throw new Error('Package.json not found.'); const packageMeta = await packageJson.json(); export default class WsPlugin extends BasePlugin { constructor(config = {}) { super(config); this.config = config; this.name = packageMeta.name; this.version = packageMeta.version; this.description = packageMeta.description; this.author = packageMeta.author; this.dependencies = ['@sodacore/http']; } async install(app) { app.register(WsConnections); app.register(UpgradeMiddleware); app.register(WsService); } }