Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import r from 'rethinkdb'
  2.  
  3. import Events from './events'
  4. import Settings from './settings'
  5.  
  6. const plugin = {
  7. async register (
  8. server: {
  9. expose: (s: string, a: any) => {}
  10. },
  11. options: {
  12. host: string,
  13. port: number,
  14. db: string,
  15. user: string,
  16. password: string
  17. } = {
  18. host: 'localhost',
  19. port: 28015,
  20. db: 'test',
  21. user: 'admin',
  22. password: ''
  23. },
  24. next: Function
  25. ): undefined {
  26. try {
  27. await r.connect(options)
  28. server.expose('events', new Events(r, server.statsd))
  29. server.expose('settings', new Settings(r, server.statsd))
  30. } catch (error) {
  31. next(error)
  32. }
  33.  
  34. next()
  35. }
  36. }
  37.  
  38. plugin.register.attributes = {
  39. name: 'orm',
  40. version: '1.0.0',
  41. dependencies: ['hapi-statsd']
  42. }
  43.  
  44. export default plugin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement