- Upewnij się że masz zainstalowane
cargo
(package manager Rusta) w najnowszej wersji - Sklonuj repozytorium na swój lokalny dysk
- Stwórz plik
.env
w głównym katalogu repozytorium i zamieść w nim zmiennąDATABASE_URL
zawierającą adres URL bazy danych np.:
DATABASE_URL = "mysql://nazwaUzytkowniak:Haslo@localhost/bazaDanych"
- Stwórz plik Rocket.toml i umieść w nim następującą treść, gdzie wartością
secret_key
jest 256-bitowy klucz base64, który wygenerowany może być za pomocą komendy:openssl rand -base64 32
[default]
secret_key = ""
- Zaimportuj tabelę z /sql/structure.sql do bazy danych MySQL i upewnij się że uruchomiony jest serwer MySQL
- Skompiluj i uruchom program za pomocą:
cargo run --release
- Po kompilacji strona powinna działać na
localhost:8000
Returns all inserted markers in the form of a JSON array:
[
{
id:1,
latitude:50.21212,
longitude:1.12121,
title:"pomoc dzieciom",
description:"sasas",
type:"NeighborHelp",
addTime:1665747948,
startTime:1675747948,
endTime:1666784387,
address: {
street:"Jagiellonska",
city: "Sosnowiec",
number:"13"
},
contactInfo: {
name: "Paweł",
surname: "Kowalski",
address: {
street: "Jagiellonska",
city: "Sosnowiec",
number: "13",
},
method: {
type: "PhoneNumber",
val: "123456789"
},
userID: 1
},
{
id:2,
latitude:50.21212,
longitude:1.12121,
title:"pomoc dzieciom",
description:"asasas",
type:"NeighborHelp",
addTime:1665747950,
startTime:1675747950,
endTime:1666784390,
address: {
street:"Jagiellonska",
city: "Sosnowiec",
number:"13"
},
contactInfo: {
name: "Paweł",
surname: "Kowalski",
address: {
street: "Jagiellonska",
city: "Sosnowiec",
number: "13",
},
method: {
type: "PhoneNumber",
val: "123456789"
},
userID: 1
}
]
id
integer - ID of the markerlatitude
double - Latitude of the markerlongitude
double - Longitude of the numbertitle
string - Title of the markerdescription
string - Marker's descriptiontype
Enum (NeighborHelp/Happening/Charity/MassEvent) - Type of the eventaddTime
unix timestamp - UNIX timestamp of the time when marker was addedstartTime
unix timestamp (OPTIONAL) - UNIX timestamp of the time when event startsendTime
unix timestamp (OPTIONAL) - UNIX timestamp of the time when event endsaddress
Address - Marker's location represented by Address objectcontactInfo
ContactInfo - Contact info of the marker's creatoruserID
integer - ID of the user who created the marker
Returns all markers added by the currently logged in user:
[
{
id:1,
latitude:50.21212,
longitude:1.12121,
title:"pomoc dzieciom",
description:"sasas",
type:"NeighborHelp",
addTime:1665747948,
startTime:1675747948,
endTime:1666784387,
address:{
street:"Jagiellonska",
city: "Sosnowiec",
number:"13"
},
contactInfo:{
name: "Paweł",
surname: "Kowalksi",
address: {
postalCode: "41-207",
street: "Jagiellonska",
number: "13",
},
method:{
type: "PhoneNumber",
val: "123456789"
}
}
]
Returns full information about Marker with ID <id>:
{
id:1,
latitude:50.21212,
longitude:1.12121,
title:"pomoc dzieciom",
description:"sasas",
type:"NeighborHelp",
addTime:1665747948,
startTime:1675747948,
endTime:1666784387,
address:{
street:"Jagiellonska",
city: "Sosnowiec",
number:"13"
},
contactInfo:{
name: "Paweł",
surname: "Kowalksi",
address: {
street: "Jagiellonska",
city: "Sosnowiec",
number: "13",
},
method:{
type: "PhoneNumber",
val: "123456789"
},
userID: 1
}
if the ID is not present in the DB, it responds with SomsiadStatus::error
id
: number - the id of the markerlatitude
: number (double) - coordinatelongitude
: number (double) - coordinatetitle
: string - title of the markerdescription
: string - description of a given eventtype
: Enum ("NeighborHelp"/"Happening"/"Charity"/"MassEvent") - type of the eventaddTime
: Unix milis - Time when the marker got added, optional when addingstartTime
: Unix milis - Time when the event in the marker start, opitonalendTime
: Unix milis/Nothing - If present - time when the marker expiresaddress
: addresscontactInfo
: contactInfouserID
: number - ID of the user who added given marker
Gets all markers where the city is <city>, in the same form as the /markers
Gets all markers within distance <dist> of given coordinates <lat> (latitude) and <long> (longitude) returns them in the same form as /markers
Adds marker which will be supplied by frontend in a JSON format e.g:
{
latitude:50.21212,
longitude:1.12121,title:"pomoc dzieciom",
description:"sasas",
type:"NeighborHelp",
addTime:1665747948,
startTime:1675747948,
endTime:1666784387,
address: {
city: "Sosnowiec",
street: "Jagiellonska",
number: "13",
},
contactInfo:{
name: "Paweł",
surname: "Kowalksi",
address: {
city: "Sosnowiec",
street: "Jagiellonska",
number: "13",
},
method:{
type: "PhoneNumber",
val: "123456789"
}
}
Responds with SomsiadStatus
Removes the marker with ID <marker_id>, checking if it is being removed by the user who added it (checks if user_ID in private cookie and the given database row is equal)
Responds with the FullMarker that has been removed or SomsiadStatus::error
Tries to register an user, given their credentials e.g:
{
login: {
email: '[email protected]',
password: "toor"
},
username: "lol",
name: "Paweł",
surname: "Kowalski",
sex: 'Male',
reputation: 1337,
address: {
city: "Sosnowiec",
street: "Jagiellonska",
number: "13",
}
}
login
: JSON array:email
: string, validated server-side, unique - email of the user being registredpassword
: string - unhashed password of the user being registered
username
: string, unique - username of a given username
: string - real world namesurname
: string - self-explanatorysex
: Enum ('Male','Female','Other') - self-explanatoryreputation
number - Reputation points of the user, optionaladdress
: address
Responds with SomsiadStatus
Tries to login with given credentials e.g.:
{
email: '[email protected]',
password: "toor"})
}
Structure:
email
: string, validated server-side, unique - email of the user being registredpassword
: string - unhashed password of the user being registered
Responds with SomsiadStatus If user logs in correctly, it sets a private cookie which represents their id
Removes the private cookie that indicates that a user is logged in
Return SomsiadStatus::ok if the user is logged in, if not it returns SomsiadStatus::error SomsiadStatus
Gets public info about the user with id <id>
{
username:"root",
name:"Paweł",
surname:"Kowalski",
sex:"Other",
reputation:0
}
If the user has the private cookie, which indicates that they are logged in set, it displays data about them: e.g:
{
username:"root",
name:"Paweł",
surname:"Kowalski",
email:"[email protected]",
sex:"Male",
address:{
street:"Jagiellonska",
city: "Sosnowiec",
number: 13
},
reputation:1337
}
Structure: user structure but without the password
If the user doesn't have that cookie set it responds with SomsiadStatus error Responds with SomsiadStatus
If everything goes correctly it is:
{
status: "ok",
res: null
}
{
status: "error",
res: [
"Podany e-mail jest zajęty"
]
}
where status is either "ok" or "error", if it is "ok" then res is null and if it is erros then res is a array containing all of the errors that have occured
postalCode
: string - self-explanatory, this is optional, does not need to be in structure or can be just nullstreet
: string - only street of the addressnumber
: string (since houseNumbers can be 55a) - number of the housecountry
: string - self-explanatory
e.g:
address: {
street: "Jagiellonska",
number: "13",
city: "Sosnowiec"
}
}
name
: string {self-explanatory}surname
: string {self-explanatory}address
: addresmethod
:type
: Enum ("PhoneNumber"/Email) - type of the contact method}val
: string - Either phone number or email with which the user adding the marker can be contacted
e.g:
contactInfo:{
name: "Paweł",
surname: "Kowalksi",
address: {
postalCode: "41-207",
city: "Sosnowiec",
number: 13,
},
method:{
type: "PhoneNumber",
val: "123456789"
}
}