Skip to content

Instantly share code, notes, and snippets.

@mayankchoubey
mayankchoubey / db.mjs
Last active October 14, 2023 21:27
Node.js - Fastify URL shortener service in PostgreSQL
import { DataTypes, Sequelize } from "sequelize";
const dbUser = process.env.dbUser;
const dbUserPass = process.env.dbUserPass;
const dbName = process.env.dbName;
const sequelize = new Sequelize(
`postgres://${dbUser}:${dbUserPass}@localhost:5432/${dbName}`,
{
logging: false,
@mayankchoubey
mayankchoubey / db.mjs
Last active October 14, 2023 21:27
Node.js - Express URL shortener service in PostgreSQL
import { DataTypes, Sequelize } from "sequelize";
const dbUser = process.env.dbUser;
const dbUserPass = process.env.dbUserPass;
const dbName = process.env.dbName;
const sequelize = new Sequelize(
`postgres://${dbUser}:${dbUserPass}@localhost:5432/${dbName}`,
{
logging: false,
@mayankchoubey
mayankchoubey / db.mjs
Last active October 14, 2023 21:28
Node.js - Native URL shortener service in PostgreSQL
import { DataTypes, Sequelize } from "sequelize";
const dbUser = process.env.dbUser;
const dbUserPass = process.env.dbUserPass;
const dbName = process.env.dbName;
const sequelize = new Sequelize(
`postgres://${dbUser}:${dbUserPass}@localhost:5432/${dbName}`,
{
logging: false,
@mayankchoubey
mayankchoubey / User.java
Created September 14, 2023 06:16
SpringBoot Webflux - JWT verify & MySQL read
package webfluxdemo;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
@Table(name = "users")
public class User {
@Id
private String email;
@mayankchoubey
mayankchoubey / User.java
Created September 14, 2023 06:14
SpringBoot virtual threads - JWT verify and MySQL query
package com.example.demo;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
@Table(name = "users")
@mayankchoubey
mayankchoubey / User.java
Created September 14, 2023 06:12
SpringBoot - JWT verify and MySQL read
package com.example.demo;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
@Table(name = "users")
@mayankchoubey
mayankchoubey / QrApplication.java
Last active September 9, 2023 16:28
SpringBoot Webflux - QR generator API
package webfluxqr;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.reactive.config.EnableWebFlux;
@EnableWebFlux
@SpringBootApplication
@mayankchoubey
mayankchoubey / QrApplication.java
Created September 9, 2023 16:25
SpringBoot - QR generator API
package com.example.qr;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer;
import org.springframework.context.annotation.Bean;
import java.util.concurrent.Executors;
@SpringBootApplication
public class QrApplication {
@mayankchoubey
mayankchoubey / cargo.toml
Last active September 9, 2023 19:27
Rust - QR generator API
[package]
name = "actix_qr_generator"
version = "0.1.0"
edition = "2021"
[dependencies]
actix-web = { version = "4", features = ["openssl"] }
qrcode-generator = "4.1.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
@mayankchoubey
mayankchoubey / go_qr_generator_api.go
Last active September 9, 2023 16:19
Go - QR generator API
package main
import (
"net/http"
"github.com/gin-gonic/gin"
qrcode "github.com/skip2/go-qrcode"
)
type QrRequest struct {
UrlToEmbed string `json:"urlToEmbed"`