Grails 3.1 mejora el sistema de profiles introducido en Grails 3.0. Uno de los nuevos profiles facilita la creación y el desarrollo de aplicaciones donde el front-end es una aplicación Angular JS, y el backend un API REST hecho con Grails.
En este taller, Álvaro (miembro del equipo de Grails en OCI, comitter de Grails y autor de varios plugins) los asistentes podrán crear paso a paso una aplicación usando Grails 3.1, Angular JS y Spring Security REST.
El workshop está publicado en http://alvarosanchez.github.io/grails-angularjs-springsecurity-workshop/. Si quieres asistir al taller, deberías tener instalado previamente lo siguiente:
JDK 7 or 8.
Git.
Gradle 2.9+.
Grails 3.1.6.
7. The REST Profile
• Targeted at building REST applications.
• REST Specific plugins and commands.
• No GSP, asset pipeline, UI plugins.
• JSON / Markup views instead.
8. The REST Profile
• Profile specific commands:
• create-domain-resource - creates an
@Resource domain
• create-restful-controller - creates a
RestfulController
9. The REST Profile
• Statically compiled, extensible JSON views:
json.person {
name "bob"
}
{"person":{"name":"bob"}}
10. Create the project
$ grails create-app -profile rest-api
-features hibernate5,json-views todo
| Application created at /tmp/todo
11. Create a domain resource
$ grails create-domain-resource todo
| Created grails-app/domain/todo/Todo.groovy
| Created src/test/groovy/todo/TodoSpec.groovy
12. REST Domain class
package com.example
import grails.rest.Resource
@Resource(uri = '/todos')
class Todo {
String description
boolean completed
}
13. Create a restful controller
$ grails create-restful-controller todo.Todo
| Created grails-app/controllers/todo/TodoController.groovy
18. The Angular JS Profile
• Extends the REST profile.
• Adds project setup for AngularJS.
• Code generation for AngularJS.
• Scaffolding available via plugin.
24. Spring Security REST
• Compatibility layer over Spring Security Core.
• Login and logout REST endpoints.
• Token validation filter.
• Stateless by default, with JWT (signed and encrypted)
• Memcached, Redis, GORM and Grails Cache token storages.
• Implicit grant support through 3rd party providers.
• RFC 6750 Bearer Token support.
25. Create the project
$ grails create-app -profile angular
-features hibernate,json-views,security todo
| Application created at /tmp/todo