Deploying Node Js application with express framework in Supabase (Edge Functions) - node.js

I developed a node Js application integrated with some services like database, authentication from Supabase, It works fine and gave success results in local development for each routes when called from Postman. Now I want to deploy this application to make rest APIs for frontend. Supabase provides edge-functions. In their documentation they told it is an alternative for firebase functions. But I can't able to find any documentation or blog regarding deployment of node Js application. Is there any way to deploy this application like firebase functions on edge functions of Supabase Any clarification related docs or alternative solutions would be helpful.

Supabase edge functions run Deno application at the moment, which is a bit different from a node.js application, so your node.js application will not deploy directly to Supabase edge functions. You would have to rewrite your code to make it compatible with a Deno application.
Luckily, since typescript, the language used in Deno functions is a superset of javascript, so you should be able to reuse a lot of the code during the rewrite!

Related

Can i create an app with React-native, firebase, and node js?

So i would like to have a react-native app and use all the cool features from firebase. Since I'm fairly new to firebase though, I'm curious if and how I could possibly install a nodejs environment -which should be hosted by firebase- to add some Api features. Thanks in advance
Firebase itself will not execute your Node.js code, but it has integrations with Cloud Functions and Cloud Run, which can be used precisely for that.
I recommend having a look at the documentation, specifically the pages on serving dynamic content and host microservices using Firebase Hosting.

Should I build server-side of application inside nuxt.js server directory?

I want to build full-stack application with Nuxt.js. I am wondering where I should create my server-side inside Nuxt.js or maybe I should create separated project only for server stuff.
I am trying to set up my project but I do not know how I should do it. The application which I am building will have own front-end, back-end and also database (I will use MongoDB) but actually I do not know how I should start. I was reading a lot about SSR and Nuxt.js seems really good if am planing to use Vue.js on fronted. While creating nuxt app I can choose to use Express and then I can see server directory inside my directory structure does it mean that i should build all back-end inside this directory or maybe it is only for small stuff?
I have also another question what if I want to use Nest.js on back-end can i just use npm i -g #nestjs/cli and then nest new project-name inside my server directory ? I was looking also for this answer but almost all results in google for this type are about (comparison between Nuxt.js, Next.js and Nest.js).
It will be my first bigger full-stack project and I want to do it right but I am a really beginner in this so I am looking for answer from more experienced programmers.
You can run express or any node.js server you want inside Nuxt.js. When installing Nuxt.js with scaffolding tool create-nuxt-app, you can choose integrated server-side frameworks : Express, Koa, Hapi, Feathers, Micro, Fastify, Adonis (WIP). There isn't offical Nest.js integration, but you can easily find a starter kit on github.
With create-nuxt-app, if you choose to use any node.js server inside your nuxt app, you will see a server directory inside your directory structure, with the corresponding server-side pre-configured index.js file.
Here is my own feeling about it:
I think the inside solution make sense for a small SPA or Headless project (Ex: parse and serve files, a simple JWT Authentification, a small websocket server...), or for a front-end logic application that cannot fit in client browser and who are nothing to do with the database (like image or file computation).
But generally, this server run the database layer for your Nuxt application: a REST or GraphQL API. It can also run your business logic of your app, serve authentification, and more and more when project growth...
If you think about separation of concerns and microservices
architecture, do not use server inside Nuxt.js. Splitting both frontend and server will result more flexibility. You can host frontend and API in different servers.
So now, do nuxt.js really need a node.js server ?
Yes if you plan to use it in SSR mode, No if you plan to use it like a SPA or Static generated way. Docs here... .
In SSR mode, nuxt.js ask data to your API at the first rendering, and provide a complete SEO compatible page to the client browser or bots. It also provide all javascript that the browser need to navigate and fetch your API. For that, nuxt.js in SSR mode should run with node.js.
I assume you said "back-end" for your API and your business logic application, in this case, you should separate nuxt.js and your server. Two node.js instances to run both.

possibility of using NodeJs server-side codes in mobile application?

Is that possible to use NodeJs server-side codes in react native,ionic,cordova or native script for mobile applications?
Question update:
I want to use NodeJs package and include NodeJs package into mobile application (native script , ionic , cordova or react native). for example include instagram-private-api into native script : NodeJs Private instagram API
{N} !== Browser / NodeJS.
It's a pure JS runtime, any apis specific to these platforms won't work within {N}. Though nativescript-nodeify plugin on-boards very limited NodeJS apis by translating them to their native equivalents.
I've been using many node.js APIs (including google/baidu/bing/wikipedia) inside my cordova App, here's what I did:
Install node.js / express / socket.io in your linux server.
Use socket.io inside your Cordova app to create 'many clients to one server' connections between your app and the node.js/socket.io server. In https://socket.io there is a simple example teaching you how to do that.
In Cordova App, use something like socket.emit('FromClientToServerCallAPI', data) to call an api.
In node.js server, define a function:
socket.on('FromClientToServerCallAPI', data)
and inside this function, call your api, and after you got the result from the api provider, run:
socket.emit('FromServerToClientAPIResult', result)
In your Cordova App, define a function:
socket.on('FromServerToClientAPIResult', result)
then do somthing with 'result'
pls. note that all the functions above are async.
Never try to call the api directly in your client codes, Some api provider requires you to apply for the api service and give you a 'key' to use the api, you don't want to put this 'key' inside your javacript and disclose it to all your users of the App, right?
Yes, it is possible with nodejs-mobile. It lets you run a full-blown Node.js engine inside a mobile application. It works on Android and iOS. There are other solutions that work on Android but as far as I know nodejs-mobile is currently the only one that also supports iOS. It also comes with plugins for React Native and Cordova.
More information, including documentation, is available on the project website.
(Full disclosure: I work for the company that develops nodejs-mobile.)

Typescript + Node + Express?

After stumbling upon the typscript-node starter released by microsoft, i started to get lost.
Can we really replace node with typescript on the server? There are several serverside things that TS does well:
- Creating a web API service with express
- Managing the CRUD queries with mongoDB
And much more...
I am used to generate an api with node and connect angular to that api. Am i wrong?
Should we switch to TS on the backend and forget about writing node code on the server?
Typescript is a (or rather, a superset of) language - not a runtime. It is the equivalent of Javascript except it needs to be compiled to run on the Node.js runtime.
You can write the backend with Typescript if you want, and then run it through ts-node, or just compile down to ES6 via tsc and then run it with standard Node (v8+ is recommended). This is what I do with many projects. It is still "node code", it just has all the benefits (and gimmicks) or Typescript.
I recommend the library meseret to manage your typescript node.js backend code. It has support for Koa, Mongoose and Socket.io, with many builtin configurations. It is a great way to manage things in one place, using TypeScript throughout your project.

Integrate Node.js with Angular 2 application

I am creating an angular 2 project which will use Node.Js as backEnd and Node.Js will make calls to 3rd party external APIS(Like Gandi) which accept calls only from Python, PHP or Node.Js.
I have chosen Node.Js.
I have called few APIs from Angular 2 services using HTTP protocol. Now I do not know where to write this Node.Js code and how to Integrate this Node.Js code with Angular 2 services.
I think, Just a sample application or sample architecture which is a combination of Node.Js and Angular 2 will help a lot.
Do I need to create Restful services using Node.Js?
If Yes, Do I need to use Express.Js also for server purpose?
Note: I do not want a Mean Stack application(No Mongo DB)
Actually it's pretty straightforward.
What I'd do is to simply consider the Angular 2 app on the frontend and the Node.Js API on the backend as independent projects. It's very likely that they will run on different providers (eg. Firebase for Angular 2 app and Heroku for the Node.js server) so it makes sense to handle them as 2 different projects with it's unique dependencies.
I have recently done a similar project, using Angular 2 + webpack as frontend and Django on the backend: https://github.com/damnko/angular2-django-movies
Hope this makes sense, otherwise please let me know
i think this repo will serve your purpose.
https://github.com/singh15/feed-server
which is using twitter api to get data and send that data to any front-end.

Resources