Browse Source

release build

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
0a155c44cd
  1. 1
      .gitignore
  2. 19
      Makefile
  3. 12
      README.md
  4. 3
      client/src/services/auth.service.ts
  5. 4
      server/src/api.rs
  6. 4
      server/src/services/user_service.rs

1
.gitignore vendored

@ -0,0 +1 @@
release/*

19
Makefile

@ -0,0 +1,19 @@
all: server client
mkdir release
cp server/target/x86_64-unknown-linux-musl/release/hastic release
mkdir release/public
cp -r client/dist/* release/public/
server:
cd server;cargo build --release --target x86_64-unknown-linux-musl
client client/dist:
cd client;yarn build
clean:
rm -r release
rm -r client/dist
rm -r server/target/release
.PHONY: server client all

12
README.md

@ -1,2 +1,14 @@
# Hastic
## Build release
```
make
```
```
cd release
./hastic
```
open `http://localhost:8000` in browser

3
client/src/services/auth.service.ts

@ -2,7 +2,8 @@ import { User } from "@/types/user";
import axios from 'axios';
const API_URL = 'http://localhost:8000/api/auth/';
// TODO: get it from config
const API_URL = '/api/auth/';
class AuthService {
login(user: User) {

4
server/src/api.rs

@ -58,9 +58,11 @@ impl API {
})
});
let login = auth::get_route(self.user_service.clone());
let public = warp::fs::dir("public");
println!("Start server on 8000 port");
let routes = login.or(options).or(not_found);
// TODO: move it to "server"
let routes = login.or(options).or(public).or(not_found);
warp::serve(routes).run(([127, 0, 0, 1], 8000)).await;
}
}

4
server/src/services/user_service.rs

@ -6,7 +6,7 @@ use std::iter::repeat_with;
pub type AccessToken = String;
const TOKEN_LENGTH: usize = 20;
const TOKEN_LENGTH: usize = 30;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct User {
@ -34,7 +34,7 @@ impl UserService {
}
return None;
}
pub fn check_token(&self, username: &String, token: &AccessToken) -> bool {
pub fn check_token(&self, token: &AccessToken) -> bool {
return self.tokens.contains(token);
}
}

Loading…
Cancel
Save