How to add a REST API to the Modern Web Dev Server? - javascript

I'm using the dev-server of Modern Web to build client side code.
Now I want to add a small backend with a REST API, but I can't find any information of how to add a backend with a REST API to this server.
Any hints on where to start?

You could write a plugin for it but I wouldn't recommend it.
It's a development server designed for testing client-side code.
It isn't designed to be a production server, and if you are going to write a REST API then you will, presumably, want it to be usable in a production environment.
Build your API with a tool designed for it (such as Express.js or Spring Boot) and use CORS to make it accessible to the server you use for client-side development.

Related

What is the web server of Meteor JS?

I don't really understand what is the name of the web server from meteor.js.
Because in PHP for example, by default, we are using ngix (or apache).
In python, we are using werkzeug (it's not really a web server in this case, but a library but the objective is similar).
In rails, we are using by default Puma.
But impossible to know what we're using in Meteor. We don't have a specific web server ? we are only using Meteor ?
I know the fact that meteor is a client/server framework built on top of nodejs (on the server side), but i don't find more precise detail about the name or the type of web server.
Node can serve up HTML pages, so unless you have some other situation going, it's the web server.
https://www.digitalocean.com/community/tutorials/how-to-create-a-web-server-in-node-js-with-the-http-module

Suggestion: Single Page application architecture issue

I have written a web app (Single Page application) which has only frontend technologies involved (Vuejs) and when I compile it, it will ultimately generate web pages (only HTML and JS). I can run this app anywhere by opening the index page.I am consuming REST API powered by oAuth on this SPA (making direct Ajax call to REST API endpoints).
But the problem is, My lead developer is saying the SPA must be powered by back-end service (Server) for example nodejs, apache. And the backend should make call to the REST APIs not directly Ajax calls from the browser (Frontend JS ajax). My SPA app runs anywhere and works perfectly on browsers even without any server.
My question is, do I really need to render and run my SPA using webserver, whats the reasons behind making my SPA (Plain html, js) app server powered??
Also please suggest me, if people simply write app using JS and HTML (pure front end) and upload on the server and point a domain name to that html-js web app which will be consuming remote REST APIs.
Thank you for making my doubts clear in advance.
I have remote REST API provider, suggest me best way to write an SPA to consume that remote APIs.
There may be some reasons to setup a back-end service, for example:
Hide REST API endpoints
Setup your own caching / throttling / failovers etc. to REST API endpoints
Override / control REST API responses / requests
Still, you can use only pure html+js SPA, but adding back-end service gives you additional options, not possible to achieve on front-end.

how can i access mail from a microsoft exchange server using javascript?

I am trying to build a desktop app using electron that retrieves mail from a specific mailbox (microsoft exchange server), now, i have looked around and read that mailbox connection should be done server side (the question was made by a guy building a web based app that is a little bit similar to what i want to do), but, since i am not really deploying a node js server but rather using electron, which, as far as i understand is like a desktop app version of node, im not sure on which approach to take. Should i use an api? does microsoft has any interface for this? or should i use a third party integration for it?
It looks like the Exchange Web Services API is only provided as a CLR assembly, so if you wanted to use it you'd need to:
write a C# console app that you then spawn from your Electron app
(and communicate via stdin/stdout), or
use the EWS API in your Electron app via Edge.js
Alternatively, you could probably just directly communicate with the exchange server using SOAP messages, but that could be a bit tedious to implement.

Node JS Http Server Production Ready

I am building a simple web service using node js, I only use the built in web server feature using:
var server = http.createServer(handleRequest);
I added a caching mechanism using node-cache, but that's it, I run the script via PM2 to make sure it's always running. Is this a safe and good practice to do? I saw some posts mentioning using nginx as reverse proxy server, won't that add an extra step that will slow things down?
Thanks!
It's recomended to use nginx as a frontier in production for secure reasons, load balancing, static content output and administration issues. In some cases it could be used for API versioning.

Using Gigya API with node.js

For one of my projects I'd like to try out Gigya as my social network connection provider and am writing my app using Node.js. Has anyone done this?
Gigya provides a JavaScript API that is intended to be used on the client.
http://developers.gigya.com/020_Client_API
It should be possible to adapt that for server side use.
Gigya's client side javascript is intended to be run in the browser as much as possible, since they perform 2 part authentication using cookies set by their domains. You can try to port it to run server side, but none of the public methods will work as advertised.
I've written a wrapper for their REST API using their proprietary authentication that I've been using in a work project for a few weeks: https://github.com/jproulx/Gigya-Node-SDK -- note that not everything has been tested thoroughly as I've only needed to use a subset of the socialize services on the server side. It should serve as a good jumping off point to bootstrap something for your needs.
Gigya does not yet have an official Node SDK. However, I've written an SDK that implements the entire service.
In addition to the standard APIs, it contains special support for streaming data from Accounts & DS.
Git: https://github.com/scotthovestadt/node-gigya
Install with "npm install gigya".

Categories