Skip to content

Instantly share code, notes, and snippets.

View dmi3coder's full-sized avatar
🇩🇪
arbeite

Dmytro dmi3coder

🇩🇪
arbeite
  • Berlin, Germany
  • 17:54 (UTC +02:00)
View GitHub Profile
@dmi3coder
dmi3coder / TokenUtils.java
Created May 12, 2020 10:54
TokenUtils class for Quarkus token security
package tech.donau.quarkify.security;
import org.eclipse.microprofile.jwt.Claims;
import org.jose4j.jws.AlgorithmIdentifiers;
import org.jose4j.jws.JsonWebSignature;
import org.jose4j.jwt.JwtClaims;
import org.jose4j.jwt.NumericDate;
import java.io.InputStream;
import java.security.KeyFactory;
@dmi3coder
dmi3coder / GraphQlConfig.java
Created April 29, 2020 16:41
Example of GraphQL config for Quarkus
package net.quarkify;
import graphql.GraphQL;
import graphql.schema.*;
import graphql.schema.idl.*;
import io.vertx.core.Promise;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.graphql.*;
import net.quarkify.data.*;
@dmi3coder
dmi3coder / GraphQlConfig.java
Created April 29, 2020 09:21
Example of createGraphQL method in Quarkus GraphQL example
private GraphQL createGraphQL() throws Exception {
TypeDefinitionRegistry teamsSchema = getTeamSchema();
RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring()
.type("Query",
builder -> builder.dataFetcher("allTeams", new VertxDataFetcher<>(this::getAllTeams))
).build();
SchemaGenerator schemaGenerator = new SchemaGenerator();
GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(teamsSchema, runtimeWiring);
@dmi3coder
dmi3coder / Team.java
Created April 29, 2020 08:58
Data classes for Quarkus GraphQL example
package net.quarkify.data;
public class Team {
public Long id;
public String name;
public User[] users;
public Team(Long id, String name, User... users) {
this.id = id;
this.name = name;
@dmi3coder
dmi3coder / SetCommand.java
Created April 26, 2020 13:13
Example of Picocli Quarkus command that modifies db entity
package org.acme.getting.started.command;
import org.acme.getting.started.data.Setting;
import picocli.CommandLine;
import javax.enterprise.context.Dependent;
import javax.transaction.Transactional;
@Dependent
@CommandLine.Command(name = "set")
public class SetCommand implements Runnable {
@dmi3coder
dmi3coder / Setting.java
Created April 26, 2020 13:02
Example of Setting entity used in Quarkus Command mode example
package org.acme.getting.started.data;
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import javax.persistence.*;
@Entity
public class Setting extends PanacheEntityBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer id;
@dmi3coder
dmi3coder / GreetingApplication.java
Created April 26, 2020 12:04
Example of GreetingApplication with Picocli in Quarkus
package org.acme.getting.started;
import io.quarkus.runtime.*;
import io.quarkus.runtime.annotations.QuarkusMain;
import org.acme.getting.started.command.*;
import org.apache.maven.shared.utils.cli.CommandLineUtils;
import picocli.CommandLine;
import javax.inject.Inject;
@QuarkusMain
@dmi3coder
dmi3coder / GreetingCommand.java
Created April 26, 2020 11:50
Example of GreetingCommand in Quarkus Command mode
package org.acme.getting.started.command;
import org.acme.getting.started.GreetingService;
import picocli.CommandLine;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
@Dependent
@CommandLine.Command(name = "greet", mixinStandardHelpOptions = true, description = "Greet person by their name")
public class GreetingCommand implements Runnable {
@dmi3coder
dmi3coder / QuarkusCommand.java
Created April 26, 2020 11:33
Example of Root QuarkusCommand with Picocli
package org.acme.getting.started.command;
import picocli.CommandLine;
@CommandLine.Command(subcommands = {
CommandLine.HelpCommand.class
// Put here more static commands, that don't require Dependency Injection
})
public class QuarkusCommand {
}
@dmi3coder
dmi3coder / GreetingApplication.java
Created April 23, 2020 20:37
Quarkus Greeting example with Command mode and main method
package org.acme.getting.started;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import org.jboss.logging.Logger;
import javax.inject.Inject;
@QuarkusMain
public class GreetingApplication implements QuarkusApplication {