Giter Club home page Giter Club logo

eris's Introduction

Eris Release SonarCloud

Eris is an open source weather API to get the current weather condition across the globe.

Description

Eris is a simple Spring Boot Java API that is developed as a consolidation of the following services:

The technology stack consists of Spring Boot framework only. The free version of the service is also hosted on Heroku. Though the API can be hosted in any platform that supports Spring Boot. Feel free to fork it and create your private API.

Dependencies

The project depends on JDK 17 and Maven. Make sure to have them installed. Any other project dependencies exist in pom.xml file and once you run the project, they will be downloaded.

Development

Eris can operate in two modes:

  • Standalone: single node (default)
  • Cluster: multiple nodes registering with Consul

Standalone mode

To run the project in standalone mode just run,

$ mvn spring-boot:run

Cluster mode

To test the cluster mode, you need to have the Consul agent up and running. You can use docker-compose.yml file included in the project,

$ docker-compose -f docker-compose.yml up

After that, enable the cluster mode via exporting the following environment variable,

$ export SPRING_CLOUD_CONSUL_ENABLED=true

Lastly, run the project,

$ mvn spring-boot:run

You can monitor the Eris instance via Consul UI at http://localhost:8500/ui.

Build JAR file

If you decide to build your own Über-JAR file to deploy either locally or on a server, after cloning the project, you have to set openweathermap key and actuator.username and actuator.password. For that, modify apikey.properties and application.properties file respectively before generating the JAR file. Alternatively, you can overwrite them those variables at runtime, see Dockerfile for all variable names.

To generate the Über-JAR, run:

$ maven clean install

To test the generated JAR file,

$ cd target
$ java -jar eris-[version]-SNAPSHOT.jar

Heroku deployment

Deploy

Project & API documentation

To know more about the project structure and API documentation please refer to our Github page documentation at this link.

Contact

License

License

Eris Weather API is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

Eris Weather API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. http://www.gnu.org/licenses/

Author(s):

© 2017-2024 Kasra Madadipouya [email protected]

eris's People

Contributors

kasramp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eris's Issues

Setup Airbrake for your Java application

Step 1: Install

Install option 1: Maven

Add the javabrake dependency through your IDE or directly to your pom.xml file:

<dependency>
  <groupId>io.airbrake</groupId>
  <artifactId>javabrake</artifactId>
  <version>0.1.6</version>
</dependency>

Install option 2: Gradle

Add javabrake to your Gradle dependencies:

compile 'io.airbrake:javabrake:0.1.6'

Install option 3: Ivy

Add javabrake to your Ivy dependencies:

<dependency org='io.airbrake' name='javabrake' rev='0.1.6'>
  <artifact name='javabrake' ext='pom'></artifact>
</dependency>

Step 2: Configure

Import the javabrake library and copy the three configuration lines into your
app to send all uncaught exceptions to Airbrake:

(You can find your project API KEY with your project's settings)

// Import the library:
import io.airbrake.javabrake.Notifier;

public class ExampleApp {
  public static void main(String[] args) {

    // Copy configuration lines:
    int projectId = <Your project ID>;
    String projectKey = "<Your project API KEY>";
    Notifier notifier = new Notifier(projectId, projectKey);
  }
}

Example of reporting a caught exception:

try {
  int i = 1/0;
} catch (ArithmeticException e) {
  notifier.report(e);
}

Visit our official GitHub repo for advanced information and integrations like log4j, log4j2, and logback.

As a maintainer, I want to be able to monitor the app health

Need to use Spring Actuator to be able to access the health endpoints. However, this endpoints should be secured. A basic approach is using environment variables and then later add the part for the database if needed.
Criteria:

  • Basic auth, salted password, for /actuator.
  • Response accordingly if an unauthorized entity tried to access, instead of redirecting to the white label page.
  • Write unit tests.

Add ACL support to Consul

Follow the guide: https://developer.hashicorp.com/consul/tutorials/security/access-control-setup-production#apply-individual-tokens-to-agents

Example,

{
 "acl_master_token": "YOUR_MASTER_TOKEN",
 ... // from the doc ,
  "service": {
    "name": "eris",
   "token": "UUID"
},
"acl": {
  "enabled": true,
  "default_policy": "deny",
  "enable_token_persistence": true,
  "tokens": {
    "agent":  "AGENT_UUID"
  }
 }
}

To generate a token,

$ consul acl token create -description "Eris weather API service" -service-identity "eris" -secret "UUID"

The service identity name should match the actual service name and it's case sensitive

Remove/replace deprecated Security config properties

Some code in SecurityConfiguration is deprecated. It should be replaced:

Warning: /home/runner/work/Eris/Eris/src/main/java/com/madadipouya/eris/configuration/SecurityConfiguration.java:[35,10] httpBasic() in org.springframework.security.config.annotation.web.builders.HttpSecurity has been deprecated and marked for removal Warning: /home/runner/work/Eris/Eris/src/main/java/com/madadipouya/eris/configuration/SecurityConfiguration.java:[35,22] and() in org.springframework.security.config.annotation.SecurityConfigurerAdapter has been deprecated and marked for removal

Change pipeline workflow

Rearrange the pipeline flow as:

  • On PR, tests should automatically run and (ideally) SonarQube should run and be able to deploy the branch to the develop environment
  • On develop branch, everything should remain as is except, publishing the artifact as -beta or -develop or as draft in GitHub and then automatically deploy the work to the staging environment. It should use different API keys than production
  • On master branch, everything should remain the same and deploy to production
  • Build docker image and publish it Docker.io

Replace property utils test with a more meaningful test cases

Currently, setters in PropertyUtils.java file are used for Unit testing. A correct approach is to load the values from a test property file and then do the assertions. This means it might be a need to convert the tests to run with SpringExtension instead of MockitoExtension.

Replace Hystrix with Resilience4j

As Hystrix has been deprecated and remove from Spring Cloud, need to replace it with Resilience4j. So that spring-cloud-dependencies can be upgraded.

Allow CORS

Currently weather extension is unable to call the Eris due to CORS issue. Need to activate it.
This can be done either for a single endpoint /currentByIp or all.

Rename health user and pass

Currently the property names defined for actuator username and password are prefixed with health. Change health.{username,password} to actuator.{username,password}.

Use circuit breaker for third party integrations

Some of the third party services occasionally have outages, it will be good to use a circuit breaker and fall back to another service temporary if the default integration is inaccessible.
One example of circuit breaker is Hystrix but that's not maintained by Netflix anymore. Better to use other options.

Update the website

Update the website and add a section about how to run it using Docker as well as updating the readme file.

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.