Skip to content

Make.org main API, mirrored from https://gitlab.com/makeorg/platform/core-api If you want to contribute, please do so on the gitlab repository.

License

Notifications You must be signed in to change notification settings

makeorg/main-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build status coverage report

Setting up the dev environment with IntelliJ Idea

  • Install the scalafmt IntelliJ plugin
  • Install the scala IntelliJ plugin
  • Check sbt shell - use for: build in Build > Build tools > sbt settings

Setting up the dev environment with Code

Installing Metals

  • Install code (yaourt -S code)
  • Install the Metals extension
  • Configure metals, as defined in the documentation

Using a custom bloop server

You should consider configuring the memory allocated to the bloop server. So far, there is no way to do it if metals starts the bloop server, so you should start it yourself.

To do it:

  • Install Bloop (yaourt -S bloop)
  • Configure the bloop jvm (sudo echo '-Xmx2G' > /usr/lib/bloop/.jvmopts)
  • Start the bloop server (bloop server)

As a bonus, you can now use the bloop commands, that will share the compilation made by code

To avoid keeping a shell always open, you can setup a systemd job.

Create the directory ~/.config/systemd/user edit the file .config/systemd/user/bloop.service with content

[Unit]
Description=Bloop server

[Service]
ExecStart=/usr/bin/bloop server

[Install]
WantedBy=basic.target

you can now control the bloop server using systemctl:

  • systemctl --user start bloop to start the server
  • systemctl --user stop bloop to stop the server
  • systemctl --user status bloop to get the server status

If you want it to start automatically when you connect to your account, just use systemctl --user enable bloop

Running the app :

In order for the app to start correctly, you need to provide the infrastructure. To start it, got to your project directory and type:

make infra-up

In order to download custom defined libraries, add the nexus credentials to the file $HOME/.sbt/1.0/credentials.sbt. With USERNAME and PASSWORD coming from Make.org password manager, this file should look like the following:

credentials ++= Seq(
  //...
  Credentials("Sonatype Nexus Repository Manager", "nexus.prod.makeorg.tech", USERNAME, PASSWORD)
)

Once the infrastructure is up and credentials.sbt is set, you can run your app:

make run

or

sbt api/run

Running the app in Debug Mode:

There are two methods here:

  • Create a sbt task from idea (intellij).
    • 'Edit configurations' -> 'Add new configuration' -> 'SBT Task'
    • Define the task as api/run
  • Run MakeMain in Debug mode from idea. This method requires two VM options to be defined:
    • Set the javaagent: type sbt "show api/kanelaRunnerOptions" and copy the javaagent in vm parameters.

If you use Metals, just click on run or debug in the MakeMain class

Run tests

To run Unit Tests: sbt test To run Integration Tests: sbt it:test If you want to run one test class : sbt "testOnly *org.make.ref.to.class" If you want to run one specific integration test : sbt "it:testOnly *org.make.ref.to.class -- -z testName"

Access the Api documentation

When application is running you can access to the swagger interface from the address: http://localhost:9000/swagger

Make the images available to the front

if your images, uploaded on the API are not visible (with an authentication error), run the following script:

./init-swift.sh

Adding hooks to automatically fix the style

create a file local.sbt in the base directory, and add in it:

gitPreCommitHook := Some(baseDirectory.value / "bin"/ "fix-style.sh")

This local.sbt file can be used to add some custom sbt config that will not be shared between users. Use with care, it will not be on the CI server, so everything must work even without it.

Secrets conf

Some parts of the configuration contain sensitive pieces of information and are defined in the secrets of the API. The following explains how to define these informations locally.

In order to send mails via Mailjet, pull data from Webflow or use the google social connect, create the file /etc/make/make-api.conf with the following content:

make-api {
  mail-jet {
    api-key = "transactional-emails-api-key"
    api-key = ${?MAILJET_API_KEY}
    secret-key = "transactional-emails-secret-key"
    secret-key = ${?MAILJET_SECRET_KEY}
    campaign-api-key = "contact-list-api-key"
    campaign-api-key = ${?CAMPAIGN_MAILJET_API_KEY}
    campaign-secret-key = "contact-list-secret-key"
    campaign-secret-key = ${?CAMPAIGN_MAILJET_SECRET_KEY}
    basic-auth-login = "make-mailjet"
    basic-auth-login = ${?MAILJET_AUTH_LOGIN}
    basic-auth-password = "mail-jet-callback-password"
    basic-auth-password = ${?MAILJET_AUTH_PASSWORD}
  }

  webflow {
    token = "webflow-token"
    token = ${?WEBFLOW_TOKEN}
  }

  social-providers {
    google {
      api-key = "put here your google api key with access to the people API"
      client-id = "put here your google client id to use the api connect form"
    }
  }
}

replacing the different secrets with their real value.

Package the application as a docker image locally

in order to build locally the docker image, type from your base directory:

make package-docker-image

Release the application

Releasing the application consists in packaging the docker image lacally, then tag and push (using docker push) the created image.

Misc

  • The netty version has been forced, so when new dependencies are added, it may be a good idea to exclude netty if it includes it
  • How to run JMH micro-benchmarks

Secure connection to cockroach

See: https://forum.cockroachlabs.com/t/connecting-to-an-ssl-secure-server-using-jdbc-java-and-client-certificate-authentication/400

License

This project is licenced under the AGPL license V3 or later. See license

About

Make.org main API, mirrored from https://gitlab.com/makeorg/platform/core-api If you want to contribute, please do so on the gitlab repository.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages