12/7/2023 0 Comments Loopback javascript![]() ![]() We realized that creating a parallel LoopBack 4 JavaScript framework would be lot of work in terms of development and maintenace. Replicating this capability in JavaScript is the biggest hurdle in creating the JavaScript API for LoopBack 4. The TypeScript LoopBack 4 API has a very neat and intuitve developer experience when it comes to customization and extension because of the in-built dependecny injection capability. Models are defined using a JSON files, instead of JavaScript classes. Routes are limited to simple responses and has no access to the LoopBack request object, which contains a lot of additional information.Ĭontroller methods are hard-coded in the helper library and leave no room for customization. This will be possible when decorators for ES6 classes becomes a JavaScript feature. Making this possible is not easy, since we have to come up with a good interface and developer experience for dependency injection. Ideally, we should be able to use classes like in TypeScript. The class factory pattern is not idiomatic ES6. The proof of concept listed above demonstrates how writing LoopBack 4 applications in JavaScript would enable all the above features.Ībility to create application class in JavaScript.Ībility to create custom sequence in JavaScript.Ībility to create CRUD controller in JavaScript.Ībility to create custom controller in JavaScript.Ībility to create datasource in JavaScript.Ībility to create repository in JavaScript.Īlthough it allows the creation of some simple apps, it is pretty limited and inflexible in what it can do. The application also supports the ability to create custom routes to define non-REST enpoints. The application class which brings all of these together.A repository to link the model to the datasource. ![]() A sequence to customize and contain the request-response process.Our FindingsĪ typical LoopBack 4 app is composed of several elements: You can take a look at a proof of concept LoopBack 4 app which uses the JavaScript API we have experimented with. We worked on a spike to enable LoopBack 4 development using JavaScript. This blog post is about what we did in that regard and what we will be doing next. We didn’t want to leave our JavaScript users behind and decided to explore the possibilities of creating a JavaScript interface to LoopBack 4. However, some developers are constrained to use plain JavaScript at the moment for various reasons. We believe that TypeScript is the right move and it will help you and us in the long run. TypeScript features made it easy for us to build dependency injection in the framework and leverage it for controllers, models, and other constructs using TypeScript decorators. ![]() We chose to write LoopBack 4 to make it more extensible, scalable, and sustainable. Its latest version (4) is written in TypeScript, while the older version were written in JavaScript. LoopBack is a popular open source Node.js framework. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |