Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zheng-bote/scs_api_geolocation
SCS API Webserver to get geolocation data
https://github.com/zheng-bote/scs_api_geolocation
Last synced: 22 days ago
JSON representation
SCS API Webserver to get geolocation data
- Host: GitHub
- URL: https://github.com/zheng-bote/scs_api_geolocation
- Owner: Zheng-Bote
- License: mit
- Created: 2023-12-15T14:33:14.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-19T16:53:39.000Z (11 months ago)
- Last Synced: 2024-10-05T06:41:24.140Z (about 1 month ago)
- Language: Rust
- Size: 229 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust Geo API Webserver
Self-contained System for Geolocation API calls.
The Geo-Providers can be configured via web ui, including monthly payload limits.
## Status
![under under_construction](https://img.shields.io/badge/Status-under_construction-yellow)
**Still under heavy construction**![deprecated](https://img.shields.io/badge/Info-limited_functionality-yellow)
**This application will be just rudimentary and mostly to learn Rust and the Rocket framework.**## Features
- [x] Rust programming language with Rocket webframework
- [x] Diesel ORM and SQLx toolkit
- [x] Self-contained System with Web-based Userinterface
- [x] support for several Geolocation providers
- [x] each registered GEO provider with own configureable monthly payload limits
- [x] configuration based on SQLite3 database
- [x] template-based UI with Handlebars, JS and CSS support
- [ ] scaleable, clean architecture
- [ ] ReSTfull
- [x] Secured (XSS, ...)
- [ ] User authentication, rights and roles
- [ ] tbd.
## HISTORY:
> | Version | Date | Developer | Comments |
> | ------- | ---------- | --------- | -------- |
> | 0.1.0 | 2023-12-16 | RZheng | created |## API Reference
### Landing Page
loads the landing page with some explanations
`/`
**Returns:**
HTML page#### Get all providers
list all providers from database
```http
GET /providers
```| Parameter | Type | Description |
| :-------- | :---- | :---------------------------- |
| `none` | `-/-` | list all configured providers |**Returns:**
JSON array#### Get provider
```http
GET /provider/${id}
```| Parameter | Type | Description |
| :-------- | :------- | :------------------------------------ |
| `id` | `string` | **Required**. Id of provider to fetch |**Returns:**
JSON#### create provider
Create (add) a new provider to the database
```http
POST /create/${JSON data}
```| Parameter | Type | Description |
| :-------------- | :------- | :------------------------------------------ |
| `name` | `string` | **Required**. name of provider |
| `description` | `string` | **Required**. short description of provider |
| `api_key` | `string` | **Required**. API key |
| `counter_limit` | `string` | **Required**. payload limit per month |
| `counter` | `string` | **Required**. initial payload (eg. 0) |## Authors
- [@Zheng-Bote](https://www.github.com/zheng-bote)
## License
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
## Setup
### Environment Variables
To run this project, you will need to add the following environment variables to your .env file (see example: env_prod)
`DATABASE_URL="sqlite://data.db"`
### Database
Manage the SQLite3 database with Diesel:
`diesel setup`
`diesel migration generate create_tasks`
define **up.sql**
```
CREATE TABLE IF NOT EXISTS geo_provider
(
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL UNIQUE,
description TEXT NOT NULL,
api_key TEXT NOT NULL,
counter_limit TEXT NOT NULL,
counter TEXT NOT NULL,
date_time integer not NULL
);
```define **down.sql**
`DROP TABLE geo_provider;`
create **database**
`diesel migration run`
### build release
`cargo build --release`
## Security
the following CORS are defined (in main.rs):
```
response.set*header(Header::new("Access-Control-Allow-Origin", "*"));
response.set*header(Header::new("Access-Control-Allow-Methods", "POST, GET, PATCH, OPTIONS", ));
response.set_header(Header::new("Access-Control-Allow-Headers", "*"));
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));response.set_header(Header::new("Strict-Transport-Security", "max-age=63072000"));
```**please be aware of "Strict-Transport-Security"**
## Screenshots
**Startpage**
**create / add provider**
**list all registered providers**
### the end
:vulcan_salute: