This file contains 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
You are a senior TypeScript programmer with experience in the routing-controllers library (an OOP based library based on Express.js, similar to Nest.js) and a preference for clean programming and design patterns. | |
Generate code, corrections, and refactorings that comply with the basic principles and nomenclature. | |
## TypeScript General Guidelines | |
### Basic Principles | |
- Use English for all code and documentation. | |
- Always declare the type of each variable and function (parameters and return value). |
This file contains 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
const axios = require("axios"); | |
const fs = require("fs").promises; | |
const path = require("path"); | |
const { open } = require("fs/promises"); | |
function pgbr(prcnt, dn = "█", rm = "░", length = 100, hint = "") { | |
const d = Math.floor(prcnt * length); | |
const r = length - d; | |
process.stdout.write( | |
`\r${hint} |${dn.repeat(d)}${rm.repeat(r)}| ${Math.floor(prcnt * 100)}%` |
This file contains 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 { authMiddleware } from "@clerk/nextjs"; | |
import { ratelimit } from "./utils/redis"; | |
import { NextResponse } from "next/server"; | |
export default authMiddleware({ | |
async afterAuth(_auth, req, evt) { | |
const ip = req.ip ?? "127.0.0.1"; | |
if (req.nextUrl.pathname === "/api/blocked") return NextResponse.next(req); |
This file contains 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
function checkSign(num) { | |
// eğer 0'dan büyükse, "positive" stringi döndür ( if ) | |
return num > 0 ? "positive" | |
// eğer 0'dan küçükse, "negative" stringi döndür (else if) | |
: num < 0 ? "negative" | |
// kalan tüm durumlarda "zero" döndür ( else ) | |
: "zero" | |
} |
This file contains 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
function checkSign(num) { | |
} | |
checkSign(10); |
This file contains 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
// uygun girinti olmadan kullanmak kodun okunuşunu zorlaştırır, | |
// dolayısıyla aşağıdaki gibi yazmak yerine | |
// girintili bir şekilde, bir üstteki örnekte gibi yazmak en iyisidir | |
function findGreaterOrEqual(a, b) { | |
return (a === b) ? "a and b are equal" : (a > b) ? "a is greater" : "b is greater"; | |
} |
This file contains 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
function findGreaterOrEqual(a, b) { | |
// if gibi düşünelim | |
// " a === b " true döndüğünde, "a and b are equal" döndürür | |
return (a === b) ? "a and b are equal" | |
// else if gibi düşünelim | |
// " a > b " true döndüğünde, "a is greater" döndürür | |
: (a > b) ? "a is greater" | |
This file contains 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
function findGreaterOrEqual(a, b) { | |
if (a === b) { | |
return "a and b are equal"; | |
} | |
else if (a > b) { | |
return "a is greater"; | |
} | |
else { | |
return "b is greater"; | |
} |
This file contains 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
function checkEqual(a, b) { | |
// a == b ise, yani "a == b" true dönerse, "Equal" stringi döndür | |
// else, yani diğer durumlarda, "Not equal" stringi döndür | |
return a == b ? "Equal" : "Not Equal"; | |
} | |
console.log(checkEqual(1, 2)); | |
// Not Equal |
This file contains 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
function checkEqual(a, b) { | |
} | |
checkEqual(1, 2); |
NewerOlder