This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import jwt from "jsonwebtoken"; | |
| import { readFileSync } from "node:fs"; | |
| const emails = JSON.parse( | |
| readFileSync( | |
| "/Users/mayankc/Work/source/perfComparisons/testdata/emails.json", | |
| ), | |
| ); | |
| let i = 1, idx = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use crate::repository::database::Database; | |
| use crate::{ | |
| types::types::ShortenUrl, types::types::UrlShortenerError, types::types::UrlShortenerRequest, | |
| types::types::UrlShortenerResponse, | |
| }; | |
| use actix_web::{delete, get, post, put, web, HttpResponse}; | |
| use chrono::{DateTime, Utc}; | |
| use nanoid::nanoid; | |
| const baseUrl: &str = "http://test.short/"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example; | |
| import java.time.LocalDateTime; | |
| import io.vertx.mutiny.sqlclient.Row; | |
| public record ShortenedUrl( | |
| String id, | |
| String srcurl, | |
| LocalDateTime created, | |
| LocalDateTime lastaccessed) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.shorten; | |
| import java.time.LocalDateTime; | |
| import jakarta.persistence.Entity; | |
| import jakarta.persistence.Table; | |
| import jakarta.persistence.GeneratedValue; | |
| import jakarta.persistence.GenerationType; | |
| import jakarta.persistence.Id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "net/http" | |
| "strings" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| type ShortenUrlRequestBody struct { | |
| SrcUrl string `json:"srcUrl"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { shorten } from "./service.js"; | |
| export async function handleRequest(ctx) { | |
| if (!(ctx.body && ctx.body.srcUrl)) { | |
| ctx.set.status = 400; | |
| return { errMsg: "Parameter 'srcUrl' is missing" }; | |
| } | |
| const srcUrl = ctx.body.srcUrl; | |
| if (srcUrl.length > 250) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { shorten } from "./service.js"; | |
| import { HTTPException } from "https://deno.land/x/hono/mod.ts"; | |
| export async function handleRequest(ctx) { | |
| const ctHdr = ctx.req.header("content-type"); | |
| if (!(ctHdr && ctHdr.includes("application/json"))) { | |
| throw new HTTPException(415, { message: "Content type JSON is required" }); | |
| } | |
| let reqBody; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from service import shorten | |
| from fastapi import FastAPI, Response, Request, HTTPException | |
| from fastapi.responses import JSONResponse | |
| async def handleRequest(reqBody: any): | |
| if not reqBody.srcUrl: | |
| raise HTTPException(status_code=400, detail="Parameter 'srcUrl' is missing") | |
| srcUrl = reqBody.srcUrl |