I have my angular universal app running well. But few of the libraries which I use, internally uses localStorage to set and get data. I can neither omit the libraries nor change it. Being said that, is there a workaround where I can use localStorage in server side.
Try to use
node-localstorage npm module to use localStorage at the nodejs server side.
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.
I need a library that is able to simulate a browser (in that it persists cookies and session id values as a browser would) while simultaneously giving me access to the JSON strings the server returns. I need it to ignore redirects and such as well.
Is there such a tool that would allow me to use node.js and Jasmine for testing a pseudo-RESTful api?
Note: I am migrating an ancient api written in Zend 1.8 to a new api that conforms more to RESTful practices, but in doing so, I must ensure that the new api is not so different from the old that it simply does not function.
You can use Postman, this is a chrome plugin.
Postman Chrome Plugin
If you do not need to deal with the GUI side of things, simple command line curl should work. It can use cookies, take text input via command line, return the results from the server as simple text.
You do say in your question test using node.js... not sure why you would feel that you 'have' to use that to test your api.
You can use Jmeter which is open source and has user friendly GUI. You do not need any special tools.
http://jmeter-plugins.org/wiki/RESTSampler/
I am creating an Android App using MvvmCross.
Before calling some service,I want my MvxActivity should first check app's isolated
storage whether that data is present in its isolatedStorage, if it is then it should
populate its UI controls(eg. ListView,Spinner etc.)by fetching data from
isojatedstorage otherwise call service and then populate them using data received from service.
How can i achieve this?
You can use File plugin for MvvmCross
https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#file
Another option is to use that plugin for Android (i didnt dig to deep inside), but for Windows Phone i had used this solution for downloading/storing images and here is my own lib for storing any text data in the isostorage (serialization/deserailzation is included).
I use PCLStorage, it's cross platform. Just search for it on NuGet.
I would like to call node.js scripts like i do with php, that is simply using their url.
I'm mainly a js programmer, so it would be wonderful for me to ditch out php totally and use node for the server side scripting.
But most of the tutorial i saw until now involved creating a server, etc...
I just want to call a script in the old way, like www.mysite.com/login.js instead of www.mysite.com/login.php
And once called the script should return or a page for rendering or simply json or other text for ajax calls.
Is it possible?
There's another possibility, similar to the CGI method mentioned above but using a module (https://github.com/samcday/node-fastcgi-application) in Node.js that supports FastCGI which would allow Apache to talk to it.
It actually blends both styles, so that the Node program is launched automatically by Apache but stays around as long as there are requests to process. You simply set up a rule to redirect the pages you want to a dispatch.njs script, which you have added with AddType in .htaccess as a Node script, which launches and then handles requests on the stdin and sends the results to stdout. But you still need the routing provided by express because it's only looking at HTTP_REQUEST_URI to determine what page you want.
Another option would be to setup Node listening on a certain port and proxy requests to it from Apache if they match a certain signature (like ends in .njs).
But most of the tutorial i saw until now involved creating a server, etc...
I just want to call a script in the old way, like www.mysite.com/login.js instead of www.mysite.com/login.php
That's how node.js works. You create a server. With PHP the first step of a tutorial is to install and setup apache (creating the server).
The equivelant of your question in PHP terms would be
Can I run PHP scripts without installing apache/nginx/other webserver
Which you can't (I believe recent or future version include a web server baked in, just like node.js !)
You need to install node.js, you need to tell node to run a web server
However you can use expressjs for a more streamlined and familiar setup. You can then just call express on the command line to scaffold your server out.
You still have to install node.js (and npm)
Node.js and PHP are two different things.
Node.js is an "event-driven I/O server-side JavaScript environment". When it functions, Javascript is not run as a scripting language, it is processed just like Ruby or Python. You start a server, and the code is run.
PHP, however, is run as a scripting language on a webserver, because the web server has a PHP processor module installed on it. Therefore, you can run PHP scripts directly by the .php extension, because the Apache server is configured to interpret .php files as scripts.
In other words, what you'd like to do is not possible without a large amount of hacky tricks, with node.js.
However, if you'd like to just use JavaScript instead of PHP, I'd check out JS-CGI, which allows you to use Javascript as a CGI extension.
You could use CGI. Something like this:
#!/usr/local/bin/node
var sys=require("sys");
sys.puts("Content-type: text/html\n");
sys.puts("Hello World!<br/>\n");
var argstr="";
for(var i in process.env){
argstr+=i+": " + process.env[i] + "<br/>\n";
}
sys.puts("args: "+ argstr +"<br/>\n");
Just like Perl/Python/../..
I'm writing what is essentially a browser in Adobe AIR (ActionScript, not AJAX). A great bit of functionality to implement would be protocol handling. iTunes, for instance, handles itms protocols; when your friend sends you a link beginning with "itms://", it's going to launch iTunes as long as it's installed. Is there a way to write an AIR app (requiring AIR 2 would be fine) that can be the "handler" for a protocol in this way?
There is no way, programatically speaking, to specifically handle a particular protocol. However, there is InvokeEvent. InvokeEvent will be fired when the application is "invoked", either when it's explictly launched or if an associated file or URL is activated.
The process of associating your app with a particular file type or protocol scheme is separate and application-dependant. In iOS, for example, you would need to specify the protocol in Info.plist under CFBundleURLTypes/CFBundleURLSchemes.
Yes. You can use the URLLoader class to download data in binary form (URLLoader.BINARY) and then parse this as appropriate. See this CS3 documentation on working with external data.
http://www.patrick-heinzelmann.de/labs/lastfm/
I'm not sure exactly how it works and I don't see a way to download the app, so I can't even test it, but maybe it will help...
Check out this page. I am trying to find out the same thing, but I haven't found any solution to do it with just Air yet. Seems like you might need a custom installer to setup the correct registry entries, and a proxy application to "wash" the input to a correct format that then can start your application with the correct command line parameters. Hope this can be of any assistance.