How to extend heroku-buildpack-core-data with a complete web frontend - api

I'm impressed with the Heroku recently added heroku-buildpack-core-data by #mattt (more info here) that helps a lot in building a web API for core-data backed iOS Apps. I would like to extend it to have also a web front-end. I see that it has a Sinatra+Sequel app inside.
Which is the heroku-friendly way to add this?
Do I have to fork and extend the buildpack?

You can find instructions on how to extend this functionality with Rack::CoreData on the Core Data Buildpack Repository:
The Core Data Buildpack is designed to encourage rapid prototyping, but should not be used on its own in production applications.
Rather, you are encouraged to create an application using Rack::CoreData directly, which allows you to extend the Core Data scaffolding with Rack applications, such as Rails or Sinatra, and middleware. Here's an example config.ru file:
config.ru
require 'bundler'
Bundler.require
DB = Sequel.connect(ENV['DATABASE_URL'])
run Rack::CoreData('./Example.xcdatamodeld')

Related

React Native mini-app / microapp structure

I'm trying to build a react native app which contains:
1/ A core app (which have multiple services)
2/ A mini-app to serve individual service above.
The benefit of this approach is to:
Reduce the size of the core app (which will be published on stores)
Easier to manage those services (each team will be in charge for one or two services)
Through my research, I found out that there is an app which is using this approach:
https://play.google.com/store/apps/details?id=com.mservice.momotransfer
After debugging with Charles proxy, I discover that they call an api to load a bundle (.jsbundle file for iOS platform) and then load the mini-app from this bundle.
However, I have not yet found any official documentation or tutorial for implementing this structure. I would be very thankful if you have any keywords, medium posts, example github repos about this matter.
you are finding as same mine
Look at this page https://github.com/smallnew/react-native-multibundler

How to generate swagger without writing spec files

I am looking for a gem which will generate swagger doc and showed it on the swagger UI, I came across rswag gem but it requires spec file needs to be present for generating the swagger doc
Is there any gem that will auto generate swagger doc if I put it in on the API controller?
I built an open-source tool to make this easy. Instead of integrating at the code level, the project uses a local proxy to analyze real development traffic and updates your API spec when it observes new behavior in the API. https://github.com/opticdev/optic
For Rails, the only change you have to make is to make the switch from using:
rails server
To starting your API with Optic's start command.
api start
When new API behavior is detected, you can add it to your spec using our UI. Here's an example.

Can you run an Angular Universal application without a server?

There's a feature in Angular Universal that allows you to pre-render pages at build-time. Can this be used to pre-render all your pages and run Angular Universal without a server?
Once html pages have been pre-rendered using angular universal (using nodejs server or asp.net core server), you can use any CDN to serve the pre-generated html.
See https://universal.angular.io/overview/
Edit: have a look at the starer kit
https://github.com/angular/universal-starter
Basically, you can reuse the prerender.js file which will write the rendered html files (for specified static routes) to the dist/browser folder, or wherever you want to. This is that folder that you deploy to a static host after
Well, you're always going to need to have a server somewhere in the equation: the only question is how much you have to set it up yourself versus how much can the current crop of tools and technologies do it for you.
In this talk from Node Summit Steven Fluin from Google talks about Firebase at the end. Pay attention to the bit about 'cloud functions' (at about 20 mins). Your Angular app will be rendered on the server using Firebase cloud functions. When a user interacts with your app, some JS is run to figure out what to send down (from the Firebase server) to the user. "You don't need to set up a server at all; everything is running in Firebase."
I haven't used Firebase myself - I'm using Angular Universal, which has a Node.js server as you know - but this sounds very nice. I found setting up Angular Universal really tricky (but got there in the end).

Building a Custom API on top of Parse.com?

I'm planning on building a developer API similar to what Uber and Yo have done. Is it possible to build such API if my app's backend is powered by parse.com? I don't want my custom API pointing to parse, but instead my own site.
I'm planning on using ruby, and was wondering if there would be any limitations over other options (not sure what options I have). Thanks
I'm not sure if it is possible using ruby, but I know it's definitely possible to build your own REST API.
We have decided to go a bit further and wrote a parse-angular seed project for developing web apps. It can be found here.
After you pulled it, do a npm install
As usual,
cloud code should go into cloud/main.js
express code: cloud/app.js
angular code: cloud/public/js/
Note that: You will need to change your AppId and AppKey in
config/global.json
cloud/public/js/app.js
As for custom apis, you can define your own in cloud/routes/api.js.
At this point you should have a nice parse-angular project set up and good to go.
If there's anything wrong, please feel free to open a pull request. :)

MVC4 Web API for web development and possibly mobile

I really like the new feature, Web API that's released with MVC4.
I'm currently working on a web application, that I will want to extend it to a mobile application.
What would be the best way of utilizing this feature?
Program it like there's no Web API, and when i'm ready to develop for a mobile application, then use this feature (Copy and paste controller functions then edit the return and error handling value ?
Or should I use Web API from the beginning of the web development. Using javascript to call functions and to handle errros? The problem with this apporach is I'm not too familiar with JS, and the code would not look very clean (the Views)
Any opinion?
Thanks
IMHO the Web API shouldn't be seen as a feature specific to mobile application development. It's a tool allowing you to easily expose RESTful APIs over HTTP. Those APIs could be consumed from desktop applications, web applications, mobile applications, etc ... The interface for each type of application will of course be developed using the specific frameworks and tools for this task (WPF, ASP.NET/MVC, WP7/iOS/Android, ...).
The Web API just allows you to expose your business data and services in an interoperable way so that different clients could consume them.
I would prefer using the second approach.
In the beginning, I also thought the .ajax calls might mess up the Views. (No one likes to add a long <script> section in a View.) But after asking my questions on Stackoverflow, I am glad to find some experts here using some "code-behind" for those javascript.
The practice is:
Create a separate JS folder to store all the "code-behind" js files. (The default Scripts folder only contains the third-party packages like knockout.js, jquery.js and etc)
For each view, generate a .js file, like home.index.js, form.add.js, etc. Just follow a consistent rule. There will be a lot of js files created. The great thing is in MVC4, we can combine all .js files under this folder and generate a minified, combined, single file, and load it only once in the _Layout view.
The way to do it is:
In _Layout view, <head> section:
<script src="#System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/JavaScripts/js")" type="text/javascript"></script>
In Global.asax, Application_Start, register the bundle:
var bundle = new Bundle("~/JavaScripts/js", new JsMinify());
bundle.AddDirectory("~/JavaScripts", "*.js", true);
BundleTable.Bundles.Add(bundle);
BundleTable.Bundles.EnableDefaultBundles();
//BundleTable.Bundles.RegisterTemplateBundles();
Then you are good to go. The Views are still clean. All the .js files are organized. And no need to import different .js file on each individual view.
Leaning JS is not a problem. As it is probably the only client-side programming language, it is now becoming necessary for us to learn new things. And I feel it is easier since we have jQuery now. It is time to upgrade our knowledge. I am happy and excited about what we can accomplish with these new tools.