How to interact Ionic framework with server side interactions like we do it in MEAN stack app


#1

Hello Ionic framework developers and professionals. I am building an application where I am creating online quizzes for school children and therefore I am making the teachers to add the quizzes in the application, so my application needs authentication and database interaction. I am planning to make it happen with restful api, and this is all of the plan in brief.

I used to write server.js file at the main directory of the MEAN stack application, now I am making the hybrid app and on ionic framework. I run $ ionic serve to start the dev server of the app, this is okay with the client side stuff.

But while doing the database interactions I need to deal with server.js and various modules involving in the app. So where I write the server side code for my project in ionic framework ,

Do I need to make another angular module that does this work, (possible)

But I want to go with the MEAN structure and therefore created server.js now how to make ionic serve recognize my server.js file as well.


#2

I think MEAN.JS is for webApps and not for mobile apps.

And if it would possible to put server code on a mobile device -> you need everything there like node, mongodb, mongodb driver and so on.

And btw… nobody wants his server code to be readable and accessable in public… (if you put it in your app - apks, ipas … it is easy to read your code :slight_smile: ).

I think if you want really something interactive you need to read about websockets.
For NodeJS server there is one big framework called Socket.io http://socket.io/


#3

I deployed my MEAN part to heroku which only have admin/CMS part of the app + REST api. And ionic is separate repository which just access that REST api to fetch data…


#4

alright @yurinondual so you are keeping server and client files apart. I got you thanks for resolving my issue.


#5

thanks @bengtler for the reply I will look at the socket.io if I will get time I will try to use this in my application tech stack.


#6

How do you handle Authentication?


#7

Using Express, oAuth2 and JWT


#8

Would you have a Repo of the work by any chance? Im looking to setup something similar.