initial commit
This commit is contained in:
commit
3100948f3a
12 changed files with 1482 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
1338
Cargo.lock
generated
Normal file
1338
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
4
Cargo.toml
Normal file
4
Cargo.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"services/*"
|
||||
]
|
57
README.md
Normal file
57
README.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Saerro Listening Post
|
||||
|
||||
PlanetSide 2 live population API. This API is free and open for anyone to use.
|
||||
|
||||
The one and only goal of this app is to provide a current "point-in-time" population status for PlanetSide 2, per world, per faction, (and later, per continent.) Historical info is _not_ a goal.
|
||||
|
||||
https://saerro.harasse.rs
|
||||
|
||||
## API Reference
|
||||
|
||||
- [`/`](https://saerro.harasse.rs) - Shows a help/usage message.
|
||||
- [`/w/{worldID}`](https://saerro.harasse.rs/w/17) - Shows populations for one world, example:
|
||||
|
||||
```json
|
||||
{
|
||||
"worldID": 17,
|
||||
"total": 1000,
|
||||
"factions": {
|
||||
"tr": 334,
|
||||
"nc": 333,
|
||||
"vs": 333
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [`/m/?id={worldID1},{worldID2}...`](https://saerro.harasse.rs/m/?id=1,17) - Shows populations for all listed worlds, example:
|
||||
|
||||
```json
|
||||
{
|
||||
"worlds": [
|
||||
{
|
||||
"worldID": 17,
|
||||
"total": 1000,
|
||||
"factions": {
|
||||
"tr": 334,
|
||||
"nc": 333,
|
||||
"vs": 333
|
||||
}
|
||||
},
|
||||
{
|
||||
"worldID": 19,
|
||||
"total": 1000,
|
||||
"factions": {
|
||||
"tr": 334,
|
||||
"nc": 333,
|
||||
"vs": 333
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
- Websocket processors
|
||||
- One pair per PC, PS4US, PS4EU
|
||||
- Each pair connects to either Census Websocket or NS Websocket, depending on availability.
|
12
services/api/Cargo.toml
Normal file
12
services/api/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "api"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
salvo = { version = "0.37.4", features = ["cors"] }
|
||||
tokio = { version = "1.22.0", features = ["macros"] }
|
||||
serde_json = "1.0.88"
|
||||
serde = "1.0.147"
|
48
services/api/src/main.rs
Normal file
48
services/api/src/main.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
use salvo::cors::Cors;
|
||||
use salvo::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
struct IncomingHeaders {
|
||||
host: String,
|
||||
}
|
||||
|
||||
#[handler]
|
||||
async fn info(req: &mut Request, res: &mut Response) {
|
||||
let headers: IncomingHeaders = req.parse_headers().unwrap();
|
||||
let json = json!({
|
||||
"@": "Saerro Listening Post",
|
||||
"@GitHub": "https://github.com/genudine/saerro",
|
||||
"@Disclaimer": "Genudine Dynamics is not responsible for any damages caused by this software. Use at your own risk.",
|
||||
"@Support": "#api-dev in https://discord.com/servers/planetside-2-community-251073753759481856",
|
||||
"Worlds": {
|
||||
"Connery": format!("https://{}/w/1", headers.host),
|
||||
"Miller": format!("https://{}/w/10", headers.host),
|
||||
"Cobalt": format!("https://{}/w/13", headers.host),
|
||||
"Emerald": format!("https://{}/w/17", headers.host),
|
||||
"Jaeger": format!("https://{}/w/19", headers.host),
|
||||
"SolTech": format!("https://{}/w/40", headers.host),
|
||||
"Genudine": format!("https://{}/w/1000", headers.host),
|
||||
"Ceres": format!("https://{}/w/2000", headers.host),
|
||||
},
|
||||
"All Worlds": format!("https://{}/m/?ids=1,10,13,17,19,40,1000,2000", headers.host),
|
||||
});
|
||||
|
||||
res.render(serde_json::to_string_pretty(&json).unwrap());
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let cors_handler = Cors::builder()
|
||||
.allow_any_origin()
|
||||
.allow_method("GET")
|
||||
.build();
|
||||
|
||||
let router = Router::new().hoop(cors_handler).get(info);
|
||||
Server::new(TcpListener::bind("127.0.0.1:7878"))
|
||||
.serve(router)
|
||||
.await;
|
||||
}
|
8
services/tasks/Cargo.toml
Normal file
8
services/tasks/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "tasks"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
services/tasks/src/main.rs
Normal file
3
services/tasks/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
8
services/websocket/Cargo.toml
Normal file
8
services/websocket/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "websocket"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
services/websocket/src/main.rs
Normal file
3
services/websocket/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
0
terraform/compute.tf
Normal file
0
terraform/compute.tf
Normal file
0
terraform/providers.tf
Normal file
0
terraform/providers.tf
Normal file
Loading…
Add table
Reference in a new issue