Anime recommendations website
- Requirements
- An installation of node.js (with npm)
- A mysql database
- A redis database
- Installing
After downloading/cloning, run the following commands:
npm install -g bower && npm install -g gulp && npm install && bower install
- Config
Copy the file .env.example
into a new file called .env
, and edit its values.
Adonis uses ES6 generators in order to make the code more readable. However, this may create some issues when trying to interface with classic node.js code.
Fixed using the co
module.
Example: Requesting a user from the database for verification with passport.
const co = require('co');
...
passport.use('local', new LocalStrategy(
function (username, password, done) {
return co(function* () {
const user = yield User.where('username', username).first().fetch();
...
});
}
))
Done using promises.
Example:
class Recommendation {
...
addLike (userId, itemId, omitUpdate) {
return new Promise((resolve, reject) => {
raccoon.liked(userId, itemId, omitUpdate, function(results) {
resolve(results)
})
})
}
...
}
Usage: yield Recommendation.addLike(userId, itemId, true);