Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import r from 'rethinkdb'
- import Events from './events'
- import Settings from './settings'
- const plugin = {
- async register (
- server: {
- expose: (s: string, a: any) => {}
- },
- options: {
- host: string,
- port: number,
- db: string,
- user: string,
- password: string
- } = {
- host: 'localhost',
- port: 28015,
- db: 'test',
- user: 'admin',
- password: ''
- },
- next: Function
- ): undefined {
- try {
- await r.connect(options)
- server.expose('events', new Events(r, server.statsd))
- server.expose('settings', new Settings(r, server.statsd))
- } catch (error) {
- next(error)
- }
- next()
- }
- }
- plugin.register.attributes = {
- name: 'orm',
- version: '1.0.0',
- dependencies: ['hapi-statsd']
- }
- export default plugin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement