Grails 3.1 enhances and improves the profile system introduced in Grails 3.0. One of the new profiles ease the creation and development of applications where the the front-end is an Angular JS application, and the backend is a Grails REST API.
In this session, Álvaro (member of the Grails team at OCI, Grails committer and author of several plugins) will demonstrate how to use the Angular profile to create an application using Grails 3.1, Angular JS and Spring Security REST.
The workshop is published at http://alvarosanchez.github.io/grails-angularjs-springsecurity-workshop/
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
}
19. The Angular JS Profile
• Extends the REST profile.
• Adds project setup for AngularJS.
• Code generation for AngularJS.
• Scaffolding available via plugin.
25. 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.
26. Create the project
$ grails create-app -profile angular
-features hibernate,json-views,security todo
| Application created at /tmp/todo