 Ladies and gentlemen, it's much more boring than the talks before. I'm Stefan. I'm old enough that when I was studying economics, I didn't play with spreadsheets. I learned to program COBOL. And I'm still waiting for my COBOL compiler that spits out JavaScript code. What you can easily guess, like I say, one of the few guys wearing a formal shirt and formal pants I worked for, the Borg, also better known as IBM. And to my horror, that's a very phrase I love to hear, to my horror I realized it's 10 years now that I work for them. I'm in Singapore for about 16 years, so in case you don't understand what I'm talking about, that's singlish with a German accent. Kenla, if you glance at the URL, the talks online. So you can look at the slides. Don't need to listen to me. And it's basically the express framework. So now we had a little discussion. I said, Stefan, you really want to talk about that. That comes down like an IBM marketing grant because the loopback framework is owned by Strongloop. And Strongloop belongs to IBM, and you work for IBM. And I said, crap. Tim said, you should talk about things you have no clue about. So you guys can talk about dating. That hurt. I know. OK, just for the record, I'm a trained counselor. So if you want to know about seeing the outside. Yeah, seriously, that's not a joke. So everything I know about IT I more or less thought myself. I did study economics. I studied law. I was certified as a counselor, actually for dysfunctional IT teams. So my specialty was when I was younger and more interested. Now I'm married, not interested anymore. I was consoling, crying secretaries because the word processor didn't work. Today, I console crying project managers when the schedule is behind. We get them all the time. We all know them. Projects are on time, best price, feature complete. Pick any two. OK, so quick one. The Loopback framework sits on top of Express, so you don't need to learn anything new. It's model driven. I'm going to have a little look on that, what it's all about. It's all about generating REST-based APIs. It has a little bit of access control and persistence abstracted, which makes a lot of things easier. Because in all the demos you see, usually, they skip over the access control part. And it adds phases to the middleware. So before pretty, after pretty, while pretty. So you have more than just the middleware, which is kind of shaky in Express, when does which part of the middleware execute. And then it has a bit of tools and stuff around it. But let's dig into that. So typically, at least in the life of a Borg, the requirements that happen in every application. OK, I have some data somewhere, and it might be Mongo. So if you're mean, in IBM, they are clean. That's Cloudant, Loopback, instead of Mongo. Then you want to easily move between development and UAT in production. So UAT, well, we test in production. And then user management act has control, and you also want to have it documented. You know, like, say, some people get a death sentence, other people get sentenced to make documentation. I'm not sure which one is worse. So boring. And under this aspect, let's have a look at the components the Loopback framework has. So there's some core code, which you do NPM install. There is an SLC command line tool. Basically, it's a customized version of Yo-Man. So you know Yo, whatever, like this morning. Did I do this morning? Yeah, this morning, Yo reveal and off get the presentation. There is a GUI tool. There is the data wrangler, and there's a little bit of an SDK. So you all know how it works. Install the stuff. And then when you look at it, like, say, you have SLC loopback, and then you have sub commands. For instance, one of the things is to say loopback swagger. So if you have a swagger definition file, you can straight away import that, and it will generate you the models. You have loopback relation, which I don't do relational databases. So I don't know what this is. I'm married, so my relation works. Any divorce lawyers here? The interesting one is ACL, and then loopback model is to create one. But then maybe I just go and show you a little bit. So I already typed in SLC loopback. I said, OK, SLC loopback. And then it asked me, eventually, oh, let's do an application. How do you want to call it? Let's say I call it carpool. And then where's the directory? It goes directory carpool. And then it goes bang and generates an application for me. So that's not very sexy. That takes a moment. I think I'm still connected to the network. And what it does, you see that already, it goes and creates a server directory with authentication, with a root. It creates component configuration, which is quite interesting. So then let's go into the directory. And then I say, SLC loopback call model. OK, let's create a model. So I want to build maybe a carpool. Oops, that was too fast. Let me try this again. So I say, loopback model. They said, what's the model? So I'm going to go and build a car. And where does the data source? I currently have none configured. So it has a memory database for me. There's just dumping stuff in memory. And you can actually go and dump it into a file. This makes it very, very easy to get started, because you don't need to fight with the database in the beginning. And OK, so what is it based on? Persistent model. Do you want to have it via the REST API? Yes, that's fine. What's the plural of car? And say cars. Oh, not cars. Cars. Courses the other thing we generally don't like. So is it a common model, or is it server-specific? I said it is common. A property name, OK, the car should have a name. And then what is the data type? It's a string. Is it required? Yes. Another, so I said, speed. And then it's number. Oops, not other number. OK. Bump required, no. Broken cars have no speed. I hit Enter. And I have already a minimal working model. If I don't like command line, I find it so sweet. I started in IT. Everything was command line. We spent a shitload of CPU cycles to get graphical user interfaces. And where are we back? I have the command line. I love it. What happens if you want to change something about this model and regenerate it? Just edit the JSON file. We have a look at this in a second. And then I go there and I'm a bit lazy. And then there's ARC. I have no clue what it stands for, automatic whatever, which starts the GUI. So now you see we are a local host. And there you have this piece, the composer. This is what is part of the loopback framework. And the other stuff is the commercial thing. So I'm going to not talk about this part. I promise. So when I go to the composer, I actually go and can see there is my car model already there. And then I can go and say I can specify different data sources, which are predefined. There's also community data sources. Because currently my favorite database is not in there. I'm a big couch DB fan. I know the guy who wrote it, he's butch it crazy. As in a good sense, butch it crazy. Anyway, so then I could go there and I said, OK, I want to change something. Let me click not on the new model, on the car. And you see, I say, for instance, here I have my little model and it said speed is a number. And I said, OK, I changed that to required. So that answers part of your question. So I can use the graphical user interface. But like I said, graphical user interfaces are so out of fashion. There was a save model button. So I close that and then I just go to everybody's favorite IDE. Oh, sorry. No, that's just a text editor. Why does Eclipse suck so much on the Mac? OK, where did I put that? In the playground, where is my car pool? And when I look at this, you see this is all what it has generated into your question. So I go there, common models, and there is a car JSON. There is basically the definition of what my car model is all about. And then I can go there and could manually go, edit the ACL, edit the relations, or I can use the command line to update that. So it's all driven by models. One of the things I had to learn the hard way is, so in my mental idea it was, oh, a model is something I want to write out in a database. But then I realized, like say, I'm an avid cyclist, so I'm part of the joyriders. And so they pasted me, hey, Stefan, can you write us an application? So I had a little bit of a chat with my guys and realized the biggest problem I'm going to have is lost passwords. So I say, oh, suck it. So I had a look around. There's this nice little service around Twilio. They have an adapter for loopback. So I send them an SMS. So he says, this is my phone number. And I've just mailed him a code which he then can paste as a login, no more lost passwords. And it was just another model. So it's not things I want to save in a database, it's things I want to work with. Of course, the other point was pretty cool, is when I go and say, OK, where's my command line? Off with the ARC. I simply go and say, start my node, and it tells me, hey, your REST API is alive at this address. So that's brilliant. Double zero. This is externally reachable, yuck. So I think I put it in there already. So I go to local 3000, it only says, hey, it started. But then I go to explorer. And then I have, based on a Swagger UI, already a user element and the car model I just created. One of the nice little things is when I go in there, it has straight away all these wonderful methods generated for me without me writing one line of code. I have no idea what I need them for, but they are there. So one lesson as a young man, I learned the very, very hard way is like, if you have a car, you should have fuel inside. Unless you want to meet new people and have all sorts of fun, which I had a few times, I want to refuel it. So there is no refuel method, so I now need to go and go to this tremendous exercise to write a REST method to add refuel capabilities into my car. And the loopback framework does it in a very unique way. So of course, I'm not going to type source code here, because like I say, I'm a horrible typer. So I created a little snippet already if I can find it. Yeah, so just bear with me. So if you look at my ingenious function, you see car.refuel is function, fuel type, and then refuel with fuel type comes back now. We're not talking business logic here. I had that the whole day. I don't need that anymore. And then the funny thing is this car remote method refuel accepts a fuel type, returns a fill level, and has a description, and it reacts on the refuel URL. So I describe it here, and I need to take this code snippet. Just let me copy that a little bit. Copy. And when you look into the model, we had to look at car.json, but there's also a file car.js. And that makes part of that model that has been generated. And car.js takes my custom functions. So I go and save that there. Oops, paste that there, I want to say. Save it. And then in theory, my framework should restart. Yep. And when I go and reload my API page, then you will see down there, there is car.refuel. And I can click on this and I said, OK, this is the variable. So what fuel, premium, extra. And I said, try it out. It shows me the curl it sends out. It shows me the request URL it sends out. And I get straight away my function returned. Again, like I said, I don't need to worry about HTTP messes and all this nonsense. Now I feel like, OK, refueling is dangerous. So have you ever been in a petrol station in Malaysia? So you want to go and limit a little bit the access to that. And we're going to have a look at that in just a second how that works. OK, so, oops. So we had the, oh, no. Hey, what happened? I just reloaded the page. No big deal. That's like, say, no. That's sweet. OK. Let me try resize the page a little bit. Nope. Oh, well, wait. No, that's much better. OK, so were we there? There, components, command line. So we haven't had a look at ACL and model. We're going to do that in a second. We had a look at the UI. We had a look at this UI. We had a look at the Explorer. And this is a little bit how things work together. So you have the Swagger API specifications in the middle. You have the API Explorer. You have the models and the remote methods. And you have the Swagger Generator. If you're a big fan of, like, say, I give my front-end developer a Swagger file, you actually can just go to the loopback UI, Explorer slash Swagger.json, and you get exactly a well-formed Swagger 2.0 file. You can then hand over to a developer to play with it. OK. So what's the big deal? One of the things is, like, say, I just showed you that. It's like, say, I have the remote methods, which generate automatic rest access points for me. And then I have the faces. Instead of just having the middleware and the boot script, I have, before initialization, initialization, after initialization, all 24 of them, I have not really figured out what they're all good for. But I see a very good thing, like, say, before file access and after file access or before you save something, after save something. So you have quite a nice little control there. Authentication, that's pretty cool. So it's based on JSON web tokens. So you can say, OK, I'll let the user log in once an hour, once a year, up to you. And you can do whatever authentication mechanism you fancy if you feel, OK, I know who the user is. You just go and say, remember, that would be your user object. Create access token. How long should it live? And then you're done. Of course, the next question goes, but Stefan, shouldn't it work with Passport? Because this is how we do authentication in Node.js. And the answer is, absolutely it should. Baked into the framework is the support for Passport. No, I have gray hair. I hadn't had it before I started playing with that. So there is an example, complete with documentation for Facebook, Google, Twitter. I tried to get it to work with IBM connections that, like I said, this is where the gray hair came from. But I finally got it to work. So you can go, and that's pretty cool. You can easily build an application. One user identity in the loopback framework, and they can authenticate with any of their accounts. So they're logging with Google once, they're logging with, link the Twitter account, next time they're logging with Twitter. Which is pretty cool when you build an application that commercial users use, which might move from company to company, but their LinkedIn account stays the same. So you can capture that a little bit. And, yeah. The users using different email addresses for social logins. We don't map on the email address. We map on, I log in with this account and link it to my application account. So you have one login, and then several... Your Facebook address, your Google Plus, your GitHub address. Basically, any of the Passport methods that are there, you can apply there. Authorization, which I like quite a bit, it's like to say, okay, you have named roles, administrator, Jack of all trades, big boss, and then you have the ones that are really interesting. I said, $everyone. This method is allowed for anybody or is denied for anybody. It can say authenticated, or this one can only be called if you're not authenticated, like login. Doesn't make much sense once you are logged in. And what I like a lot there is when you look at this, so we have read, write, and execute. So read and write is for data fields. Of course, execute is for functions you have in there. And then I can say, okay, what role, what is the permission, allow or deny. And then I can go down to the level of an individual function I have defined in the model. And all this lives in the model, so you have the things nicely next to each other. And if you have enough time and patience, you could even run a report against it, the JSON file. So losing something like the, whatever, moustache or so. And then I can, so the next one is like say, what are the little details which I found quite likeable. First of all, the details I didn't like. It's a huge framework. It's nothing what you like say on Monday morning, nine o'clock you said, oh, why don't you, let me try a loop back. And then 9.30, you're up and running. It's more like 8.50 the week later. So the nice thing is like say, there is really, really tons of documentation. So they put a lot of effort in documenting all that to the extent that you have to learn how to navigate the documentation first. But the other one is like say, there's a client SDK. There's one for Android. There's one for iOS. There is an Angular SDK. Sorry, there's no React SDK. Anyway, who codes in TechSoup? Okay, that was not fair. Okay, so then the other part is like say, you've seen, I just created a car, but there was a user model showing up straight away. So there's a bunch of building models. You can extend and you can reuse easily. The other one, which I found pretty cool is like that the environment is based on overloads based on the nodes end. What? So when you look at, is that a good example? Let me have a look. Is there a good example in there? Yeah, there is actually. When you look, I have a middleware JSON and then I have a middleware.production.json. So when, finish already? Almost, okay. I'm always done. So when it loads the middleware, this is where the data source are defined. It goes and loads this one and then it looks, what's the nodes environment? And if it is production, it will then go and overload this one with a middleware production. If I have a middleware.development.json, if the nodes environment is development, so I don't need to go and change things. I simply have different files there, which then get overloaded easily. So that's pretty cool. Makes your life easier. It's also a bit harder. So you fixed it in this configuration file, but not in that one. And of course memory connector, that's pretty cool. There's a parameter set, dump it into a JSON file that you see what you actually have entered or you prep some values. When you connect to a relational database, you can say, hey, this is my Oracle. This is my SQL server. And it goes and figures out with the tables and the relations and the keys. What is your model? So you don't have to go and copy and paste. We all love that. We only copy and paste from Stack Overflow, not from databases. And then, okay, CouchDB Connector, because I love that. Questions? Clap. We locked the door. You can't go out before somebody answers. So if there are no questions, then thank you so much. Thank you.