paint-brush
A Todo MVC Application using Iris and Vue.jsby@kataras
7,617 reads
7,617 reads

A Todo MVC Application using Iris and Vue.js

by Gerasimos MaropoulosDecember 31st, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Write a fast and modern mini todo application using Iris MVC and Vue.js

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - A Todo MVC Application using Iris and Vue.js
Gerasimos Maropoulos HackerNoon profile picture

Write a fast and modern mini todo application using Iris MVC and Vue.js

Vue.js is a front-end framework for building web applications using javascript. It has a blazing fast Virtual DOM renderer.

Iris is a back-end framework for building web applications using The Go Programming Language (disclaimer: author here). It’s one of the fastest and featured web frameworks out there. We wanna use this to serve our “todo service”.

The Tools

Programming Languages are just tools for us, but we need a safe, fast and “cross-platform” programming language to power our service.

Go is a rapidly growing open source programming language designed for building simple, fast, and reliable software. Take a look here which great companies use Go to power their services.

Install the Go Programming Language

Maybe Windows or Mac OS X user?

The article does not contain an introduction to the language itself, if you’re a newcomer I recommend you to bookmark this article, learn the language’s fundamentals and come back later on.

The Dependencies

Many articles have been written, in the past, that lead developers not to use a web framework because they are useless and “bad”. I have to tell you that there is no such thing, it always depends on the (web) framework that you’re going to use. At production environment, we don’t have the time or the experience to code everything that we wanna use in the applications, and if we could are we sure that we can do better and safely than others? In short term: Good frameworks are helpful tools for any developer, company or startup and “bad” frameworks are waste of time, crystal clear.

You’ll need two dependencies:

  1. Vue.js, for our client-side requirements. Download it from here, latest v2.
  2. The Iris Web Framework, for our server-side requirements. Can be found here, latest v10.

If you have Go already installed then just execute go get -u github.com/kataras/iristo install the Iris Web Framework.

Start

If we are all in the same page, it’s time to learn how we can create a live todo application that will be easy to deploy and extend even more!

We’re going to use a vue.js todo application which uses browser’s local storage and doesn’t have any user-specified features like live sync between browser’s tabs, you can find the original version inside the vue’s docs.

  • web/public/js/app.js
  • web/public/index.html
  • todo/item.go
  • todo/service.go
  • web/controllers/todo_controller.go
  • web/main.go

Read the comments in the source code, they may be very helpful

The client-side (vue.js)

Let’s add our view, the html.

The server-side (iris)

Our view model.

Our service.

We are going to use some of the MVC functionalities of the iris web framework here but you can do the same with the standard API as well.

And finally our main application’s endpoind.

Run the Iris web server you’ve just created by executing go run main.go from your current path (%GOPATH%/src/%your_folder%/web/).




$ go run main.goNow listening on: http://localhost:8080Application Started. Press CTRL+C to shut down._

Open one or more browser tabs at: http://localhost:8080 and have fun!

Download the Source Code

The whole project, all the files you saw in this article are located at: https://github.com/kataras/iris/tree/master/_examples/tutorial/vuejs-todo-mvc

References

https://vuejs.org/v2/examples/todomvc.html (using browser’s local storage)

https://github.com/kataras/iris/tree/master/_examples/mvc (mvc examples and features overview repository)

Thank you, once again

Happy new year and thank you for your pattience, once again:) Don’t hesitate to post any questions and provide feedback(I’m very active dev therefore you will be heard here!)

Don’t forget to check out my medium profile and twitter as well, I’m posting some (useful) stuff there too:)