Skip to content

Commit

Permalink
feat: Add auth routes and login/register pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ikurotime committed Jan 5, 2024
1 parent 9b17a82 commit b833a3b
Show file tree
Hide file tree
Showing 15 changed files with 384 additions and 33 deletions.
49 changes: 49 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
sqlx = { version = "0.6", features = ["postgres", "runtime-tokio-rustls"] }
dotenv = "0.15.0"
rand = "0.8.5"
bcrypt = "0.15.0"
83 changes: 67 additions & 16 deletions assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ video {
display: flex;
}

.hidden {
display: none;
}

.h-16 {
height: 4rem;
}
Expand All @@ -604,6 +608,10 @@ video {
width: 100%;
}

.min-w-\[80\%\] {
min-width: 80%;
}

.max-w-4xl {
max-width: 56rem;
}
Expand Down Expand Up @@ -640,12 +648,16 @@ video {
gap: 0.75rem;
}

.gap-5 {
gap: 1.25rem;
}

.gap-6 {
gap: 1.5rem;
}

.gap-5 {
gap: 1.25rem;
.gap-8 {
gap: 2rem;
}

.rounded {
Expand All @@ -656,6 +668,10 @@ video {
border-radius: 9999px;
}

.rounded-md {
border-radius: 0.375rem;
}

.rounded-b {
border-bottom-right-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
Expand Down Expand Up @@ -693,24 +709,29 @@ video {
background-color: rgb(245 246 247 / var(--tw-bg-opacity));
}

.bg-\[rgb\(234\2c 198\2c 67\)\] {
--tw-bg-opacity: 1;
background-color: rgb(234 198 67 / var(--tw-bg-opacity));
}

.bg-black {
--tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
}

.bg-white {
.bg-slate-100 {
--tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
background-color: rgb(241 245 249 / var(--tw-bg-opacity));
}

.bg-slate-900 {
--tw-bg-opacity: 1;
background-color: rgb(15 23 42 / var(--tw-bg-opacity));
}

.bg-\[rgb\(234\2c 198\2c 67\)\] {
.bg-white {
--tw-bg-opacity: 1;
background-color: rgb(234 198 67 / var(--tw-bg-opacity));
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
}

.fill-black {
Expand All @@ -721,6 +742,10 @@ video {
padding: 0.75rem;
}

.p-4 {
padding: 1rem;
}

.p-5 {
padding: 1.25rem;
}
Expand All @@ -734,16 +759,16 @@ video {
padding-right: 0.75rem;
}

.py-3 {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}

.px-8 {
padding-left: 2rem;
padding-right: 2rem;
}

.py-3 {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}

.text-center {
text-align: center;
}
Expand All @@ -763,6 +788,16 @@ video {
line-height: 1;
}

.text-7xl {
font-size: 4.5rem;
line-height: 1;
}

.text-lg {
font-size: 1.125rem;
line-height: 1.75rem;
}

.text-sm {
font-size: 0.875rem;
line-height: 1.25rem;
Expand Down Expand Up @@ -800,6 +835,11 @@ video {
color: rgb(234 198 67 / var(--tw-text-opacity));
}

.text-black {
--tw-text-opacity: 1;
color: rgb(0 0 0 / var(--tw-text-opacity));
}

.text-indigo-500 {
--tw-text-opacity: 1;
color: rgb(99 102 241 / var(--tw-text-opacity));
Expand All @@ -810,15 +850,26 @@ video {
color: rgb(255 255 255 / var(--tw-text-opacity));
}

.text-black {
--tw-text-opacity: 1;
color: rgb(0 0 0 / var(--tw-text-opacity));
}

.opacity-0 {
opacity: 0;
}

.hover\:underline:hover {
text-decoration-line: underline;
}

@media (min-width: 768px) {
.md\:min-w-\[66\%\] {
min-width: 66%;
}
}

@media (min-width: 1024px) {
.lg\:flex {
display: flex;
}

.lg\:w-1\/2 {
width: 50%;
}
}
13 changes: 7 additions & 6 deletions migrations/0001_Create_Tables.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
CREATE TABLE "User" (
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE,
name VARCHAR(255),
name VARCHAR(255) UNIQUE,
password VARCHAR(255),
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE "Links" (
CREATE TABLE links (
id SERIAL PRIMARY KEY,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
original_url VARCHAR(255),
short_url VARCHAR(255),
userId INTEGER REFERENCES "User"(id) ON DELETE SET NULL
userId INTEGER REFERENCES users (id) ON DELETE SET NULL
);
CREATE TABLE "QRCodes" (
CREATE TABLE qrcodes (
id SERIAL PRIMARY KEY,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
qr_code TEXT,
userId INTEGER REFERENCES "User"(id) ON DELETE SET NULL
userId INTEGER REFERENCES users (id) ON DELETE SET NULL
);
6 changes: 3 additions & 3 deletions migrations/0002_Create_LinkClicks_Table.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CREATE TABLE LinkClicks (
CREATE TABLE linkclicks (
ID SERIAL PRIMARY KEY,
LinkID INTEGER REFERENCES "Links"(id) ON DELETE CASCADE,
LinkID INTEGER REFERENCES links(id) ON DELETE CASCADE,
ClickTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
IPAddress VARCHAR(255),
UserAgent TEXT,
Referrer TEXT,
DeviceInfo TEXT,
GeographicLocation VARCHAR(255),
UserID INTEGER REFERENCES "User"(id) ON DELETE SET NULL,
UserID INTEGER REFERENCES users (id) ON DELETE SET NULL,
ClickCount INTEGER
);
;
1 change: 1 addition & 0 deletions src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ fn router() -> Router {
)
.nest("/api", routes::user_routes::get_routes())
.nest("/api/link", routes::link_routes::get_routes())
.nest("/api/auth", routes::auth_routes::get_routes())
}
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
mod http;
mod routes;
mod structs;

use dotenv::dotenv;
use sqlx::postgres::PgPoolOptions;
use tracing::info;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv().ok();
Expand Down
1 change: 1 addition & 0 deletions src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod user_routes;
pub mod web_routes;
pub mod link_routes;
pub mod auth_routes;
Loading

0 comments on commit b833a3b

Please sign in to comment.