Skip to content

Commit

Permalink
✨ feature: Raw endpoint is back!
Browse files Browse the repository at this point in the history
  • Loading branch information
mellowmarshe committed Mar 24, 2022
1 parent fb4b814 commit 6bc1e8c
Show file tree
Hide file tree
Showing 4 changed files with 1,831 additions and 3,101 deletions.
5 changes: 3 additions & 2 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use config::Config;

use sqlx::{postgres::PgPoolOptions, PgPool};

use crate::routes::{get_paste, get_stats, get_total_pastes_badge, get_version_badge, new_paste};
use crate::routes::{get_paste, get_stats, get_total_pastes_badge, get_version_badge, new_paste, get_raw_paste};

#[derive(Clone)]
pub struct AppState {
Expand Down Expand Up @@ -62,7 +62,8 @@ async fn main() -> io::Result<()> {
web::scope("/p")
.wrap(Governor::new(&paste_governor))
.service(get_paste)
.service(new_paste), // .service(get_raw_paste),
.service(new_paste)
.service(get_raw_paste),
)
.service(
web::scope("/b")
Expand Down
3 changes: 1 addition & 2 deletions backend/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub async fn get_paste(state: web::Data<AppState>, id: web::Path<String>) -> imp
}
}

// TODO: Fix major vuln
#[get("/r/{id}")]
pub async fn get_raw_paste(state: web::Data<AppState>, id: web::Path<String>) -> impl Responder {
let id = id.into_inner();
Expand All @@ -94,7 +93,7 @@ pub async fn get_raw_paste(state: web::Data<AppState>, id: web::Path<String>) ->
.execute(&state.pool)
.await;

HttpResponse::Ok().body(p.content)
HttpResponse::Ok().content_type("text/plain").body(p.content)
}
Err(e) => match e {
sqlx::Error::RowNotFound => {
Expand Down
3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"build": "parcel build index.pug --public-url /"
},
"devDependencies": {
"@parcel/compressor-brotli": "^2.4.0",
"@parcel/compressor-gzip": "^2.4.0",
"@parcel/transformer-sass": "2.4.0",
"@types/core-js": "^2.5.5",
"@types/node": "^17.0.21"
},
Expand Down
Loading

0 comments on commit 6bc1e8c

Please sign in to comment.