initial commit
This commit is contained in:
commit
241eabd064
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
1536
Cargo.lock
generated
Normal file
1536
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[package]
|
||||||
|
name = "abuelo"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
warp = "0.3"
|
||||||
|
chrono = "0.4"
|
||||||
|
rusqlite = { version = "0.32", features = ["chrono", "bundled"] }
|
21
README.md
Normal file
21
README.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# ABUELO
|
||||||
|
Abuelo is an open source profile service meant to organize development around
|
||||||
|
AbleOS and related projects. The rest of this document is documentation for
|
||||||
|
the API
|
||||||
|
|
||||||
|
|
||||||
|
## GET /abuelo/user/:username
|
||||||
|
Return information about a particular user in the following format:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success" : Boolean,
|
||||||
|
"message" : String,
|
||||||
|
"username" : String,
|
||||||
|
"email" : String
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- **success**: if the user is found successfully then the value returned is
|
||||||
|
true
|
||||||
|
- **message**: if success is false, contains an error message to give to the
|
||||||
|
user
|
||||||
|
- **username**:
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly-2024-07-27"
|
38
shell.nix
Normal file
38
shell.nix
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
pkgs.mkShell rec {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
clang
|
||||||
|
llvmPackages.bintools
|
||||||
|
rustup
|
||||||
|
sqlite
|
||||||
|
inetutils
|
||||||
|
];
|
||||||
|
extraCmds = '''';
|
||||||
|
RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain.toml;
|
||||||
|
# https://github.com/rust-lang/rust-bindgen#environment-variables
|
||||||
|
LIBCLANG_PATH =
|
||||||
|
pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
|
||||||
|
shellHook = ''
|
||||||
|
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
|
||||||
|
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
|
||||||
|
'';
|
||||||
|
# Add precompiled library to rustc search path
|
||||||
|
RUSTFLAGS = (builtins.map (a: "-L ${a}/lib") [
|
||||||
|
# add libraries here (e.g. pkgs.libvmi)
|
||||||
|
]);
|
||||||
|
# Add glibc, clang, glib and other headers to bindgen search path
|
||||||
|
BINDGEN_EXTRA_CLANG_ARGS =
|
||||||
|
# Includes with normal include path
|
||||||
|
(builtins.map (a: ''-I"${a}/include"'') [
|
||||||
|
# add dev libraries here (e.g. pkgs.libvmi.dev)
|
||||||
|
pkgs.glibc.dev
|
||||||
|
])
|
||||||
|
# Includes with special directory paths
|
||||||
|
++ [
|
||||||
|
''
|
||||||
|
-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
|
||||||
|
''-I"${pkgs.glib.dev}/include/glib-2.0"''
|
||||||
|
"-I${pkgs.glib.out}/lib/glib-2.0/include/"
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
27
src/account.rs
Normal file
27
src/account.rs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
|
pub type UserID = u128;
|
||||||
|
|
||||||
|
pub enum AccountStatusState {
|
||||||
|
Offline,
|
||||||
|
Idle,
|
||||||
|
// Similar to discords do not disturb.
|
||||||
|
Silenced,
|
||||||
|
Online,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AccountStatus{
|
||||||
|
state: AccountStatusState,
|
||||||
|
tagline: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub struct Account{
|
||||||
|
username: String,
|
||||||
|
user_id: UserID,
|
||||||
|
password_hash: String,
|
||||||
|
status: AccountStatus,
|
||||||
|
created_date: DateTime<Utc>,
|
||||||
|
// Donator role
|
||||||
|
premium: bool,
|
||||||
|
}
|
13
src/main.rs
Normal file
13
src/main.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use warp::Filter;
|
||||||
|
|
||||||
|
mod account;
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// GET /hello/warp => 200 OK with body "Hello, warp!"
|
||||||
|
let hello = warp::path!("hello" / String)
|
||||||
|
.map(|name| format!("Hello, {}!", name));
|
||||||
|
|
||||||
|
warp::serve(hello)
|
||||||
|
.run(([127, 0, 0, 1], 3030))
|
||||||
|
.await;
|
||||||
|
}
|
Loading…
Reference in a new issue