https://github.com/anras5/greenicoapi
RESTful API and web application for Greenico project
https://github.com/anras5/greenicoapi
gin-gonic go rest-api
Last synced: 2 months ago
JSON representation
RESTful API and web application for Greenico project
- Host: GitHub
- URL: https://github.com/anras5/greenicoapi
- Owner: anras5
- Created: 2022-12-30T19:15:11.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-12T16:06:09.000Z (over 2 years ago)
- Last Synced: 2025-01-21T17:49:59.138Z (4 months ago)
- Topics: gin-gonic, go, rest-api
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Greenico API
Weather station with Raspberry Pi Pico - "Greenico"
[GreenicoAPI](https://github.com/anras5/GreenicoAPI) is only a part of `Greenico` project.
The first part is [Greenico on Raspberry Pi Pico](https://github.com/anras5/Greenico). Be sure to check it out also.
## Table of contents
1. [The purpose of the project](#Purpose)
2. [Description](#Description)
3. [Technical information](#Technical)
4. [Contact](#Contact)## Purpose
The aim of the project is to allow the user to view the current state of the weather by designing and building a weather
station. The preview will be possible through a browser, i.e. a web application in the form of clear graphs and on the
display attached to the weather station.## Description
Go was chosen as the programming language for this part of the project with Gin framework due to the ease of
implementing the RESTful API and the simplicity of connecting the application with
Postgres database. The web application was built using Go templates and language JavaScript.
The Postgres database was created using the Soda migration tool.## Available endpoints
API endpoints:
```go
// API
router.GET("/api/reading", handlers.GetReading(db))
router.GET("/api/readings", handlers.GetReadings(db))
router.GET("/api/all-readings", handlers.GetAllReadings(db))
router.POST("/api/reading", handlers.InsertReading(db))
router.DELETE("/api/reading", handlers.DeleteReading(db))
```Web application endpoints:
```go
// WEB APP
router.GET("/", handlers.MainRender(db))
router.GET("/voc", handlers.PageRender(db, "voc"))
router.GET("/temperature", handlers.PageRender(db, "temperature"))
router.GET("/humidity", handlers.PageRender(db, "humidity"))
router.GET("/light", handlers.PageRender(db, "light"))
router.GET("/pressure", handlers.PageRender(db, "pressure"))
router.GET("/uv", handlers.PageRender(db, "uv"))
```## Technical
API was written in **Go** programming language with the use of **Gin framework**. All requirements are listed
in `go.mod` file.### How to run the app
1. Create (in the root directory of the project) and fill values in `.env` file:
```
HOSTNAME=
PORT=
DBNAME=
DBUSER=
DB_PASSWD=
```
2. Run `run.bat` file## Contact
Contact me at:
[email protected]