strongloop-evangelists / workshop-band-app Goto Github PK
View Code? Open in Web Editor NEWWorkshop to build an app to help bands
Workshop to build an app to help bands
I haven't actually tried it yet. . . trying to come up with something that fits the context & makes sense. I find the static "CoffeeShop.status" example confusing, as I think most people would assume as I did: that the method checks the status of a particular coffeeshop (instance), whereas in fact it just checks whether the current time is between a hardcoded range.
Instance methods require a bit more configuration (maybe?) but they are much easier to understand the purpose of IMO.
/albums/123/complete
๐ 75
Anyway here it is! Alternately it could just be a "say Hi" type method, but I think for the slides if we're going with "band app" from start to finish it would be confusing to introduce a new, different model while introducing model features.
I am wondering if it wouldn't be easier (at least in the slides) to push remote methods further back, after attendees can see the basic scaffolded stuff in action, see relationships, see how far you can get without customizing.
'use strict';
module.exports = function(Album) {
/**
* reports how complete an album record is based on not-empty fields
* returns number between 0 and 100
* @param {Function(Error, number)} callback
*/
Album.prototype.percentComplete = function(callback) {
var numFields = 5;
var fieldsComplete = 1; // assume title is complete
if (this.year) fieldsComplete++;
if (this['record-label']) fieldsComplete++;
if (this.artwork) fieldsComplete++;
if (this.tracks.length && this.tracks.length > 0) fieldsComplete++;
callback(null, Math.round((fieldsComplete / numFields) * 100));
};
Album.remoteMethod('percentComplete', {
isStatic: false,
description: 'Get % of album fields completed',
http: {
path: '/complete',
verb: 'get',
status: 200
},
returns: {root: true, type: 'number'},
});
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.