Rapid prototyping with ionic 2 and node. js – part 1 – devdactic

Do you know how fast you can actually develop a really solid MVP prototype including a frontend and working backend these days? It’s amazing.

In this 3 part series I will share how I recently assembled a fully working prototype in only 3 days using node.js as the backend and Ionic 2 as the frontend of our MVP. Data recovery best The Plan

As all of this is only working locally, we need a way to get this out in the hands of friends and customers so inside the third part we will take care of the deployment and actually getting our work into the hands of others!

First of all make sure you have Node.js installed on your machine. Data recovery program Additional we will use a MongoDB to hold our data, so go ahead and install it as well following the instructions.

You don’t need all of these tools, but of course you need Node.js and MongoDB created to actually run our server. 7 data recovery 94fbr Starting a new Node.js Server

To start a new Node.js server you have to run only one command which will first of all create your package.json. Database languages Afterwards we install the needed npm packages and finally we add 4 files that will be filled with everything we need later.

While the npm creation runs you will get asked many questions. Database ranking Most of them can be skipped by pressing enter using the default value, but make sure to set the entry point of your app to server.js. Data recovery youtube Of course you can change it later inside the package.json, but why not do it right in the first place here.

To create a new todo, we create a new Todo object which is our mongoose scheme that we have exported. 911 database This object already has different functions, like save to write the object to the database.


Data recovery download If this operations is successful we return a success and are finished here.

To get all todos we can use the Todo schema again and call find without any specific parameters. Data recovery after factory reset Normally you could specify an object to filter here, but in our case we want all the todos inside the database. Database schema design The return and error handling is pretty much the same in all of our 3 routes.

Finally, to delete a todo we get an id through the request parameters which we use then for the findByIdAndRemove function of our TodoSchema.

That’s already everything for some very simple CRUD (well not the U but..) operations on our MongoDB, now we only need to get this server started! Starting our Node.js Server

We have created the model and the routes, but we actually need to define our server and apply some of our installed packages to make life easier.

Stuff like helmet (protects your app) and cors (you know about CORS with Ionic apps) are just really helpful and can be added within a few lines.

Finally, we establish the Mongoose connection to the database using our config.json and call use on our todo-routes so the app applies all the routes to our server. Database uml Now we can create the server and print out a log if everything was successful.

banner