-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from BoolJS/develop
Release v0.8.0
- Loading branch information
Showing
21 changed files
with
249 additions
and
463 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Submodule example
deleted from
145d8f
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"node": true, | ||
"laxcomma": true, | ||
"undef": true, | ||
"strict": true, | ||
"unused": true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
|
||
"development": { | ||
"host": "localhost", | ||
"database": "db" | ||
}, | ||
|
||
"test": { | ||
"host": "localhost", | ||
"database": "db_test" | ||
}, | ||
|
||
"production": { | ||
"host": "example.com", | ||
"database": "db" | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'host': 'localhost' | ||
'port': 8080 | ||
'credentials': | ||
'user': 'example' | ||
'password': 'samplepass' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app){ | ||
|
||
var Dog = app.dao.Dog | ||
, json = new app.views.Json(); | ||
|
||
return { | ||
list: function(req, res, next){ | ||
var dog = new Dog(); | ||
json.promise(dog.list(), res, next); | ||
} | ||
}; | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
module.exports = function (app) { | ||
const { Dog } = app.dao; | ||
const { promise } = new app.views.Json(); | ||
|
||
this.list = function (request, response, next) { | ||
var dog = new Dog(); | ||
promise(dog.list(), response, next); | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app){ | ||
|
||
var dog = new app.models.Dog(); | ||
|
||
return { | ||
list: function(){ | ||
return dog.list(); | ||
} | ||
}; | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
const Bool = require('..'); | ||
|
||
// Here is where magic happens | ||
module.exports = new Bool('com.example.api').run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const dogs = []; | ||
|
||
module.exports = class DogModel { | ||
constructor (app) { | ||
this.Error = app.Error; | ||
} | ||
|
||
async list () { | ||
return dogs; | ||
} | ||
|
||
async index (id) { | ||
for (var dog in dogs) { | ||
if (dogs[dog].id === id) { | ||
return dog; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
async find (id) { | ||
var index = this.index(id); | ||
if (index === null) { | ||
throw new this.Error( | ||
404, 'dog_not_found', 'The searched dog wasn\'t in the list' | ||
); | ||
} | ||
return dogs[index]; | ||
} | ||
|
||
async update (id, dog) { | ||
Object.assign(this.find(id), dog); | ||
} | ||
|
||
async delete (id) { | ||
var index = this.index(id); | ||
|
||
if (index === null) { | ||
throw new this.Error( | ||
404, 'dog_not_found', 'The searched dog wasn\'t in the list' | ||
); | ||
} | ||
|
||
dogs.splice(index, 1); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = function (app) { | ||
|
||
var dog = new app.controllers.Dog(); | ||
|
||
return [ | ||
{ | ||
method: 'get', | ||
url: '/dog', | ||
action: dog.list, | ||
cors: true | ||
} | ||
]; | ||
|
||
}; |
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
const { Error } = require('booljs.api'); | ||
const { Error } = require('@booljs/api'); | ||
|
||
/** | ||
* @private | ||
|
Oops, something went wrong.