Skip to content

Instantly share code, notes, and snippets.

@mayankchoubey
mayankchoubey / actix.rs
Created May 28, 2024 23:57
Go vs Rust frameworks - Hello world
use actix_web::{get, App, HttpServer, Responder};
#[get("/")]
async fn index() -> impl Responder {
"Hello World!"
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(index))
@mayankchoubey
mayankchoubey / db.go
Last active May 22, 2024 18:37
Fiber - HTTP + DB reads
package main
import (
"context"
"database/sql"
"os"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect/pgdialect"
"github.com/uptrace/bun/driver/pgdriver"
@mayankchoubey
mayankchoubey / db.mjs
Created May 22, 2024 18:35
Fastify - HTTP + DB read
import { env } from "node:process";
import { DataTypes, Sequelize } from "sequelize";
const dbUser = env.dbUser;
const dbUserPass = env.dbUserPass;
const dbName = env.dbName;
const sequelize = new Sequelize(
`postgres://${dbUser}:${dbUserPass}@localhost:5432/${dbName}`,
{
@mayankchoubey
mayankchoubey / NoUserResponse.java
Created May 22, 2024 00:25
Quarkus - PG read use case
package com.example;
public class NoUserResponse {
}
@mayankchoubey
mayankchoubey / db.go
Last active May 18, 2024 23:46
Go - Gin, Fiber, and Echo app for database reads
package main
import (
"context"
"database/sql"
"os"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect/pgdialect"
"github.com/uptrace/bun/driver/pgdriver"
)
@mayankchoubey
mayankchoubey / NoUserResponse.java
Created May 18, 2024 21:45
Spring Boot - PG read app
package com.example.demo;
public class NoUserResponse {
}
@mayankchoubey
mayankchoubey / db.mjs
Created May 5, 2024 20:23
Node vs Deno vs Bun: Database reads application
import { env } from "node:process";
import { DataTypes, Sequelize } from "sequelize";
const dbUser = env.dbUser;
const dbUserPass = env.dbUserPass;
const dbName = env.dbName;
const sequelize = new Sequelize(
`postgres://${dbUser}:${dbUserPass}@localhost:5432/${dbName}`,
{
@mayankchoubey
mayankchoubey / bun_file_server.js
Last active February 19, 2024 17:14
Static file server in various languages
const basePath = "/Users/mayankc/Work/source/perfComparisons";
Bun.serve({
port: 3000,
fetch(request) {
const fp = basePath + new URL(request.url).pathname;
try {
return new Response(Bun.file(fp));
} catch (e) {
return new Response(null, { status: 404 });
}
@mayankchoubey
mayankchoubey / actix_app.rs
Created February 19, 2024 00:30
Rocket vs Actix vs Axum vs Warp vs Gotham
use actix_web::{get, App, HttpServer, Responder};
use uuid::Uuid;
#[get("/")]
async fn index() -> impl Responder {
return "Hello ".to_owned() + &Uuid::new_v4().to_string();
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
@mayankchoubey
mayankchoubey / auth.mjs
Created February 18, 2024 05:55
Node.js vs Deno vs Bun : A real world PDF generation service for benchmarking
import jwt from "jsonwebtoken";
import { env } from "node:process";
const jwtSecret = env.JWT_SECRET;
function getToken(headers) {
if (
headers && headers.authorization &&
headers.authorization.startsWith("Bearer ")
) {