Skip to content
Snippets Groups Projects

Ecolyo Agent - Server

Ecolyo Agent is the backoffice for the Ecolyo app.

This repository contains the backend part of this backoffice.

Features

  • Authentification using OAuth2

  • Connected admins can use an API to edit and save different sections of the newsletters that will be sent to Ecolyo users

  • Exposes a public route to get the sections of a specific or the last newsletter

How to setup :

This backend should be deployed with the frontend from this repo

However this backend can be run in standalone :

  • Clone the repository

  • Set a .env file at the root and add all variables declared in the template.env

  • (Optionnal) you can create new certificates by running cd dev_certificates && ./generate-certificates.sh

  • Run docker-compose up -d

Once deployed, you can access to a Swagger documentation of the API on https://${HOSTNAME}/swagger/index.html

Launch locally

To launch it locally :

  • Run docker-compose up -d

In local you can access phpmyadmin interface to manage the database : http://localhost:8008

Launch locally in standalone for development

To launch the backend for development goal:

  • edit main.go file, uncomment the last line "log.Fatal(http.ListenAndServe(":"+strconv.Itoa(httpsPort), rootMux.Router))" and comment the line above "log.Fatal(http.ListenAndServeTLS(":"+strconv.Itoa(httpsPort), "./dev_certificates/localhost.crt", "./dev_certificates/localhost.key", rootMux.Router))"
  • This way you disable https so make sure your requests goes on http adresses
  • in vscode/launch.json set "REDIRECT_URL" to "http://localhost:1443/OAuth2Callback",
  • also comment the port and host values
  • if you comment the DATABASE_USER line, it will launches with a sqlite database instead of mysql
  • launch the app by pressing F5 on vscode, you will see the logs on the debug console.
  • this way you won't have the login every time you relaunch the backend for development

Build image for local

docker build . -t backoffice-server