Git Product home page Git Product logo

hawapi's Introduction

Introduction

The HawAPI is a Free and Open Source API for Stranger Things show.

All this information is available through a RESTful API implemented with Java (Spring Boot) + PostgreSQL and served via JSON and allows developers to create desktop, web and mobile applications using this data very easy.

Getting Started

Internationalization Support

Scope en-US pt-BR fr-FR es-ES
Actors -- -- -- --
Characters -- -- -- --
Episodes Yes Yes Soon Soon
Games Yes Yes Soon Soon
Locations Yes Yes Soon Soon
Seasons Yes Yes Soon Soon
Soundtracks -- -- -- --

Contributing

You could help continuing its development by:

  • Contribute to the source code
  • Suggest new features and report issues

Contact

For any questions about the project, please reach out via:

Code of conduct

We will behave ourselves if you behave yourselves. For more details see our Code of conduct.

License

HawAPI is licensed under the MIT License.

Check out all licenses/dependencies

hawapi's People

Contributors

dependabot[bot] avatar lucjosin avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

itpreneur

hawapi's Issues

Setup static redirection

Description

Spring doesn't recognize index files.

  • /docs/ -> /docs/index.html

E.g:

@Configuration
public class EndpointConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // Docs
        registry.addViewController("/docs").setViewName("redirect:/docs/");
        registry.addViewController("/docs/").setViewName("forward:/docs/index.html");

        // Try it
        registry.addViewController("/try-it").setViewName("redirect:/try-it/");
        registry.addViewController("/try-it/").setViewName("forward:/try-it/index.html");
    }
}

Fix error when using pagination

Description

Ref: Branch: feat/i18n-and-filtering

Hibernate will block the usage of pagination (page and size) when using join.

HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!

Workarond

For now, pagination will only work if no filter is specified and language param is set to *.

/api/v1/actors?language=*&page=1&size=1

Ref

Update swagger documentation

Description

Use annotations to create a better swagger api documentation.

  • ApiParam
  • ApiOperation
  • ApiResponses
  • ApiResponse
  • ApiModelProperty

Update `SpecificationBuilder` with new methods/doc

Description

After PR #48, not all models will have a translation param.

// All models will have the 'static' and 'translation' tables and all related fields.
// Filters will contain all fields from 'static' AND 'translation'.
//
// Calling 'root.get' using a non-existing 'fieldName' will throw 'IllegalArgumentException'.
// If this happens, try to get from 'translation' table.

Avoid calling database even when `uuids` are empty

Description

An GET request will call the method findAll from controller and findAllUUIDs from service. If the return of uuids are empty we still calling findAll from service.

Solution

Check if uuids are empty, if true, early return empty list.

  if (uuids.isEmpty()) {
      return ResponseEntity.ok().headers(headers).body(Collections.emptyList());
  }

@GetMapping
public ResponseEntity<List<ActorDTO>> findAll(Map<String, String> filters, Pageable pageable) {
filters.putIfAbsent("language", responseUtils.getDefaultLanguage());
Page<UUID> uuids = service.findAllUUIDs(pageable);
HttpHeaders headers = responseUtils.getHeaders(
filters.get("language"),
uuids,
pageable,
uuids.getSize()
);
List<ActorDTO> res = service.findAll(filters, uuids.getContent());
return ResponseEntity.ok().headers(headers).body(res);
}

Fix AuthService account creation

Description

Currently we only check for ADMIN role, if send a POST with "role": "DEV" will successfully create the account.

if (user.getRole() != null) {
if (!RoleType.isValid(user.getRole())) {
throw new RoleBadRequestException("Role '" + user.getRole() + "' is not valid!");
}
// Only 'ADMIN' can create users with 'ADMIN' role.
if (user.getRole().equals(RoleType.ADMIN.name())) {
if (!hasAdminAuthorization()) {
throw new UserUnauthorizedException("Only user with ADMIN role can create ADMIN users");
}
}
} else {
user.setRole(RoleType.BASIC.name());
}

Add `random` endpoints

Description

  • ?language=<string> (only a few endpoints)

E.g:

Specific endpoint (Normal)

<URL>/api/v1/actors/random

Specific endpoint (With translation)

<URL>/api/v1/episodes/random
<URL>/api/v1/episodes/<UUID>/translations/random

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.