Skip to content

Latest commit

 

History

History
88 lines (51 loc) · 2.21 KB

demo.adoc

File metadata and controls

88 lines (51 loc) · 2.21 KB

JHipster 7 Demo Steps

The brackets at the end of each step indicate the alias’s or IntelliJ Live Templates to use. You can find the template definitions at mraible/idea-live-templates.

Create JHipster Project

  1. Create a blog directory and create a JHipster app in it

    applicationType: monolith
    name: blog
    package: org.jhipster.blog
    authenticationType: JWT
    prodDatabaseType: PostgreSQL
    languages: en,es
    testFrameworks: Cypress
  2. Start app using ./mvnw, browse through admin features

  3. Confirm everything works by running Cypress

Generate Entities

  1. Import Blog JDL from start.jhipster.tech

    jhipster jdl blog.jdl
  2. Restart application and show pre-loaded data

  3. Turn off faker in application-dev.yml and rm -rf target/h2db

  4. Create a couple of blogs and entries for admin and user

  5. Show how admin and user share data

Add Business Logic

  1. Edit BlogResource.java and change getAllBlogs() method

    return blogRepository.findByUserIsCurrentUser()
  2. Show how blog list screen limits data to current user

  3. Edit PostResource.java and change getAllPosts() [jh-findBy]

    page = postRepository.findByBlogUserLoginOrderByDateDesc(SecurityUtils.getCurrentUserLogin().orElse(null), pageable);
  4. Using your IDE, create this method in PostRepository

  5. Recompile both classes and verify entries are limited to current user

Make UI Enhancements

  1. Allow HTML in entries with [innerHTML]="post.content"

  2. Improve entry layout to look like a blog [jh-posts]

Lock it down!

  1. Add logic to BlogResource#getBlog to make sure user owns blog [jh-get]

Deploy to the Cloud

  1. Build for production

    ./mvnw -Pprod verify
  2. Fix test failures by setting a User on a blog by default

    @Autowired
    private UserRepository userRepository;
    public Blog createEntity(EntityManager em) {
        Blog blog = new Blog()
                .name(DEFAULT_NAME)
                .handle(DEFAULT_HANDLE)
                .user(userRepository.findOneByLogin("user").get());
        return blog;
    }
  3. Run build again

  4. Login to Heroku using heroku login

  5. Run jhipster heroku

  6. When process completes, run heroku open

  7. Fini!