]>
git.r.bdr.sh - rbdr/dead-drop/blob - lib/dead_drop.js
1ea86e8079f602b4f8a181b7c636501dba437a35
3 const Koa
= require('koa');
4 const KoaRoute
= require('koa-route');
9 * The Dead Drop class is the main entry point for the application.
12 * @param {DeadDrop.tConfiguration} config the initialization options to
15 module
.exports
= internals
.DeadDrop
= class DeadDrop
{
19 Object
.assign(this, config
);
23 * Initializes the application and starts listening. Also prints a
24 * nice robotic banner with information.
32 this._initializeServer();
36 return Promise
.resolve();
39 // Initializes the Koa application and all the handlers.
45 this._app
.use(KoaRoute
.get('/menus/main', function * () {
47 this.body
= 'I will return the main menu.';
50 this._app
.use(KoaRoute
.post('/menus/main', function * () {
52 this.body
= 'I will parse the main menu.';
55 this._app
.use(KoaRoute
.get('/menus/recording', function * () {
57 this.body
= 'I will return the select recording menu.';
60 this._app
.use(KoaRoute
.post('/menus/recording', function * () {
62 this.body
= 'I will parse the select recording menu.';
65 this._app
.use(KoaRoute
.get('/recordings', function * () {
67 this.body
= 'I will initiate recording process';
70 this._app
.use(KoaRoute
.post('/recordings', function * () {
72 this.body
= 'I will create a new recording';
75 this._app
.use(KoaRoute
.get('/recordings/:id', function * (id
) {
80 this.body
= 'I will return a random recording';
83 this.body
= 'I will return a specific recording';
87 this._app
.use(function * () {
89 this.body
= 'hello, world';
98 this._app
.listen(this.port
);
101 // Prints the banner.
106 console
.log(' /-----\\');
107 console
.log(` |ú ù| - Happy to listen on: ${this.port}`);
108 console
.log(' | U |');
109 console
.log(' \\---/');
110 console
.log(' +---------+');
111 console
.log(' ~| () |~');
112 console
.log(' ~| /\\ | ~');
113 console
.log(' ~| \\/ | ~c');
114 console
.log(' ^+---------+');
115 console
.log(' (o==o==o) ');