This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Store} from 'confidence'; | |
import {readFileSync} from 'fs'; | |
const criteria = { | |
env: process.env.NODE_ENV || 'development' | |
}; | |
let store, | |
config; | |
config = { | |
$meta: 'Config file', | |
server: { | |
host: '0.0.0.0', | |
port: process.env.PORT || 3200, | |
options: {} | |
}, | |
good: { | |
opsInterval: 1000, | |
reporters: [{ | |
reporter: require('good-console'), | |
events: { log: '*' } | |
}] | |
}, | |
postgres: { | |
connectionString: process.env.DATABASE_URL || 'postgres://meenie@localhost/surveys', | |
native: true | |
}, | |
app: { | |
redisUrl: process.env.REDIS_URL || 'redis://localhost:6379' | |
} | |
}; | |
store = new Store(config); | |
export const get = (key) => { | |
return store.get(key, criteria); | |
}; | |
export const meta = (key) => { | |
return store.meta(key, criteria); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {compose} from 'glue'; | |
import * as manifest from './manifest'; | |
compose(manifest.get('/'), {relativeTo: __dirname}, function (err, server) { | |
server.start(function () { | |
server.log('info', 'Server running at: ' + server.connections[0].info.uri); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Store} from 'confidence'; | |
import * as config from './config'; | |
const criteria = { | |
env: process.env.NODE_ENV || 'development' | |
}; | |
let store, | |
manifest; | |
manifest = { | |
$meta: 'My App', | |
connections: [{ | |
host: config.get('/server/host'), | |
port: config.get('/server/port') | |
}], | |
registrations: [ | |
// Third Party Plugins | |
{ | |
plugin: { | |
register: 'good', | |
options: config.get('/good') | |
} | |
}, | |
{ | |
plugin: 'nes' | |
}, | |
{ | |
plugin: { | |
register: 'hapi-node-postgres', | |
options: config.get('/postgres') | |
} | |
}, | |
// App Plugins | |
{ | |
plugin: { | |
register: './plugins/App', | |
options: config.get('/app') | |
} | |
} | |
] | |
}; | |
store = new Store(manifest); | |
export const get = (key) => { | |
return store.get(key, criteria); | |
}; | |
export const meta = (key) => { | |
return store.meta(key, criteria); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {IHapiServer, IHapiRequest, IPluginRegister} from '../../interfaces'; | |
import {IPluginOptions} from './interfaces'; | |
export const register = <IPluginRegister<IPluginOptions>>function (server, options, next) { | |
server.route({ | |
method: 'GET', | |
path: '/', | |
handler: function (request: IHapiRequest, reply) { | |
reply('Hello World'); | |
} | |
}); | |
next(); | |
}; | |
register.attributes = { | |
name: 'App', | |
version: '1.0.0' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment