I am developing a polymer component which is using firebase polymer element inside it.
I have seperate URls for firebase in staging and production, so I want to know what is the best design pattern to handle these environment urls in the polymer app.
If it's one instance, can you just change the location to your staging URL?
For something more advanced (e.g. using a mock endpoint with all instances of <firebase-element> or testing), Scott put together an example of how to use core-ajax with mock data that may be useful: https://github.com/PolymerLabs/mock-ajax.
Related
It is well known that nextjs API routes provide a straightforward solution to build your API with Next.js. and that any file inside the folder pages/api is mapped to /api/* and will be treated as an API endpoint instead of a page.
I have just one doubt: is the code within the pages/api exposed to the world? I mean, can I build some logic there that has some key that must be hidden or maybe some MySQL connection?
Whether or not /api is in any way exposed to the world I do not know for sure, but according to Next documentation, "they are server-side only bundles."
In general though, for any key/sql connection that you want to run, I would put that into an .env.local file on your machine, a file that gets git ignored and never uploaded, and if you are hosting on Vercel, then use their environmental variables to store sensitive information.
You'd find environmental variables under:
{Your Account}/{Project}/Settings/Environmental Variables
p.s. Also from Next.js docs, I think you'd find this bit on getStaticProps useful.
How does one properly modularize an Angularjs app? I have an HTML page with separate parts, which I want to have separate controllers. At the moment I have one single controller, which serves the whole page. Different parts of the HTML page share the same scope data. Could someone provide a short and neat example with multiple controllers serving parts of the same page and sharing common scope data? I'm quite new to Angular.
Many thanks.
This question is too broad to be answered fully however here is some hints :
use directive/components when you need to manipulate the DOM
Controller should have the less code possible. Put the logic/server call in a service layer.
If you need a complex navigation system with multiple controller sharing data you might want to check ui-router (https://github.com/angular-ui/ui-router). It's a state machine in which you can nested state and their associated views. The controller of child state inherits from parent state allowing sharing datas.
If not ui-router 2 way of sharing data in a controller : events ($on, $emit), storing the data shared in a service and use $watch to watch for changes.
I wanted my Grails 3.1.5 app to serve both JSON data using the *.gson format AND, for some pages/URLs I wanted to continue to use GSPs.
I built an app using the rest-api profile.
Then I copied over controllers and views from an other app that I'd built using the web-api.
In doing so, and to be consistent, I also moved index.gson to a different location.
Now I get a:
Could not resolve view with name 'index' in servlet with name 'grailsDispatcherServlet'
Started digging into the viewResolvers that are available in the 3.1.5 code base. It is possible that the rest-api profile configures a viewResolver to look for *.gson files in a certain location.
Is there anyway to configure maybe a CompositeViewResolver that looks for both the views, *.gson and *.gsps?
If so, how can I do this?
Thanks!
I've managed to resolve this issue by adding this plugin to build.gradle:
compile 'org.grails:grails-plugin-gsp'
and with both
profile 'org.grails.profiles:web'
profile 'org.grails.profiles:rest-api'
and apply plugins
apply plugin: 'org.grails.grails-web'
apply plugin: 'org.grails.grails-gsp'
apply plugin: 'org.grails.plugins.views-json'
Apparently, they remove it when you're using REST profile, to reduce overhead, as you rarely render HTML on REST service side.
I am trying to build a website with the Play framework that will need to request some directions from the google maps api.
For those requests, I need to use my google api key. Obviously, I don't want to hardcode this value for multiple reasons. Is there a specific file configuration file that is suited for this usage in the Play framework?
It sounds like you don't want to hardcode your key for security reasons - ie. you are checking into a public Github repository, in which case you have a couple of options:
I usually use an environment variable for local development:
maps.api.key=${?MAPS_API_KEY}
ie. where MAPS_API_KEY is an environment variable configured on your machine.
For production deployment I either:-
1.) Set the value dynamically at build time from a private property file. Usually my approach if using a CI tool for the build.
2.) You could also pass it in as a system variable at startup:
/path/to/yourapp/bin/yourapp -Dmaps.api.key="YOURKEY"
You will need to modify your startup script if using activator dist to create your distribution.
Does anyone know any example/tutorial of Polymer using core-ajax and ajax-form to build a CRUD application?
My main question is how to structure the app (best practices) to focus data access in "modules" (custom elements) like in Angular services.
Should I use a unique core-ajax by "module" for example and change this attributes (like url and method) in javascript or put multiple core-ajax in template? I know this is maybe a personal choice, but if an idea for this already exists I would follow it.
Thanks
The best choice is use Firebase!
http://polymer.github.io/firebase-element
Also there is the AngularJS binding for Firebase
https://www.firebase.com/docs/web/libraries/angular/quickstart.html