├── Readme.md ├── backend ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── prisma │ ├── migrations │ │ ├── 20240708062825_test_1 │ │ │ └── migration.sql │ │ ├── 20240708070650_test1 │ │ │ └── migration.sql │ │ └── migration_lock.toml │ └── schema.prisma ├── src │ ├── index.ts │ └── routes │ │ ├── post.ts │ │ └── user.ts ├── tsconfig.json └── wrangler.toml ├── commons ├── .gitignore ├── .npmignore ├── node_modules │ ├── .package-lock.json │ ├── @arinjain111 │ │ └── medium-commons │ │ │ ├── package.json │ │ │ └── tsconfig.json │ └── zod │ │ ├── LICENSE │ │ ├── README.md │ │ ├── index.d.ts │ │ ├── lib │ │ ├── ZodError.d.ts │ │ ├── ZodError.js │ │ ├── __tests__ │ │ │ ├── Mocker.d.ts │ │ │ └── Mocker.js │ │ ├── benchmarks │ │ │ ├── datetime.d.ts │ │ │ ├── datetime.js │ │ │ ├── discriminatedUnion.d.ts │ │ │ ├── discriminatedUnion.js │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── ipv4.d.ts │ │ │ ├── ipv4.js │ │ │ ├── object.d.ts │ │ │ ├── object.js │ │ │ ├── primitives.d.ts │ │ │ ├── primitives.js │ │ │ ├── realworld.d.ts │ │ │ ├── realworld.js │ │ │ ├── string.d.ts │ │ │ ├── string.js │ │ │ ├── union.d.ts │ │ │ └── union.js │ │ ├── errors.d.ts │ │ ├── errors.js │ │ ├── external.d.ts │ │ ├── external.js │ │ ├── helpers │ │ │ ├── enumUtil.d.ts │ │ │ ├── enumUtil.js │ │ │ ├── errorUtil.d.ts │ │ │ ├── errorUtil.js │ │ │ ├── parseUtil.d.ts │ │ │ ├── parseUtil.js │ │ │ ├── partialUtil.d.ts │ │ │ ├── partialUtil.js │ │ │ ├── typeAliases.d.ts │ │ │ ├── typeAliases.js │ │ │ ├── util.d.ts │ │ │ └── util.js │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.mjs │ │ ├── index.umd.js │ │ ├── locales │ │ │ ├── en.d.ts │ │ │ └── en.js │ │ ├── types.d.ts │ │ └── types.js │ │ └── package.json ├── package-lock.json ├── package.json ├── src │ └── index.ts └── tsconfig.json └── frontend ├── .eslintrc.cjs ├── .gitignore ├── README.md ├── dist ├── assets │ ├── Write-BiAatf6L.png │ ├── index-BbdDSyxM.css │ └── index-C8xY6_vk.js ├── index.html └── vite.svg ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── public └── vite.svg ├── src ├── App.css ├── App.tsx ├── HomepageComponent │ ├── Navbar.tsx │ ├── OurStory.tsx │ └── Write.tsx ├── Hooks │ └── Index.ts ├── assets │ ├── Write.png │ └── react.svg ├── components │ ├── AppBar.tsx │ ├── Auth.tsx │ ├── DevelopmentPage.tsx │ ├── PostCard.tsx │ ├── PostPage.tsx │ ├── PostPageSkeleton.tsx │ ├── PostSkeleton.tsx │ └── Quote.tsx ├── config.ts ├── index.css ├── main.tsx ├── pages │ ├── Home.tsx │ ├── Post.tsx │ ├── Posts.tsx │ ├── Signin.tsx │ └── Signup.tsx └── vite-env.d.ts ├── tailwind.config.js ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts /Readme.md: -------------------------------------------------------------------------------- 1 | # Medium like website 2 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | 4 | # dev 5 | .yarn/ 6 | !.yarn/releases 7 | .vscode/* 8 | !.vscode/launch.json 9 | !.vscode/*.code-snippets 10 | .idea/workspace.xml 11 | .idea/usage.statistics.xml 12 | .idea/shelf 13 | 14 | # deps 15 | node_modules/ 16 | .wrangler 17 | 18 | # env 19 | .env 20 | .env.production 21 | .dev.vars 22 | 23 | # logs 24 | logs/ 25 | *.log 26 | npm-debug.log* 27 | yarn-debug.log* 28 | yarn-error.log* 29 | pnpm-debug.log* 30 | lerna-debug.log* 31 | 32 | # misc 33 | .DS_Store 34 | -------------------------------------------------------------------------------- /backend/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run dev 4 | ``` 5 | 6 | ``` 7 | npm run deploy 8 | ``` 9 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "scripts": { 4 | "dev": "wrangler dev src/index.ts", 5 | "deploy": "wrangler deploy --minify src/index.ts" 6 | }, 7 | "dependencies": { 8 | "@arinjain111/medium-commons": "^1.0.0", 9 | "@prisma/client": "^5.16.1", 10 | "@prisma/extension-accelerate": "^1.1.0", 11 | "hono": "^4.4.9", 12 | "jsonwebtoken": "^9.0.2", 13 | "prisma": "^5.16.1", 14 | "zod": "^3.23.8" 15 | }, 16 | "devDependencies": { 17 | "@cloudflare/workers-types": "^4.20240529.0", 18 | "wrangler": "^3.57.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /backend/prisma/migrations/20240708062825_test_1/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "User" ( 3 | "id" SERIAL NOT NULL, 4 | "email" TEXT NOT NULL, 5 | "name" TEXT, 6 | "password" TEXT NOT NULL, 7 | 8 | CONSTRAINT "User_pkey" PRIMARY KEY ("id") 9 | ); 10 | 11 | -- CreateTable 12 | CREATE TABLE "Post" ( 13 | "id" TEXT NOT NULL, 14 | "authorId" INTEGER NOT NULL, 15 | "title" TEXT NOT NULL, 16 | "content" TEXT NOT NULL, 17 | "published" BOOLEAN NOT NULL DEFAULT false, 18 | 19 | CONSTRAINT "Post_pkey" PRIMARY KEY ("id") 20 | ); 21 | 22 | -- CreateIndex 23 | CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); 24 | 25 | -- AddForeignKey 26 | ALTER TABLE "Post" ADD CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; 27 | -------------------------------------------------------------------------------- /backend/prisma/migrations/20240708070650_test1/migration.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Warnings: 3 | 4 | - The primary key for the `Post` table will be changed. If it partially fails, the table could be left without primary key constraint. 5 | - The `id` column on the `Post` table would be dropped and recreated. This will lead to data loss if there is data in the column. 6 | 7 | */ 8 | -- AlterTable 9 | ALTER TABLE "Post" DROP CONSTRAINT "Post_pkey", 10 | DROP COLUMN "id", 11 | ADD COLUMN "id" SERIAL NOT NULL, 12 | ADD CONSTRAINT "Post_pkey" PRIMARY KEY ("id"); 13 | -------------------------------------------------------------------------------- /backend/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "postgresql" -------------------------------------------------------------------------------- /backend/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? 5 | // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init 6 | 7 | generator client { 8 | provider = "prisma-client-js" 9 | } 10 | 11 | datasource db { 12 | provider = "postgresql" 13 | url = env("DATABASE_URL") 14 | } 15 | 16 | model User { 17 | id Int @id @default(autoincrement()) 18 | email String @unique 19 | name String? 20 | password String 21 | posts Post[] 22 | } 23 | 24 | model Post { 25 | id Int @id @default(autoincrement()) 26 | authorId Int 27 | title String 28 | content String 29 | published Boolean @default(false) 30 | author User @relation(fields: [authorId], references: [id]) 31 | } -------------------------------------------------------------------------------- /backend/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import {userRouter} from './routes/user' 3 | import { blogRouter } from './routes/post' 4 | import { cors } from 'hono/cors'; 5 | 6 | const app = new Hono<{ 7 | Bindings: { 8 | DATABASE_URL: string, 9 | JWT_SECRET: string, 10 | }, 11 | }>(); 12 | app.use("/*", cors()); 13 | app.route("/api/v1/user", userRouter); 14 | app.route("/api/v1/post", blogRouter); 15 | 16 | export default app 17 | -------------------------------------------------------------------------------- /backend/src/routes/post.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from "hono" 2 | import { PrismaClient } from '@prisma/client/edge' 3 | import { withAccelerate } from '@prisma/extension-accelerate' 4 | import { verify } from 'hono/jwt' 5 | 6 | export const blogRouter = new Hono<{ 7 | Bindings: { 8 | DATABASE_URL: string, 9 | JWT_SECRET: string, 10 | }, 11 | Variables: { 12 | userId: string 13 | } 14 | }>() 15 | 16 | blogRouter.use('/*', async (c, next) => { 17 | const authorId = c.req.header("Authorization") || ""; 18 | const user = await verify (authorId, c.env.JWT_SECRET) 19 | try { 20 | if(user) { 21 | c.set("userId", user.id); 22 | await next(); 23 | } else { 24 | c.status(403) 25 | return c.json({ 26 | message: "you are not logged in" 27 | }); 28 | } 29 | } catch(e) { 30 | console.log(e); 31 | c.status(500) 32 | return c.json({ 33 | message: "internal server error" 34 | }); 35 | } 36 | }); 37 | 38 | blogRouter.post('/', async (c) => { 39 | const body = await c.req.json() 40 | const authorId = c.get("userId"); 41 | const prisma = new PrismaClient({ 42 | datasourceUrl: c.env.DATABASE_URL, 43 | }).$extends(withAccelerate()) 44 | 45 | const post = await prisma.post.create({ 46 | data: { 47 | title: body.title, 48 | content: body.content, 49 | authorId: Number(authorId), 50 | } 51 | }); 52 | 53 | return c.json({ 54 | id: post.id, 55 | }) 56 | }); 57 | 58 | blogRouter.put('/', async (c) => { 59 | const body = await c.req.json() 60 | const prisma = new PrismaClient({ 61 | datasourceUrl: c.env.DATABASE_URL, 62 | }).$extends(withAccelerate()) 63 | 64 | const post = await prisma.post.update({ 65 | where:{ 66 | id: body.id, 67 | }, 68 | data: { 69 | title: body.title, 70 | content: body.content 71 | } 72 | }); 73 | return c.json({ 74 | id: post.id, 75 | }) 76 | }) 77 | 78 | //add pagenation 79 | blogRouter.get('/bulk', async(c) => { 80 | const prisma = new PrismaClient({ 81 | datasourceUrl: c.env.DATABASE_URL, 82 | }).$extends(withAccelerate()) 83 | 84 | const posts = await prisma.post.findMany({ 85 | select: { 86 | content: true, 87 | title: true, 88 | id: true, 89 | author: { 90 | select: { 91 | name: true 92 | } 93 | } 94 | } 95 | }); 96 | 97 | return c.json({posts}); 98 | }) 99 | 100 | blogRouter.get('/:id', async (c) => { 101 | const id = c.req.param("id") 102 | const prisma = new PrismaClient({ 103 | datasourceUrl: c.env.DATABASE_URL, 104 | }).$extends(withAccelerate()) 105 | try { 106 | const post = await prisma.post.findFirst({ 107 | where: { 108 | id: Number(id), 109 | }, 110 | select: { 111 | id: true, 112 | title: true, 113 | content: true, 114 | author: { 115 | select: { 116 | name: true 117 | } 118 | } 119 | } 120 | }); 121 | return c.json({ 122 | post 123 | }) 124 | } catch(e) { 125 | c.status(411) 126 | return c.json({ 127 | message: "Error while fetching blog post" 128 | }); 129 | } 130 | }) 131 | 132 | export default blogRouter; -------------------------------------------------------------------------------- /backend/src/routes/user.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from "hono"; 2 | import { PrismaClient } from '@prisma/client/edge' 3 | import { withAccelerate } from '@prisma/extension-accelerate' 4 | import { sign } from 'hono/jwt' 5 | import { signupInput } from '@arinjain111/medium-commons' 6 | 7 | export const userRouter = new Hono<{ 8 | Bindings: { 9 | DATABASE_URL: string, 10 | JWT_SECRET: string 11 | } 12 | }>(); 13 | 14 | userRouter.post('/signup', async (c) => { 15 | 16 | const body = await c.req.json(); 17 | const {success} = signupInput.safeParse(body); 18 | if(!success) { 19 | c.status(403) 20 | return c.json({ 21 | message: "incorrect input" 22 | }) 23 | } 24 | const prisma = new PrismaClient({ 25 | datasourceUrl: c.env.DATABASE_URL, 26 | }).$extends(withAccelerate()); 27 | try { 28 | const user = await prisma.user.create({ 29 | data: { 30 | email: body.email, 31 | password: body.password, 32 | name: body.name 33 | } 34 | }); 35 | const jwt = await sign({ id: user.id }, c.env.JWT_SECRET); 36 | return c.text(jwt); 37 | } catch(e) { 38 | c.status(403); 39 | return c.json({error: "User already exists with this email"}); 40 | } 41 | }); 42 | 43 | userRouter.post('/signin', async (c) => { 44 | const prisma = new PrismaClient({ 45 | datasourceUrl: c.env.DATABASE_URL, 46 | }).$extends(withAccelerate()); 47 | 48 | const body = await c.req.json() 49 | const user = await prisma.user.findFirst({ 50 | where: { 51 | email: body.email, 52 | password: body.password, 53 | } 54 | }) 55 | if(!user) { 56 | c.status(404) 57 | return c.json({error: "user not found"}) 58 | } 59 | const jwt = await sign({id: user.id}, c.env.JWT_SECRET); 60 | return c.text(jwt) 61 | }); -------------------------------------------------------------------------------- /backend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "skipLibCheck": true, 8 | "lib": [ 9 | "ESNext" 10 | ], 11 | "types": [ 12 | "@cloudflare/workers-types" 13 | ], 14 | "jsx": "react-jsx", 15 | "jsxImportSource": "hono/jsx" 16 | }, 17 | } -------------------------------------------------------------------------------- /backend/wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "backend" 2 | compatibility_date = "2023-12-01" 3 | 4 | [vars] 5 | DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlfa2V5IjoiN2Q5MTgzNjQtMDM2NC00NDM1LWFjMDgtMTRjODFmOWQ5YTFiIiwidGVuYW50X2lkIjoiOWQyYmVkNmRjMWM2OGRhM2Y1OWFkZWYzYjMzOGYwZTUwYzcyOWJkMjc4YTZlMGIwNmFhMzk4ODhmOWJmYzQwYSIsImludGVybmFsX3NlY3JldCI6ImQyNWQ5MTg1LTVmYzItNGI1OS04MDBhLTZkMjExNDU2Y2E5NyJ9.59QwJNPp6kjmkGafeN9K4WAZijn1IBKKQTvI9FbVbeo" 6 | 7 | JWT_SECRET = "asdasd" 8 | 9 | [placement] 10 | mode = "smart" -------------------------------------------------------------------------------- /commons/.gitignore: -------------------------------------------------------------------------------- 1 | node-modeules 2 | dist 3 | -------------------------------------------------------------------------------- /commons/.npmignore: -------------------------------------------------------------------------------- 1 | src -------------------------------------------------------------------------------- /commons/node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arinjain111/medium-commons", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "node_modules/@arinjain111/medium-commons": { 8 | "version": "1.0.0", 9 | "resolved": "https://registry.npmjs.org/@arinjain111/medium-commons/-/medium-commons-1.0.0.tgz", 10 | "integrity": "sha512-tPTsR8XtHWmk7opbe1J8wdQs1tjpZShupwvzUsk0tZcJIJOkiNyWZLRYRpgWQni5RwxQFNfpRqWegRelazZ8Uw==", 11 | "dependencies": { 12 | "zod": "^3.23.8" 13 | } 14 | }, 15 | "node_modules/zod": { 16 | "version": "3.23.8", 17 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", 18 | "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", 19 | "funding": { 20 | "url": "https://github.com/sponsors/colinhacks" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /commons/node_modules/@arinjain111/medium-commons/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arinjain111/medium-commons", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "zod": "^3.23.8" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /commons/node_modules/@arinjain111/medium-commons/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | "rootDir": "./src", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /commons/node_modules/zod/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Colin McDonnell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /commons/node_modules/zod/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./lib"; 2 | export as namespace Zod; 3 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/ZodError.d.ts: -------------------------------------------------------------------------------- 1 | import type { TypeOf, ZodType } from "."; 2 | import { Primitive } from "./helpers/typeAliases"; 3 | import { util, ZodParsedType } from "./helpers/util"; 4 | declare type allKeys = T extends any ? keyof T : never; 5 | export declare type inferFlattenedErrors, U = string> = typeToFlattenedError, U>; 6 | export declare type typeToFlattenedError = { 7 | formErrors: U[]; 8 | fieldErrors: { 9 | [P in allKeys]?: U[]; 10 | }; 11 | }; 12 | export declare const ZodIssueCode: { 13 | invalid_type: "invalid_type"; 14 | invalid_literal: "invalid_literal"; 15 | custom: "custom"; 16 | invalid_union: "invalid_union"; 17 | invalid_union_discriminator: "invalid_union_discriminator"; 18 | invalid_enum_value: "invalid_enum_value"; 19 | unrecognized_keys: "unrecognized_keys"; 20 | invalid_arguments: "invalid_arguments"; 21 | invalid_return_type: "invalid_return_type"; 22 | invalid_date: "invalid_date"; 23 | invalid_string: "invalid_string"; 24 | too_small: "too_small"; 25 | too_big: "too_big"; 26 | invalid_intersection_types: "invalid_intersection_types"; 27 | not_multiple_of: "not_multiple_of"; 28 | not_finite: "not_finite"; 29 | }; 30 | export declare type ZodIssueCode = keyof typeof ZodIssueCode; 31 | export declare type ZodIssueBase = { 32 | path: (string | number)[]; 33 | message?: string; 34 | }; 35 | export interface ZodInvalidTypeIssue extends ZodIssueBase { 36 | code: typeof ZodIssueCode.invalid_type; 37 | expected: ZodParsedType; 38 | received: ZodParsedType; 39 | } 40 | export interface ZodInvalidLiteralIssue extends ZodIssueBase { 41 | code: typeof ZodIssueCode.invalid_literal; 42 | expected: unknown; 43 | received: unknown; 44 | } 45 | export interface ZodUnrecognizedKeysIssue extends ZodIssueBase { 46 | code: typeof ZodIssueCode.unrecognized_keys; 47 | keys: string[]; 48 | } 49 | export interface ZodInvalidUnionIssue extends ZodIssueBase { 50 | code: typeof ZodIssueCode.invalid_union; 51 | unionErrors: ZodError[]; 52 | } 53 | export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase { 54 | code: typeof ZodIssueCode.invalid_union_discriminator; 55 | options: Primitive[]; 56 | } 57 | export interface ZodInvalidEnumValueIssue extends ZodIssueBase { 58 | received: string | number; 59 | code: typeof ZodIssueCode.invalid_enum_value; 60 | options: (string | number)[]; 61 | } 62 | export interface ZodInvalidArgumentsIssue extends ZodIssueBase { 63 | code: typeof ZodIssueCode.invalid_arguments; 64 | argumentsError: ZodError; 65 | } 66 | export interface ZodInvalidReturnTypeIssue extends ZodIssueBase { 67 | code: typeof ZodIssueCode.invalid_return_type; 68 | returnTypeError: ZodError; 69 | } 70 | export interface ZodInvalidDateIssue extends ZodIssueBase { 71 | code: typeof ZodIssueCode.invalid_date; 72 | } 73 | export declare type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "base64" | { 74 | includes: string; 75 | position?: number; 76 | } | { 77 | startsWith: string; 78 | } | { 79 | endsWith: string; 80 | }; 81 | export interface ZodInvalidStringIssue extends ZodIssueBase { 82 | code: typeof ZodIssueCode.invalid_string; 83 | validation: StringValidation; 84 | } 85 | export interface ZodTooSmallIssue extends ZodIssueBase { 86 | code: typeof ZodIssueCode.too_small; 87 | minimum: number | bigint; 88 | inclusive: boolean; 89 | exact?: boolean; 90 | type: "array" | "string" | "number" | "set" | "date" | "bigint"; 91 | } 92 | export interface ZodTooBigIssue extends ZodIssueBase { 93 | code: typeof ZodIssueCode.too_big; 94 | maximum: number | bigint; 95 | inclusive: boolean; 96 | exact?: boolean; 97 | type: "array" | "string" | "number" | "set" | "date" | "bigint"; 98 | } 99 | export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase { 100 | code: typeof ZodIssueCode.invalid_intersection_types; 101 | } 102 | export interface ZodNotMultipleOfIssue extends ZodIssueBase { 103 | code: typeof ZodIssueCode.not_multiple_of; 104 | multipleOf: number | bigint; 105 | } 106 | export interface ZodNotFiniteIssue extends ZodIssueBase { 107 | code: typeof ZodIssueCode.not_finite; 108 | } 109 | export interface ZodCustomIssue extends ZodIssueBase { 110 | code: typeof ZodIssueCode.custom; 111 | params?: { 112 | [k: string]: any; 113 | }; 114 | } 115 | export declare type DenormalizedError = { 116 | [k: string]: DenormalizedError | string[]; 117 | }; 118 | export declare type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue; 119 | export declare type ZodIssue = ZodIssueOptionalMessage & { 120 | fatal?: boolean; 121 | message: string; 122 | }; 123 | export declare const quotelessJson: (obj: any) => string; 124 | declare type recursiveZodFormattedError = T extends [any, ...any[]] ? { 125 | [K in keyof T]?: ZodFormattedError; 126 | } : T extends any[] ? { 127 | [k: number]: ZodFormattedError; 128 | } : T extends object ? { 129 | [K in keyof T]?: ZodFormattedError; 130 | } : unknown; 131 | export declare type ZodFormattedError = { 132 | _errors: U[]; 133 | } & recursiveZodFormattedError>; 134 | export declare type inferFormattedError, U = string> = ZodFormattedError, U>; 135 | export declare class ZodError extends Error { 136 | issues: ZodIssue[]; 137 | get errors(): ZodIssue[]; 138 | constructor(issues: ZodIssue[]); 139 | format(): ZodFormattedError; 140 | format(mapper: (issue: ZodIssue) => U): ZodFormattedError; 141 | static create: (issues: ZodIssue[]) => ZodError; 142 | static assert(value: unknown): asserts value is ZodError; 143 | toString(): string; 144 | get message(): string; 145 | get isEmpty(): boolean; 146 | addIssue: (sub: ZodIssue) => void; 147 | addIssues: (subs?: ZodIssue[]) => void; 148 | flatten(): typeToFlattenedError; 149 | flatten(mapper?: (issue: ZodIssue) => U): typeToFlattenedError; 150 | get formErrors(): typeToFlattenedError; 151 | } 152 | declare type stripPath = T extends any ? util.OmitKeys : never; 153 | export declare type IssueData = stripPath & { 154 | path?: (string | number)[]; 155 | fatal?: boolean; 156 | }; 157 | export declare type ErrorMapCtx = { 158 | defaultError: string; 159 | data: any; 160 | }; 161 | export declare type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => { 162 | message: string; 163 | }; 164 | export {}; 165 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/ZodError.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0; 4 | const util_1 = require("./helpers/util"); 5 | exports.ZodIssueCode = util_1.util.arrayToEnum([ 6 | "invalid_type", 7 | "invalid_literal", 8 | "custom", 9 | "invalid_union", 10 | "invalid_union_discriminator", 11 | "invalid_enum_value", 12 | "unrecognized_keys", 13 | "invalid_arguments", 14 | "invalid_return_type", 15 | "invalid_date", 16 | "invalid_string", 17 | "too_small", 18 | "too_big", 19 | "invalid_intersection_types", 20 | "not_multiple_of", 21 | "not_finite", 22 | ]); 23 | const quotelessJson = (obj) => { 24 | const json = JSON.stringify(obj, null, 2); 25 | return json.replace(/"([^"]+)":/g, "$1:"); 26 | }; 27 | exports.quotelessJson = quotelessJson; 28 | class ZodError extends Error { 29 | constructor(issues) { 30 | super(); 31 | this.issues = []; 32 | this.addIssue = (sub) => { 33 | this.issues = [...this.issues, sub]; 34 | }; 35 | this.addIssues = (subs = []) => { 36 | this.issues = [...this.issues, ...subs]; 37 | }; 38 | const actualProto = new.target.prototype; 39 | if (Object.setPrototypeOf) { 40 | // eslint-disable-next-line ban/ban 41 | Object.setPrototypeOf(this, actualProto); 42 | } 43 | else { 44 | this.__proto__ = actualProto; 45 | } 46 | this.name = "ZodError"; 47 | this.issues = issues; 48 | } 49 | get errors() { 50 | return this.issues; 51 | } 52 | format(_mapper) { 53 | const mapper = _mapper || 54 | function (issue) { 55 | return issue.message; 56 | }; 57 | const fieldErrors = { _errors: [] }; 58 | const processError = (error) => { 59 | for (const issue of error.issues) { 60 | if (issue.code === "invalid_union") { 61 | issue.unionErrors.map(processError); 62 | } 63 | else if (issue.code === "invalid_return_type") { 64 | processError(issue.returnTypeError); 65 | } 66 | else if (issue.code === "invalid_arguments") { 67 | processError(issue.argumentsError); 68 | } 69 | else if (issue.path.length === 0) { 70 | fieldErrors._errors.push(mapper(issue)); 71 | } 72 | else { 73 | let curr = fieldErrors; 74 | let i = 0; 75 | while (i < issue.path.length) { 76 | const el = issue.path[i]; 77 | const terminal = i === issue.path.length - 1; 78 | if (!terminal) { 79 | curr[el] = curr[el] || { _errors: [] }; 80 | // if (typeof el === "string") { 81 | // curr[el] = curr[el] || { _errors: [] }; 82 | // } else if (typeof el === "number") { 83 | // const errorArray: any = []; 84 | // errorArray._errors = []; 85 | // curr[el] = curr[el] || errorArray; 86 | // } 87 | } 88 | else { 89 | curr[el] = curr[el] || { _errors: [] }; 90 | curr[el]._errors.push(mapper(issue)); 91 | } 92 | curr = curr[el]; 93 | i++; 94 | } 95 | } 96 | } 97 | }; 98 | processError(this); 99 | return fieldErrors; 100 | } 101 | static assert(value) { 102 | if (!(value instanceof ZodError)) { 103 | throw new Error(`Not a ZodError: ${value}`); 104 | } 105 | } 106 | toString() { 107 | return this.message; 108 | } 109 | get message() { 110 | return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2); 111 | } 112 | get isEmpty() { 113 | return this.issues.length === 0; 114 | } 115 | flatten(mapper = (issue) => issue.message) { 116 | const fieldErrors = {}; 117 | const formErrors = []; 118 | for (const sub of this.issues) { 119 | if (sub.path.length > 0) { 120 | fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; 121 | fieldErrors[sub.path[0]].push(mapper(sub)); 122 | } 123 | else { 124 | formErrors.push(mapper(sub)); 125 | } 126 | } 127 | return { formErrors, fieldErrors }; 128 | } 129 | get formErrors() { 130 | return this.flatten(); 131 | } 132 | } 133 | exports.ZodError = ZodError; 134 | ZodError.create = (issues) => { 135 | const error = new ZodError(issues); 136 | return error; 137 | }; 138 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/__tests__/Mocker.d.ts: -------------------------------------------------------------------------------- 1 | export declare class Mocker { 2 | pick: (...args: any[]) => any; 3 | get string(): string; 4 | get number(): number; 5 | get bigint(): bigint; 6 | get boolean(): boolean; 7 | get date(): Date; 8 | get symbol(): symbol; 9 | get null(): null; 10 | get undefined(): undefined; 11 | get stringOptional(): any; 12 | get stringNullable(): any; 13 | get numberOptional(): any; 14 | get numberNullable(): any; 15 | get booleanOptional(): any; 16 | get booleanNullable(): any; 17 | } 18 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/__tests__/Mocker.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Mocker = void 0; 4 | function getRandomInt(max) { 5 | return Math.floor(Math.random() * Math.floor(max)); 6 | } 7 | const testSymbol = Symbol("test"); 8 | class Mocker { 9 | constructor() { 10 | this.pick = (...args) => { 11 | return args[getRandomInt(args.length)]; 12 | }; 13 | } 14 | get string() { 15 | return Math.random().toString(36).substring(7); 16 | } 17 | get number() { 18 | return Math.random() * 100; 19 | } 20 | get bigint() { 21 | return BigInt(Math.floor(Math.random() * 10000)); 22 | } 23 | get boolean() { 24 | return Math.random() < 0.5; 25 | } 26 | get date() { 27 | return new Date(Math.floor(Date.now() * Math.random())); 28 | } 29 | get symbol() { 30 | return testSymbol; 31 | } 32 | get null() { 33 | return null; 34 | } 35 | get undefined() { 36 | return undefined; 37 | } 38 | get stringOptional() { 39 | return this.pick(this.string, this.undefined); 40 | } 41 | get stringNullable() { 42 | return this.pick(this.string, this.null); 43 | } 44 | get numberOptional() { 45 | return this.pick(this.number, this.undefined); 46 | } 47 | get numberNullable() { 48 | return this.pick(this.number, this.null); 49 | } 50 | get booleanOptional() { 51 | return this.pick(this.boolean, this.undefined); 52 | } 53 | get booleanNullable() { 54 | return this.pick(this.boolean, this.null); 55 | } 56 | } 57 | exports.Mocker = Mocker; 58 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/datetime.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/datetime.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const datetimeValidationSuite = new benchmark_1.default.Suite("datetime"); 8 | const DATA = "2021-01-01"; 9 | const MONTHS_31 = new Set([1, 3, 5, 7, 8, 10, 12]); 10 | const MONTHS_30 = new Set([4, 6, 9, 11]); 11 | const simpleDatetimeRegex = /^(\d{4})-(\d{2})-(\d{2})$/; 12 | const datetimeRegexNoLeapYearValidation = /^\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\d|2\d))$/; 13 | const datetimeRegexWithLeapYearValidation = /^((\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\d|3[01])|(0[469]|11)-(0[1-9]|[12]\d|30)|(02)-(0[1-9]|1\d|2[0-8])))$/; 14 | datetimeValidationSuite 15 | .add("new Date()", () => { 16 | return !isNaN(new Date(DATA).getTime()); 17 | }) 18 | .add("regex (no validation)", () => { 19 | return simpleDatetimeRegex.test(DATA); 20 | }) 21 | .add("regex (no leap year)", () => { 22 | return datetimeRegexNoLeapYearValidation.test(DATA); 23 | }) 24 | .add("regex (w/ leap year)", () => { 25 | return datetimeRegexWithLeapYearValidation.test(DATA); 26 | }) 27 | .add("capture groups + code", () => { 28 | const match = DATA.match(simpleDatetimeRegex); 29 | if (!match) 30 | return false; 31 | // Extract year, month, and day from the capture groups 32 | const year = Number.parseInt(match[1], 10); 33 | const month = Number.parseInt(match[2], 10); // month is 0-indexed in JavaScript Date, so subtract 1 34 | const day = Number.parseInt(match[3], 10); 35 | if (month === 2) { 36 | if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) { 37 | return day <= 29; 38 | } 39 | return day <= 28; 40 | } 41 | if (MONTHS_30.has(month)) { 42 | return day <= 30; 43 | } 44 | if (MONTHS_31.has(month)) { 45 | return day <= 31; 46 | } 47 | return false; 48 | }) 49 | .on("cycle", (e) => { 50 | console.log(`${datetimeValidationSuite.name}: ${e.target}`); 51 | }); 52 | exports.default = { 53 | suites: [datetimeValidationSuite], 54 | }; 55 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/discriminatedUnion.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/discriminatedUnion.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const index_1 = require("../index"); 8 | const doubleSuite = new benchmark_1.default.Suite("z.discriminatedUnion: double"); 9 | const manySuite = new benchmark_1.default.Suite("z.discriminatedUnion: many"); 10 | const aSchema = index_1.z.object({ 11 | type: index_1.z.literal("a"), 12 | }); 13 | const objA = { 14 | type: "a", 15 | }; 16 | const bSchema = index_1.z.object({ 17 | type: index_1.z.literal("b"), 18 | }); 19 | const objB = { 20 | type: "b", 21 | }; 22 | const cSchema = index_1.z.object({ 23 | type: index_1.z.literal("c"), 24 | }); 25 | const objC = { 26 | type: "c", 27 | }; 28 | const dSchema = index_1.z.object({ 29 | type: index_1.z.literal("d"), 30 | }); 31 | const double = index_1.z.discriminatedUnion("type", [aSchema, bSchema]); 32 | const many = index_1.z.discriminatedUnion("type", [aSchema, bSchema, cSchema, dSchema]); 33 | doubleSuite 34 | .add("valid: a", () => { 35 | double.parse(objA); 36 | }) 37 | .add("valid: b", () => { 38 | double.parse(objB); 39 | }) 40 | .add("invalid: null", () => { 41 | try { 42 | double.parse(null); 43 | } 44 | catch (err) { } 45 | }) 46 | .add("invalid: wrong shape", () => { 47 | try { 48 | double.parse(objC); 49 | } 50 | catch (err) { } 51 | }) 52 | .on("cycle", (e) => { 53 | console.log(`${doubleSuite.name}: ${e.target}`); 54 | }); 55 | manySuite 56 | .add("valid: a", () => { 57 | many.parse(objA); 58 | }) 59 | .add("valid: c", () => { 60 | many.parse(objC); 61 | }) 62 | .add("invalid: null", () => { 63 | try { 64 | many.parse(null); 65 | } 66 | catch (err) { } 67 | }) 68 | .add("invalid: wrong shape", () => { 69 | try { 70 | many.parse({ type: "unknown" }); 71 | } 72 | catch (err) { } 73 | }) 74 | .on("cycle", (e) => { 75 | console.log(`${manySuite.name}: ${e.target}`); 76 | }); 77 | exports.default = { 78 | suites: [doubleSuite, manySuite], 79 | }; 80 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const datetime_1 = __importDefault(require("./datetime")); 7 | const discriminatedUnion_1 = __importDefault(require("./discriminatedUnion")); 8 | const ipv4_1 = __importDefault(require("./ipv4")); 9 | const object_1 = __importDefault(require("./object")); 10 | const primitives_1 = __importDefault(require("./primitives")); 11 | const realworld_1 = __importDefault(require("./realworld")); 12 | const string_1 = __importDefault(require("./string")); 13 | const union_1 = __importDefault(require("./union")); 14 | const argv = process.argv.slice(2); 15 | let suites = []; 16 | if (!argv.length) { 17 | suites = [ 18 | ...realworld_1.default.suites, 19 | ...primitives_1.default.suites, 20 | ...string_1.default.suites, 21 | ...object_1.default.suites, 22 | ...union_1.default.suites, 23 | ...discriminatedUnion_1.default.suites, 24 | ]; 25 | } 26 | else { 27 | if (argv.includes("--realworld")) { 28 | suites.push(...realworld_1.default.suites); 29 | } 30 | if (argv.includes("--primitives")) { 31 | suites.push(...primitives_1.default.suites); 32 | } 33 | if (argv.includes("--string")) { 34 | suites.push(...string_1.default.suites); 35 | } 36 | if (argv.includes("--object")) { 37 | suites.push(...object_1.default.suites); 38 | } 39 | if (argv.includes("--union")) { 40 | suites.push(...union_1.default.suites); 41 | } 42 | if (argv.includes("--discriminatedUnion")) { 43 | suites.push(...datetime_1.default.suites); 44 | } 45 | if (argv.includes("--datetime")) { 46 | suites.push(...datetime_1.default.suites); 47 | } 48 | if (argv.includes("--ipv4")) { 49 | suites.push(...ipv4_1.default.suites); 50 | } 51 | } 52 | for (const suite of suites) { 53 | suite.run({}); 54 | } 55 | // exit on Ctrl-C 56 | process.on("SIGINT", function () { 57 | console.log("Exiting..."); 58 | process.exit(); 59 | }); 60 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/ipv4.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/ipv4.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const suite = new benchmark_1.default.Suite("ipv4"); 8 | const DATA = "127.0.0.1"; 9 | const ipv4RegexA = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; 10 | const ipv4RegexB = /^(?:(?:(?=(25[0-5]))\1|(?=(2[0-4][0-9]))\2|(?=(1[0-9]{2}))\3|(?=([0-9]{1,2}))\4)\.){3}(?:(?=(25[0-5]))\5|(?=(2[0-4][0-9]))\6|(?=(1[0-9]{2}))\7|(?=([0-9]{1,2}))\8)$/; 11 | const ipv4RegexC = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/; 12 | const ipv4RegexD = /^(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/; 13 | const ipv4RegexE = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)$/; 14 | const ipv4RegexF = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/; 15 | const ipv4RegexG = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/; 16 | const ipv4RegexH = /^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$/; 17 | const ipv4RegexI = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/; 18 | suite 19 | .add("A", () => { 20 | return ipv4RegexA.test(DATA); 21 | }) 22 | .add("B", () => { 23 | return ipv4RegexB.test(DATA); 24 | }) 25 | .add("C", () => { 26 | return ipv4RegexC.test(DATA); 27 | }) 28 | .add("D", () => { 29 | return ipv4RegexD.test(DATA); 30 | }) 31 | .add("E", () => { 32 | return ipv4RegexE.test(DATA); 33 | }) 34 | .add("F", () => { 35 | return ipv4RegexF.test(DATA); 36 | }) 37 | .add("G", () => { 38 | return ipv4RegexG.test(DATA); 39 | }) 40 | .add("H", () => { 41 | return ipv4RegexH.test(DATA); 42 | }) 43 | .add("I", () => { 44 | return ipv4RegexI.test(DATA); 45 | }) 46 | .on("cycle", (e) => { 47 | console.log(`${suite.name}: ${e.target}`); 48 | }); 49 | exports.default = { 50 | suites: [suite], 51 | }; 52 | if (require.main === module) { 53 | suite.run(); 54 | } 55 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/object.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/object.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const index_1 = require("../index"); 8 | const emptySuite = new benchmark_1.default.Suite("z.object: empty"); 9 | const shortSuite = new benchmark_1.default.Suite("z.object: short"); 10 | const longSuite = new benchmark_1.default.Suite("z.object: long"); 11 | const empty = index_1.z.object({}); 12 | const short = index_1.z.object({ 13 | string: index_1.z.string(), 14 | }); 15 | const long = index_1.z.object({ 16 | string: index_1.z.string(), 17 | number: index_1.z.number(), 18 | boolean: index_1.z.boolean(), 19 | }); 20 | emptySuite 21 | .add("valid", () => { 22 | empty.parse({}); 23 | }) 24 | .add("valid: extra keys", () => { 25 | empty.parse({ string: "string" }); 26 | }) 27 | .add("invalid: null", () => { 28 | try { 29 | empty.parse(null); 30 | } 31 | catch (err) { } 32 | }) 33 | .on("cycle", (e) => { 34 | console.log(`${emptySuite.name}: ${e.target}`); 35 | }); 36 | shortSuite 37 | .add("valid", () => { 38 | short.parse({ string: "string" }); 39 | }) 40 | .add("valid: extra keys", () => { 41 | short.parse({ string: "string", number: 42 }); 42 | }) 43 | .add("invalid: null", () => { 44 | try { 45 | short.parse(null); 46 | } 47 | catch (err) { } 48 | }) 49 | .on("cycle", (e) => { 50 | console.log(`${shortSuite.name}: ${e.target}`); 51 | }); 52 | longSuite 53 | .add("valid", () => { 54 | long.parse({ string: "string", number: 42, boolean: true }); 55 | }) 56 | .add("valid: extra keys", () => { 57 | long.parse({ string: "string", number: 42, boolean: true, list: [] }); 58 | }) 59 | .add("invalid: null", () => { 60 | try { 61 | long.parse(null); 62 | } 63 | catch (err) { } 64 | }) 65 | .on("cycle", (e) => { 66 | console.log(`${longSuite.name}: ${e.target}`); 67 | }); 68 | exports.default = { 69 | suites: [emptySuite, shortSuite, longSuite], 70 | }; 71 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/primitives.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/primitives.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const Mocker_1 = require("../__tests__/Mocker"); 8 | const index_1 = require("../index"); 9 | const val = new Mocker_1.Mocker(); 10 | const enumSuite = new benchmark_1.default.Suite("z.enum"); 11 | const enumSchema = index_1.z.enum(["a", "b", "c"]); 12 | enumSuite 13 | .add("valid", () => { 14 | enumSchema.parse("a"); 15 | }) 16 | .add("invalid", () => { 17 | try { 18 | enumSchema.parse("x"); 19 | } 20 | catch (e) { } 21 | }) 22 | .on("cycle", (e) => { 23 | console.log(`z.enum: ${e.target}`); 24 | }); 25 | const longEnumSuite = new benchmark_1.default.Suite("long z.enum"); 26 | const longEnumSchema = index_1.z.enum([ 27 | "one", 28 | "two", 29 | "three", 30 | "four", 31 | "five", 32 | "six", 33 | "seven", 34 | "eight", 35 | "nine", 36 | "ten", 37 | "eleven", 38 | "twelve", 39 | "thirteen", 40 | "fourteen", 41 | "fifteen", 42 | "sixteen", 43 | "seventeen", 44 | ]); 45 | longEnumSuite 46 | .add("valid", () => { 47 | longEnumSchema.parse("five"); 48 | }) 49 | .add("invalid", () => { 50 | try { 51 | longEnumSchema.parse("invalid"); 52 | } 53 | catch (e) { } 54 | }) 55 | .on("cycle", (e) => { 56 | console.log(`long z.enum: ${e.target}`); 57 | }); 58 | const undefinedSuite = new benchmark_1.default.Suite("z.undefined"); 59 | const undefinedSchema = index_1.z.undefined(); 60 | undefinedSuite 61 | .add("valid", () => { 62 | undefinedSchema.parse(undefined); 63 | }) 64 | .add("invalid", () => { 65 | try { 66 | undefinedSchema.parse(1); 67 | } 68 | catch (e) { } 69 | }) 70 | .on("cycle", (e) => { 71 | console.log(`z.undefined: ${e.target}`); 72 | }); 73 | const literalSuite = new benchmark_1.default.Suite("z.literal"); 74 | const short = "short"; 75 | const bad = "bad"; 76 | const literalSchema = index_1.z.literal("short"); 77 | literalSuite 78 | .add("valid", () => { 79 | literalSchema.parse(short); 80 | }) 81 | .add("invalid", () => { 82 | try { 83 | literalSchema.parse(bad); 84 | } 85 | catch (e) { } 86 | }) 87 | .on("cycle", (e) => { 88 | console.log(`z.literal: ${e.target}`); 89 | }); 90 | const numberSuite = new benchmark_1.default.Suite("z.number"); 91 | const numberSchema = index_1.z.number().int(); 92 | numberSuite 93 | .add("valid", () => { 94 | numberSchema.parse(1); 95 | }) 96 | .add("invalid type", () => { 97 | try { 98 | numberSchema.parse("bad"); 99 | } 100 | catch (e) { } 101 | }) 102 | .add("invalid number", () => { 103 | try { 104 | numberSchema.parse(0.5); 105 | } 106 | catch (e) { } 107 | }) 108 | .on("cycle", (e) => { 109 | console.log(`z.number: ${e.target}`); 110 | }); 111 | const dateSuite = new benchmark_1.default.Suite("z.date"); 112 | const plainDate = index_1.z.date(); 113 | const minMaxDate = index_1.z 114 | .date() 115 | .min(new Date("2021-01-01")) 116 | .max(new Date("2030-01-01")); 117 | dateSuite 118 | .add("valid", () => { 119 | plainDate.parse(new Date()); 120 | }) 121 | .add("invalid", () => { 122 | try { 123 | plainDate.parse(1); 124 | } 125 | catch (e) { } 126 | }) 127 | .add("valid min and max", () => { 128 | minMaxDate.parse(new Date("2023-01-01")); 129 | }) 130 | .add("invalid min", () => { 131 | try { 132 | minMaxDate.parse(new Date("2019-01-01")); 133 | } 134 | catch (e) { } 135 | }) 136 | .add("invalid max", () => { 137 | try { 138 | minMaxDate.parse(new Date("2031-01-01")); 139 | } 140 | catch (e) { } 141 | }) 142 | .on("cycle", (e) => { 143 | console.log(`z.date: ${e.target}`); 144 | }); 145 | const symbolSuite = new benchmark_1.default.Suite("z.symbol"); 146 | const symbolSchema = index_1.z.symbol(); 147 | symbolSuite 148 | .add("valid", () => { 149 | symbolSchema.parse(val.symbol); 150 | }) 151 | .add("invalid", () => { 152 | try { 153 | symbolSchema.parse(1); 154 | } 155 | catch (e) { } 156 | }) 157 | .on("cycle", (e) => { 158 | console.log(`z.symbol: ${e.target}`); 159 | }); 160 | exports.default = { 161 | suites: [ 162 | enumSuite, 163 | longEnumSuite, 164 | undefinedSuite, 165 | literalSuite, 166 | numberSuite, 167 | dateSuite, 168 | symbolSuite, 169 | ], 170 | }; 171 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/realworld.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/realworld.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const index_1 = require("../index"); 8 | const shortSuite = new benchmark_1.default.Suite("realworld"); 9 | const People = index_1.z.array(index_1.z.object({ 10 | type: index_1.z.literal("person"), 11 | hair: index_1.z.enum(["blue", "brown"]), 12 | active: index_1.z.boolean(), 13 | name: index_1.z.string(), 14 | age: index_1.z.number().int(), 15 | hobbies: index_1.z.array(index_1.z.string()), 16 | address: index_1.z.object({ 17 | street: index_1.z.string(), 18 | zip: index_1.z.string(), 19 | country: index_1.z.string(), 20 | }), 21 | })); 22 | let i = 0; 23 | function num() { 24 | return ++i; 25 | } 26 | function str() { 27 | return (++i % 100).toString(16); 28 | } 29 | function array(fn) { 30 | return Array.from({ length: ++i % 10 }, () => fn()); 31 | } 32 | const people = Array.from({ length: 100 }, () => { 33 | return { 34 | type: "person", 35 | hair: i % 2 ? "blue" : "brown", 36 | active: !!(i % 2), 37 | name: str(), 38 | age: num(), 39 | hobbies: array(str), 40 | address: { 41 | street: str(), 42 | zip: str(), 43 | country: str(), 44 | }, 45 | }; 46 | }); 47 | shortSuite 48 | .add("valid", () => { 49 | People.parse(people); 50 | }) 51 | .on("cycle", (e) => { 52 | console.log(`${shortSuite.name}: ${e.target}`); 53 | }); 54 | exports.default = { 55 | suites: [shortSuite], 56 | }; 57 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/string.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const index_1 = require("../index"); 8 | const SUITE_NAME = "z.string"; 9 | const suite = new benchmark_1.default.Suite(SUITE_NAME); 10 | const empty = ""; 11 | const short = "short"; 12 | const long = "long".repeat(256); 13 | const manual = (str) => { 14 | if (typeof str !== "string") { 15 | throw new Error("Not a string"); 16 | } 17 | return str; 18 | }; 19 | const stringSchema = index_1.z.string(); 20 | const optionalStringSchema = index_1.z.string().optional(); 21 | const optionalNullableStringSchema = index_1.z.string().optional().nullable(); 22 | suite 23 | .add("empty string", () => { 24 | stringSchema.parse(empty); 25 | }) 26 | .add("short string", () => { 27 | stringSchema.parse(short); 28 | }) 29 | .add("long string", () => { 30 | stringSchema.parse(long); 31 | }) 32 | .add("optional string", () => { 33 | optionalStringSchema.parse(long); 34 | }) 35 | .add("nullable string", () => { 36 | optionalNullableStringSchema.parse(long); 37 | }) 38 | .add("nullable (null) string", () => { 39 | optionalNullableStringSchema.parse(null); 40 | }) 41 | .add("invalid: null", () => { 42 | try { 43 | stringSchema.parse(null); 44 | } 45 | catch (err) { } 46 | }) 47 | .add("manual parser: long", () => { 48 | manual(long); 49 | }) 50 | .on("cycle", (e) => { 51 | console.log(`${SUITE_NAME}: ${e.target}`); 52 | }); 53 | exports.default = { 54 | suites: [suite], 55 | }; 56 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/union.d.ts: -------------------------------------------------------------------------------- 1 | import Benchmark from "benchmark"; 2 | declare const _default: { 3 | suites: Benchmark.Suite[]; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/benchmarks/union.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const benchmark_1 = __importDefault(require("benchmark")); 7 | const index_1 = require("../index"); 8 | const doubleSuite = new benchmark_1.default.Suite("z.union: double"); 9 | const manySuite = new benchmark_1.default.Suite("z.union: many"); 10 | const aSchema = index_1.z.object({ 11 | type: index_1.z.literal("a"), 12 | }); 13 | const objA = { 14 | type: "a", 15 | }; 16 | const bSchema = index_1.z.object({ 17 | type: index_1.z.literal("b"), 18 | }); 19 | const objB = { 20 | type: "b", 21 | }; 22 | const cSchema = index_1.z.object({ 23 | type: index_1.z.literal("c"), 24 | }); 25 | const objC = { 26 | type: "c", 27 | }; 28 | const dSchema = index_1.z.object({ 29 | type: index_1.z.literal("d"), 30 | }); 31 | const double = index_1.z.union([aSchema, bSchema]); 32 | const many = index_1.z.union([aSchema, bSchema, cSchema, dSchema]); 33 | doubleSuite 34 | .add("valid: a", () => { 35 | double.parse(objA); 36 | }) 37 | .add("valid: b", () => { 38 | double.parse(objB); 39 | }) 40 | .add("invalid: null", () => { 41 | try { 42 | double.parse(null); 43 | } 44 | catch (err) { } 45 | }) 46 | .add("invalid: wrong shape", () => { 47 | try { 48 | double.parse(objC); 49 | } 50 | catch (err) { } 51 | }) 52 | .on("cycle", (e) => { 53 | console.log(`${doubleSuite.name}: ${e.target}`); 54 | }); 55 | manySuite 56 | .add("valid: a", () => { 57 | many.parse(objA); 58 | }) 59 | .add("valid: c", () => { 60 | many.parse(objC); 61 | }) 62 | .add("invalid: null", () => { 63 | try { 64 | many.parse(null); 65 | } 66 | catch (err) { } 67 | }) 68 | .add("invalid: wrong shape", () => { 69 | try { 70 | many.parse({ type: "unknown" }); 71 | } 72 | catch (err) { } 73 | }) 74 | .on("cycle", (e) => { 75 | console.log(`${manySuite.name}: ${e.target}`); 76 | }); 77 | exports.default = { 78 | suites: [doubleSuite, manySuite], 79 | }; 80 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/errors.d.ts: -------------------------------------------------------------------------------- 1 | import defaultErrorMap from "./locales/en"; 2 | import type { ZodErrorMap } from "./ZodError"; 3 | export { defaultErrorMap }; 4 | export declare function setErrorMap(map: ZodErrorMap): void; 5 | export declare function getErrorMap(): ZodErrorMap; 6 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/errors.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0; 7 | const en_1 = __importDefault(require("./locales/en")); 8 | exports.defaultErrorMap = en_1.default; 9 | let overrideErrorMap = en_1.default; 10 | function setErrorMap(map) { 11 | overrideErrorMap = map; 12 | } 13 | exports.setErrorMap = setErrorMap; 14 | function getErrorMap() { 15 | return overrideErrorMap; 16 | } 17 | exports.getErrorMap = getErrorMap; 18 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/external.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./errors"; 2 | export * from "./helpers/parseUtil"; 3 | export * from "./helpers/typeAliases"; 4 | export * from "./helpers/util"; 5 | export * from "./types"; 6 | export * from "./ZodError"; 7 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/external.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5 | }) : (function(o, m, k, k2) { 6 | if (k2 === undefined) k2 = k; 7 | o[k2] = m[k]; 8 | })); 9 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 10 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 11 | }; 12 | Object.defineProperty(exports, "__esModule", { value: true }); 13 | __exportStar(require("./errors"), exports); 14 | __exportStar(require("./helpers/parseUtil"), exports); 15 | __exportStar(require("./helpers/typeAliases"), exports); 16 | __exportStar(require("./helpers/util"), exports); 17 | __exportStar(require("./types"), exports); 18 | __exportStar(require("./ZodError"), exports); 19 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/enumUtil.d.ts: -------------------------------------------------------------------------------- 1 | export declare namespace enumUtil { 2 | type UnionToIntersectionFn = (T extends unknown ? (k: () => T) => void : never) extends (k: infer Intersection) => void ? Intersection : never; 3 | type GetUnionLast = UnionToIntersectionFn extends () => infer Last ? Last : never; 4 | type UnionToTuple = [T] extends [never] ? Tuple : UnionToTuple>, [GetUnionLast, ...Tuple]>; 5 | type CastToStringTuple = T extends [string, ...string[]] ? T : never; 6 | export type UnionToTupleString = CastToStringTuple>; 7 | export {}; 8 | } 9 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/enumUtil.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/errorUtil.d.ts: -------------------------------------------------------------------------------- 1 | export declare namespace errorUtil { 2 | type ErrMessage = string | { 3 | message?: string; 4 | }; 5 | const errToObj: (message?: ErrMessage | undefined) => { 6 | message?: string | undefined; 7 | }; 8 | const toString: (message?: ErrMessage | undefined) => string | undefined; 9 | } 10 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/errorUtil.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.errorUtil = void 0; 4 | var errorUtil; 5 | (function (errorUtil) { 6 | errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {}; 7 | errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; 8 | })(errorUtil = exports.errorUtil || (exports.errorUtil = {})); 9 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/parseUtil.d.ts: -------------------------------------------------------------------------------- 1 | import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError"; 2 | import type { ZodParsedType } from "./util"; 3 | export declare const makeIssue: (params: { 4 | data: any; 5 | path: (string | number)[]; 6 | errorMaps: ZodErrorMap[]; 7 | issueData: IssueData; 8 | }) => ZodIssue; 9 | export declare type ParseParams = { 10 | path: (string | number)[]; 11 | errorMap: ZodErrorMap; 12 | async: boolean; 13 | }; 14 | export declare type ParsePathComponent = string | number; 15 | export declare type ParsePath = ParsePathComponent[]; 16 | export declare const EMPTY_PATH: ParsePath; 17 | export interface ParseContext { 18 | readonly common: { 19 | readonly issues: ZodIssue[]; 20 | readonly contextualErrorMap?: ZodErrorMap; 21 | readonly async: boolean; 22 | }; 23 | readonly path: ParsePath; 24 | readonly schemaErrorMap?: ZodErrorMap; 25 | readonly parent: ParseContext | null; 26 | readonly data: any; 27 | readonly parsedType: ZodParsedType; 28 | } 29 | export declare type ParseInput = { 30 | data: any; 31 | path: (string | number)[]; 32 | parent: ParseContext; 33 | }; 34 | export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void; 35 | export declare type ObjectPair = { 36 | key: SyncParseReturnType; 37 | value: SyncParseReturnType; 38 | }; 39 | export declare class ParseStatus { 40 | value: "aborted" | "dirty" | "valid"; 41 | dirty(): void; 42 | abort(): void; 43 | static mergeArray(status: ParseStatus, results: SyncParseReturnType[]): SyncParseReturnType; 44 | static mergeObjectAsync(status: ParseStatus, pairs: { 45 | key: ParseReturnType; 46 | value: ParseReturnType; 47 | }[]): Promise>; 48 | static mergeObjectSync(status: ParseStatus, pairs: { 49 | key: SyncParseReturnType; 50 | value: SyncParseReturnType; 51 | alwaysSet?: boolean; 52 | }[]): SyncParseReturnType; 53 | } 54 | export interface ParseResult { 55 | status: "aborted" | "dirty" | "valid"; 56 | data: any; 57 | } 58 | export declare type INVALID = { 59 | status: "aborted"; 60 | }; 61 | export declare const INVALID: INVALID; 62 | export declare type DIRTY = { 63 | status: "dirty"; 64 | value: T; 65 | }; 66 | export declare const DIRTY: (value: T) => DIRTY; 67 | export declare type OK = { 68 | status: "valid"; 69 | value: T; 70 | }; 71 | export declare const OK: (value: T) => OK; 72 | export declare type SyncParseReturnType = OK | DIRTY | INVALID; 73 | export declare type AsyncParseReturnType = Promise>; 74 | export declare type ParseReturnType = SyncParseReturnType | AsyncParseReturnType; 75 | export declare const isAborted: (x: ParseReturnType) => x is INVALID; 76 | export declare const isDirty: (x: ParseReturnType) => x is OK | DIRTY; 77 | export declare const isValid: (x: ParseReturnType) => x is OK; 78 | export declare const isAsync: (x: ParseReturnType) => x is AsyncParseReturnType; 79 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/parseUtil.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0; 7 | const errors_1 = require("../errors"); 8 | const en_1 = __importDefault(require("../locales/en")); 9 | const makeIssue = (params) => { 10 | const { data, path, errorMaps, issueData } = params; 11 | const fullPath = [...path, ...(issueData.path || [])]; 12 | const fullIssue = { 13 | ...issueData, 14 | path: fullPath, 15 | }; 16 | if (issueData.message !== undefined) { 17 | return { 18 | ...issueData, 19 | path: fullPath, 20 | message: issueData.message, 21 | }; 22 | } 23 | let errorMessage = ""; 24 | const maps = errorMaps 25 | .filter((m) => !!m) 26 | .slice() 27 | .reverse(); 28 | for (const map of maps) { 29 | errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; 30 | } 31 | return { 32 | ...issueData, 33 | path: fullPath, 34 | message: errorMessage, 35 | }; 36 | }; 37 | exports.makeIssue = makeIssue; 38 | exports.EMPTY_PATH = []; 39 | function addIssueToContext(ctx, issueData) { 40 | const overrideMap = (0, errors_1.getErrorMap)(); 41 | const issue = (0, exports.makeIssue)({ 42 | issueData: issueData, 43 | data: ctx.data, 44 | path: ctx.path, 45 | errorMaps: [ 46 | ctx.common.contextualErrorMap, 47 | ctx.schemaErrorMap, 48 | overrideMap, 49 | overrideMap === en_1.default ? undefined : en_1.default, // then global default map 50 | ].filter((x) => !!x), 51 | }); 52 | ctx.common.issues.push(issue); 53 | } 54 | exports.addIssueToContext = addIssueToContext; 55 | class ParseStatus { 56 | constructor() { 57 | this.value = "valid"; 58 | } 59 | dirty() { 60 | if (this.value === "valid") 61 | this.value = "dirty"; 62 | } 63 | abort() { 64 | if (this.value !== "aborted") 65 | this.value = "aborted"; 66 | } 67 | static mergeArray(status, results) { 68 | const arrayValue = []; 69 | for (const s of results) { 70 | if (s.status === "aborted") 71 | return exports.INVALID; 72 | if (s.status === "dirty") 73 | status.dirty(); 74 | arrayValue.push(s.value); 75 | } 76 | return { status: status.value, value: arrayValue }; 77 | } 78 | static async mergeObjectAsync(status, pairs) { 79 | const syncPairs = []; 80 | for (const pair of pairs) { 81 | const key = await pair.key; 82 | const value = await pair.value; 83 | syncPairs.push({ 84 | key, 85 | value, 86 | }); 87 | } 88 | return ParseStatus.mergeObjectSync(status, syncPairs); 89 | } 90 | static mergeObjectSync(status, pairs) { 91 | const finalObject = {}; 92 | for (const pair of pairs) { 93 | const { key, value } = pair; 94 | if (key.status === "aborted") 95 | return exports.INVALID; 96 | if (value.status === "aborted") 97 | return exports.INVALID; 98 | if (key.status === "dirty") 99 | status.dirty(); 100 | if (value.status === "dirty") 101 | status.dirty(); 102 | if (key.value !== "__proto__" && 103 | (typeof value.value !== "undefined" || pair.alwaysSet)) { 104 | finalObject[key.value] = value.value; 105 | } 106 | } 107 | return { status: status.value, value: finalObject }; 108 | } 109 | } 110 | exports.ParseStatus = ParseStatus; 111 | exports.INVALID = Object.freeze({ 112 | status: "aborted", 113 | }); 114 | const DIRTY = (value) => ({ status: "dirty", value }); 115 | exports.DIRTY = DIRTY; 116 | const OK = (value) => ({ status: "valid", value }); 117 | exports.OK = OK; 118 | const isAborted = (x) => x.status === "aborted"; 119 | exports.isAborted = isAborted; 120 | const isDirty = (x) => x.status === "dirty"; 121 | exports.isDirty = isDirty; 122 | const isValid = (x) => x.status === "valid"; 123 | exports.isValid = isValid; 124 | const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise; 125 | exports.isAsync = isAsync; 126 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/partialUtil.d.ts: -------------------------------------------------------------------------------- 1 | import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../index"; 2 | export declare namespace partialUtil { 3 | type DeepPartial = T extends ZodObject ? ZodObject<{ 4 | [k in keyof T["shape"]]: ZodOptional>; 5 | }, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray ? ZodArray, Card> : T extends ZodOptional ? ZodOptional> : T extends ZodNullable ? ZodNullable> : T extends ZodTuple ? { 6 | [k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial : never; 7 | } extends infer PI ? PI extends ZodTupleItems ? ZodTuple : never : never : T; 8 | } 9 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/partialUtil.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/typeAliases.d.ts: -------------------------------------------------------------------------------- 1 | export declare type Primitive = string | number | symbol | bigint | boolean | null | undefined; 2 | export declare type Scalars = Primitive | Primitive[]; 3 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/typeAliases.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/util.d.ts: -------------------------------------------------------------------------------- 1 | export declare namespace util { 2 | type AssertEqual = (() => V extends T ? 1 : 2) extends () => V extends U ? 1 : 2 ? true : false; 3 | export type isAny = 0 extends 1 & T ? true : false; 4 | export const assertEqual: (val: AssertEqual) => AssertEqual; 5 | export function assertIs(_arg: T): void; 6 | export function assertNever(_x: never): never; 7 | export type Omit = Pick>; 8 | export type OmitKeys = Pick>; 9 | export type MakePartial = Omit & Partial>; 10 | export type Exactly = T & Record, never>; 11 | export const arrayToEnum: (items: U) => { [k in U[number]]: k; }; 12 | export const getValidEnumValues: (obj: any) => any[]; 13 | export const objectValues: (obj: any) => any[]; 14 | export const objectKeys: ObjectConstructor["keys"]; 15 | export const find: (arr: T[], checker: (arg: T) => any) => T | undefined; 16 | export type identity = objectUtil.identity; 17 | export type flatten = objectUtil.flatten; 18 | export type noUndefined = T extends undefined ? never : T; 19 | export const isInteger: NumberConstructor["isInteger"]; 20 | export function joinValues(array: T, separator?: string): string; 21 | export const jsonStringifyReplacer: (_: string, value: any) => any; 22 | export {}; 23 | } 24 | export declare namespace objectUtil { 25 | export type MergeShapes = { 26 | [k in Exclude]: U[k]; 27 | } & V; 28 | type optionalKeys = { 29 | [k in keyof T]: undefined extends T[k] ? k : never; 30 | }[keyof T]; 31 | type requiredKeys = { 32 | [k in keyof T]: undefined extends T[k] ? never : k; 33 | }[keyof T]; 34 | export type addQuestionMarks = { 35 | [K in requiredKeys]: T[K]; 36 | } & { 37 | [K in optionalKeys]?: T[K]; 38 | } & { 39 | [k in keyof T]?: unknown; 40 | }; 41 | export type identity = T; 42 | export type flatten = identity<{ 43 | [k in keyof T]: T[k]; 44 | }>; 45 | export type noNeverKeys = { 46 | [k in keyof T]: [T[k]] extends [never] ? never : k; 47 | }[keyof T]; 48 | export type noNever = identity<{ 49 | [k in noNeverKeys]: k extends keyof T ? T[k] : never; 50 | }>; 51 | export const mergeShapes: (first: U, second: T) => T & U; 52 | export type extendShape = { 53 | [K in keyof A as K extends keyof B ? never : K]: A[K]; 54 | } & { 55 | [K in keyof B]: B[K]; 56 | }; 57 | export {}; 58 | } 59 | export declare const ZodParsedType: { 60 | function: "function"; 61 | number: "number"; 62 | string: "string"; 63 | nan: "nan"; 64 | integer: "integer"; 65 | float: "float"; 66 | boolean: "boolean"; 67 | date: "date"; 68 | bigint: "bigint"; 69 | symbol: "symbol"; 70 | undefined: "undefined"; 71 | null: "null"; 72 | array: "array"; 73 | object: "object"; 74 | unknown: "unknown"; 75 | promise: "promise"; 76 | void: "void"; 77 | never: "never"; 78 | map: "map"; 79 | set: "set"; 80 | }; 81 | export declare type ZodParsedType = keyof typeof ZodParsedType; 82 | export declare const getParsedType: (data: any) => ZodParsedType; 83 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/helpers/util.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0; 4 | var util; 5 | (function (util) { 6 | util.assertEqual = (val) => val; 7 | function assertIs(_arg) { } 8 | util.assertIs = assertIs; 9 | function assertNever(_x) { 10 | throw new Error(); 11 | } 12 | util.assertNever = assertNever; 13 | util.arrayToEnum = (items) => { 14 | const obj = {}; 15 | for (const item of items) { 16 | obj[item] = item; 17 | } 18 | return obj; 19 | }; 20 | util.getValidEnumValues = (obj) => { 21 | const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number"); 22 | const filtered = {}; 23 | for (const k of validKeys) { 24 | filtered[k] = obj[k]; 25 | } 26 | return util.objectValues(filtered); 27 | }; 28 | util.objectValues = (obj) => { 29 | return util.objectKeys(obj).map(function (e) { 30 | return obj[e]; 31 | }); 32 | }; 33 | util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban 34 | ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban 35 | : (object) => { 36 | const keys = []; 37 | for (const key in object) { 38 | if (Object.prototype.hasOwnProperty.call(object, key)) { 39 | keys.push(key); 40 | } 41 | } 42 | return keys; 43 | }; 44 | util.find = (arr, checker) => { 45 | for (const item of arr) { 46 | if (checker(item)) 47 | return item; 48 | } 49 | return undefined; 50 | }; 51 | util.isInteger = typeof Number.isInteger === "function" 52 | ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban 53 | : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; 54 | function joinValues(array, separator = " | ") { 55 | return array 56 | .map((val) => (typeof val === "string" ? `'${val}'` : val)) 57 | .join(separator); 58 | } 59 | util.joinValues = joinValues; 60 | util.jsonStringifyReplacer = (_, value) => { 61 | if (typeof value === "bigint") { 62 | return value.toString(); 63 | } 64 | return value; 65 | }; 66 | })(util = exports.util || (exports.util = {})); 67 | var objectUtil; 68 | (function (objectUtil) { 69 | objectUtil.mergeShapes = (first, second) => { 70 | return { 71 | ...first, 72 | ...second, // second overwrites first 73 | }; 74 | }; 75 | })(objectUtil = exports.objectUtil || (exports.objectUtil = {})); 76 | exports.ZodParsedType = util.arrayToEnum([ 77 | "string", 78 | "nan", 79 | "number", 80 | "integer", 81 | "float", 82 | "boolean", 83 | "date", 84 | "bigint", 85 | "symbol", 86 | "function", 87 | "undefined", 88 | "null", 89 | "array", 90 | "object", 91 | "unknown", 92 | "promise", 93 | "void", 94 | "never", 95 | "map", 96 | "set", 97 | ]); 98 | const getParsedType = (data) => { 99 | const t = typeof data; 100 | switch (t) { 101 | case "undefined": 102 | return exports.ZodParsedType.undefined; 103 | case "string": 104 | return exports.ZodParsedType.string; 105 | case "number": 106 | return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number; 107 | case "boolean": 108 | return exports.ZodParsedType.boolean; 109 | case "function": 110 | return exports.ZodParsedType.function; 111 | case "bigint": 112 | return exports.ZodParsedType.bigint; 113 | case "symbol": 114 | return exports.ZodParsedType.symbol; 115 | case "object": 116 | if (Array.isArray(data)) { 117 | return exports.ZodParsedType.array; 118 | } 119 | if (data === null) { 120 | return exports.ZodParsedType.null; 121 | } 122 | if (data.then && 123 | typeof data.then === "function" && 124 | data.catch && 125 | typeof data.catch === "function") { 126 | return exports.ZodParsedType.promise; 127 | } 128 | if (typeof Map !== "undefined" && data instanceof Map) { 129 | return exports.ZodParsedType.map; 130 | } 131 | if (typeof Set !== "undefined" && data instanceof Set) { 132 | return exports.ZodParsedType.set; 133 | } 134 | if (typeof Date !== "undefined" && data instanceof Date) { 135 | return exports.ZodParsedType.date; 136 | } 137 | return exports.ZodParsedType.object; 138 | default: 139 | return exports.ZodParsedType.unknown; 140 | } 141 | }; 142 | exports.getParsedType = getParsedType; 143 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as z from "./external"; 2 | export * from "./external"; 3 | export { z }; 4 | export default z; 5 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5 | }) : (function(o, m, k, k2) { 6 | if (k2 === undefined) k2 = k; 7 | o[k2] = m[k]; 8 | })); 9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 10 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 11 | }) : function(o, v) { 12 | o["default"] = v; 13 | }); 14 | var __importStar = (this && this.__importStar) || function (mod) { 15 | if (mod && mod.__esModule) return mod; 16 | var result = {}; 17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 18 | __setModuleDefault(result, mod); 19 | return result; 20 | }; 21 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 22 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 23 | }; 24 | Object.defineProperty(exports, "__esModule", { value: true }); 25 | exports.z = void 0; 26 | const z = __importStar(require("./external")); 27 | exports.z = z; 28 | __exportStar(require("./external"), exports); 29 | exports.default = z; 30 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/locales/en.d.ts: -------------------------------------------------------------------------------- 1 | import { ZodErrorMap } from "../ZodError"; 2 | declare const errorMap: ZodErrorMap; 3 | export default errorMap; 4 | -------------------------------------------------------------------------------- /commons/node_modules/zod/lib/locales/en.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const util_1 = require("../helpers/util"); 4 | const ZodError_1 = require("../ZodError"); 5 | const errorMap = (issue, _ctx) => { 6 | let message; 7 | switch (issue.code) { 8 | case ZodError_1.ZodIssueCode.invalid_type: 9 | if (issue.received === util_1.ZodParsedType.undefined) { 10 | message = "Required"; 11 | } 12 | else { 13 | message = `Expected ${issue.expected}, received ${issue.received}`; 14 | } 15 | break; 16 | case ZodError_1.ZodIssueCode.invalid_literal: 17 | message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`; 18 | break; 19 | case ZodError_1.ZodIssueCode.unrecognized_keys: 20 | message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`; 21 | break; 22 | case ZodError_1.ZodIssueCode.invalid_union: 23 | message = `Invalid input`; 24 | break; 25 | case ZodError_1.ZodIssueCode.invalid_union_discriminator: 26 | message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`; 27 | break; 28 | case ZodError_1.ZodIssueCode.invalid_enum_value: 29 | message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`; 30 | break; 31 | case ZodError_1.ZodIssueCode.invalid_arguments: 32 | message = `Invalid function arguments`; 33 | break; 34 | case ZodError_1.ZodIssueCode.invalid_return_type: 35 | message = `Invalid function return type`; 36 | break; 37 | case ZodError_1.ZodIssueCode.invalid_date: 38 | message = `Invalid date`; 39 | break; 40 | case ZodError_1.ZodIssueCode.invalid_string: 41 | if (typeof issue.validation === "object") { 42 | if ("includes" in issue.validation) { 43 | message = `Invalid input: must include "${issue.validation.includes}"`; 44 | if (typeof issue.validation.position === "number") { 45 | message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; 46 | } 47 | } 48 | else if ("startsWith" in issue.validation) { 49 | message = `Invalid input: must start with "${issue.validation.startsWith}"`; 50 | } 51 | else if ("endsWith" in issue.validation) { 52 | message = `Invalid input: must end with "${issue.validation.endsWith}"`; 53 | } 54 | else { 55 | util_1.util.assertNever(issue.validation); 56 | } 57 | } 58 | else if (issue.validation !== "regex") { 59 | message = `Invalid ${issue.validation}`; 60 | } 61 | else { 62 | message = "Invalid"; 63 | } 64 | break; 65 | case ZodError_1.ZodIssueCode.too_small: 66 | if (issue.type === "array") 67 | message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`; 68 | else if (issue.type === "string") 69 | message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`; 70 | else if (issue.type === "number") 71 | message = `Number must be ${issue.exact 72 | ? `exactly equal to ` 73 | : issue.inclusive 74 | ? `greater than or equal to ` 75 | : `greater than `}${issue.minimum}`; 76 | else if (issue.type === "date") 77 | message = `Date must be ${issue.exact 78 | ? `exactly equal to ` 79 | : issue.inclusive 80 | ? `greater than or equal to ` 81 | : `greater than `}${new Date(Number(issue.minimum))}`; 82 | else 83 | message = "Invalid input"; 84 | break; 85 | case ZodError_1.ZodIssueCode.too_big: 86 | if (issue.type === "array") 87 | message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`; 88 | else if (issue.type === "string") 89 | message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`; 90 | else if (issue.type === "number") 91 | message = `Number must be ${issue.exact 92 | ? `exactly` 93 | : issue.inclusive 94 | ? `less than or equal to` 95 | : `less than`} ${issue.maximum}`; 96 | else if (issue.type === "bigint") 97 | message = `BigInt must be ${issue.exact 98 | ? `exactly` 99 | : issue.inclusive 100 | ? `less than or equal to` 101 | : `less than`} ${issue.maximum}`; 102 | else if (issue.type === "date") 103 | message = `Date must be ${issue.exact 104 | ? `exactly` 105 | : issue.inclusive 106 | ? `smaller than or equal to` 107 | : `smaller than`} ${new Date(Number(issue.maximum))}`; 108 | else 109 | message = "Invalid input"; 110 | break; 111 | case ZodError_1.ZodIssueCode.custom: 112 | message = `Invalid input`; 113 | break; 114 | case ZodError_1.ZodIssueCode.invalid_intersection_types: 115 | message = `Intersection results could not be merged`; 116 | break; 117 | case ZodError_1.ZodIssueCode.not_multiple_of: 118 | message = `Number must be a multiple of ${issue.multipleOf}`; 119 | break; 120 | case ZodError_1.ZodIssueCode.not_finite: 121 | message = "Number must be finite"; 122 | break; 123 | default: 124 | message = _ctx.defaultError; 125 | util_1.util.assertNever(issue); 126 | } 127 | return { message }; 128 | }; 129 | exports.default = errorMap; 130 | -------------------------------------------------------------------------------- /commons/node_modules/zod/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zod", 3 | "version": "3.23.8", 4 | "author": "Colin McDonnell ", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/colinhacks/zod.git" 8 | }, 9 | "main": "./lib/index.js", 10 | "module": "./lib/index.mjs", 11 | "devDependencies": { 12 | "@babel/core": "^7.22.5", 13 | "@babel/preset-env": "^7.22.5", 14 | "@babel/preset-typescript": "^7.22.5", 15 | "@jest/globals": "^29.4.3", 16 | "@rollup/plugin-typescript": "^8.2.0", 17 | "@swc/core": "^1.3.66", 18 | "@swc/jest": "^0.2.26", 19 | "@types/benchmark": "^2.1.0", 20 | "@types/jest": "^29.2.2", 21 | "@types/node": "14", 22 | "@typescript-eslint/eslint-plugin": "^5.15.0", 23 | "@typescript-eslint/parser": "^5.15.0", 24 | "babel-jest": "^29.5.0", 25 | "benchmark": "^2.1.4", 26 | "dependency-cruiser": "^9.19.0", 27 | "eslint": "^8.11.0", 28 | "eslint-config-prettier": "^8.5.0", 29 | "eslint-plugin-ban": "^1.6.0", 30 | "eslint-plugin-import": "^2.25.4", 31 | "eslint-plugin-simple-import-sort": "^7.0.0", 32 | "eslint-plugin-unused-imports": "^2.0.0", 33 | "husky": "^7.0.4", 34 | "jest": "^29.3.1", 35 | "lint-staged": "^12.3.7", 36 | "nodemon": "^2.0.15", 37 | "prettier": "^2.6.0", 38 | "pretty-quick": "^3.1.3", 39 | "rollup": "^2.70.1", 40 | "ts-jest": "^29.1.0", 41 | "ts-morph": "^14.0.0", 42 | "ts-node": "^10.9.1", 43 | "tslib": "^2.3.1", 44 | "tsx": "^3.8.0", 45 | "typescript": "~4.5.5", 46 | "vitest": "^0.32.2" 47 | }, 48 | "exports": { 49 | ".": { 50 | "types": "./index.d.ts", 51 | "require": "./lib/index.js", 52 | "import": "./lib/index.mjs" 53 | }, 54 | "./package.json": "./package.json", 55 | "./locales/*": "./lib/locales/*" 56 | }, 57 | "bugs": { 58 | "url": "https://github.com/colinhacks/zod/issues" 59 | }, 60 | "description": "TypeScript-first schema declaration and validation library with static type inference", 61 | "files": [ 62 | "/lib", 63 | "/index.d.ts" 64 | ], 65 | "funding": "https://github.com/sponsors/colinhacks", 66 | "homepage": "https://zod.dev", 67 | "keywords": [ 68 | "typescript", 69 | "schema", 70 | "validation", 71 | "type", 72 | "inference" 73 | ], 74 | "license": "MIT", 75 | "lint-staged": { 76 | "src/*.ts": [ 77 | "eslint --cache --fix", 78 | "prettier --ignore-unknown --write" 79 | ], 80 | "*.md": [ 81 | "prettier --ignore-unknown --write" 82 | ] 83 | }, 84 | "scripts": { 85 | "prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts *.md --no-error-on-unmatched-pattern", 86 | "prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts *.md --ignore-unknown --no-error-on-unmatched-pattern", 87 | "lint:check": "eslint --cache --ext .ts ./src", 88 | "lint:fix": "eslint --cache --fix --ext .ts ./src", 89 | "check": "yarn lint:check && yarn prettier:check", 90 | "fix": "yarn lint:fix && yarn prettier:fix", 91 | "clean": "rm -rf lib/* deno/lib/*", 92 | "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno", 93 | "build:deno": "node ./deno-build.mjs && cp ./README.md ./deno/lib", 94 | "build:esm": "rollup --config ./configs/rollup.config.js", 95 | "build:cjs": "tsc -p ./configs/tsconfig.cjs.json", 96 | "build:types": "tsc -p ./configs/tsconfig.types.json", 97 | "build:test": "tsc -p ./configs/tsconfig.test.json", 98 | "test:watch": "yarn test:ts-jest --watch", 99 | "test": "yarn test:ts-jest", 100 | "test:babel": "jest --coverage --config ./configs/babel-jest.config.json", 101 | "test:bun": "bun test src/", 102 | "test:vitest": "npx vitest --config ./configs/vitest.config.ts", 103 | "test:ts-jest": "npx jest --config ./configs/ts-jest.config.json", 104 | "test:swc": "npx jest --config ./configs/swc-jest.config.json", 105 | "test:deno": "cd deno && deno test", 106 | "prepublishOnly": "npm run test && npm run build && npm run build:deno", 107 | "play": "nodemon -e ts -w . -x tsx playground.ts", 108 | "depcruise": "depcruise -c .dependency-cruiser.js src", 109 | "benchmark": "tsx src/benchmarks/index.ts", 110 | "prepare": "husky install" 111 | }, 112 | "sideEffects": false, 113 | "support": { 114 | "backing": { 115 | "npm-funding": true 116 | } 117 | }, 118 | "types": "./index.d.ts" 119 | } 120 | -------------------------------------------------------------------------------- /commons/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arinjain111/medium-commons", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@arinjain111/medium-commons", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@arinjain111/medium-commons": "^1.0.0", 13 | "zod": "^3.23.8" 14 | } 15 | }, 16 | "node_modules/@arinjain111/medium-commons": { 17 | "version": "1.0.0", 18 | "resolved": "https://registry.npmjs.org/@arinjain111/medium-commons/-/medium-commons-1.0.0.tgz", 19 | "integrity": "sha512-tPTsR8XtHWmk7opbe1J8wdQs1tjpZShupwvzUsk0tZcJIJOkiNyWZLRYRpgWQni5RwxQFNfpRqWegRelazZ8Uw==", 20 | "dependencies": { 21 | "zod": "^3.23.8" 22 | } 23 | }, 24 | "node_modules/zod": { 25 | "version": "3.23.8", 26 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", 27 | "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", 28 | "funding": { 29 | "url": "https://github.com/sponsors/colinhacks" 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /commons/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arinjain111/medium-commons", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@arinjain111/medium-commons": "^1.0.0", 14 | "zod": "^3.23.8" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /commons/src/index.ts: -------------------------------------------------------------------------------- 1 | import z from 'zod' 2 | 3 | export const signupInput = z.object({ 4 | email: z.string().email().endsWith('@example.com'), 5 | password: z.string().min(8), 6 | name: z.string().optional() 7 | }) 8 | 9 | export const signinInput = z.object({ 10 | email: z.string().email().endsWith('@example.com'), 11 | password: z.string().min(8), 12 | name: z.string().optional() 13 | }) 14 | 15 | const createPostInput = z.object({ 16 | title: z.string(), 17 | content: z.string(), 18 | }) 19 | 20 | const updateblogInput = z.object({ 21 | title: z.string(), 22 | content: z.string(), 23 | id: z.number() 24 | }) 25 | 26 | export type SigninInput = z.infer 27 | export type createPostInput = z.infer 28 | export type SignupInput = z.infer 29 | export type updateblogInput = z.infer 30 | -------------------------------------------------------------------------------- /commons/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | "rootDir": "./src", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /frontend/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | ], 9 | ignorePatterns: ['dist', '.eslintrc.cjs'], 10 | parser: '@typescript-eslint/parser', 11 | plugins: ['react-refresh'], 12 | rules: { 13 | 'react-refresh/only-export-components': [ 14 | 'warn', 15 | { allowConstantExport: true }, 16 | ], 17 | }, 18 | } 19 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | *.local 12 | 13 | # Editor directories and files 14 | .vscode/* 15 | !.vscode/extensions.json 16 | .idea 17 | .DS_Store 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw? 23 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | # React + TypeScript + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: 13 | 14 | - Configure the top-level `parserOptions` property like this: 15 | 16 | ```js 17 | export default { 18 | // other rules... 19 | parserOptions: { 20 | ecmaVersion: 'latest', 21 | sourceType: 'module', 22 | project: ['./tsconfig.json', './tsconfig.node.json'], 23 | tsconfigRootDir: __dirname, 24 | }, 25 | } 26 | ``` 27 | 28 | - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` 29 | - Optionally add `plugin:@typescript-eslint/stylistic-type-checked` 30 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list 31 | -------------------------------------------------------------------------------- /frontend/dist/assets/Write-BiAatf6L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arinjain111/Blogwise/a51aa6fc6db2474201cf5abf338b436f04375aac/frontend/dist/assets/Write-BiAatf6L.png -------------------------------------------------------------------------------- /frontend/dist/assets/index-BbdDSyxM.css: -------------------------------------------------------------------------------- 1 | *,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.relative{position:relative}.col-span-4{grid-column:span 4 / span 4}.col-span-8{grid-column:span 8 / span 8}.m-2{margin:.5rem}.mb-0{margin-bottom:0}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-2\.5{margin-bottom:.625rem}.mb-4{margin-bottom:1rem}.me-2{margin-inline-end:.5rem}.mt-2{margin-top:.5rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.h-10{height:2.5rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-6{height:1.5rem}.h-\[98vh\]{height:98vh}.h-screen{height:100vh}.min-h-12{min-height:3rem}.min-h-20{min-height:5rem}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-32{width:8rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-full{width:100%}.min-w-full{min-width:100%}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-screen-xl{max-width:1280px}.max-w-xl{max-width:36rem}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-pointer{cursor:pointer}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.overflow-hidden{overflow:hidden}.rounded-3xl{border-radius:1.5rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-black{--tw-border-opacity: 1;border-color:rgb(0 0 0 / var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity))}.bg-gray-500{--tw-bg-opacity: 1;background-color:rgb(107 114 128 / var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity))}.bg-green-700{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-amber-100{--tw-gradient-from: #fef3c7 var(--tw-gradient-from-position);--tw-gradient-to: rgb(254 243 199 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-slate-300{--tw-gradient-from: #cbd5e1 var(--tw-gradient-from-position);--tw-gradient-to: rgb(203 213 225 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-amber-400{--tw-gradient-to: #fbbf24 var(--tw-gradient-to-position)}.to-slate-500{--tw-gradient-to: #64748b var(--tw-gradient-to-position)}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-4{padding:1rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-16{padding-left:4rem;padding-right:4rem}.px-20{padding-left:5rem;padding-right:5rem}.px-32{padding-left:8rem;padding-right:8rem}.px-40{padding-left:10rem;padding-right:10rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.pb-1{padding-bottom:.25rem}.pb-10{padding-bottom:2.5rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-48{padding-bottom:12rem}.pb-8{padding-bottom:2rem}.pl-1{padding-left:.25rem}.pl-1\.5{padding-left:.375rem}.pl-2{padding-left:.5rem}.pl-5{padding-left:1.25rem}.pr-2{padding-right:.5rem}.pt-11{padding-top:2.75rem}.pt-2{padding-top:.5rem}.pt-20{padding-top:5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-5{padding-top:1.25rem}.pt-8{padding-top:2rem}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-5xl{font-size:3rem;line-height:1}.text-6xl{font-size:3.75rem;line-height:1}.text-9xl{font-size:8rem;line-height:1}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-extrabold{font-weight:800}.font-light{font-weight:300}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.text-zinc-600{--tw-text-opacity: 1;color:rgb(82 82 91 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.font-arin{font-family:gt-super,Georgia,Cambria,Times New Roman,Times,serif}.font-arin2{font-family:Bodoni Moda,serif;font-optical-sizing:auto;font-weight:weight;font-style:normal}.hover\:bg-gray-400:hover{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity))}.hover\:bg-gray-800:hover{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity))}.hover\:bg-gray-900:hover{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity))}.hover\:bg-green-800:hover{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.focus\:border-blue-500:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-4:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity))}.focus\:ring-gray-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(243 244 246 / var(--tw-ring-opacity))}.focus\:ring-gray-300:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity))}.focus\:ring-gray-800:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(31 41 55 / var(--tw-ring-opacity))}.focus\:ring-green-300:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(134 239 172 / var(--tw-ring-opacity))}@media (min-width: 1024px){.lg\:block{display:block}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width: 1280px){.xl\:px-52{padding-left:13rem;padding-right:13rem}.xl\:px-56{padding-left:14rem;padding-right:14rem}}@media (prefers-color-scheme: dark){.dark\:text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity))}} 2 | -------------------------------------------------------------------------------- /frontend/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Vite + React + TS 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /frontend/dist/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@arinjain111/medium-commons": "^1.0.0", 14 | "axios": "^1.7.2", 15 | "clsx": "^2.1.1", 16 | "react": "^18.3.1", 17 | "react-dom": "^18.3.1", 18 | "react-router-dom": "^6.24.1" 19 | }, 20 | "devDependencies": { 21 | "@types/react": "^18.3.3", 22 | "@types/react-dom": "^18.3.0", 23 | "@typescript-eslint/eslint-plugin": "^7.13.1", 24 | "@typescript-eslint/parser": "^7.13.1", 25 | "@vitejs/plugin-react": "^4.3.1", 26 | "autoprefixer": "^10.4.19", 27 | "eslint": "^8.57.0", 28 | "eslint-plugin-react-hooks": "^4.6.2", 29 | "eslint-plugin-react-refresh": "^0.4.7", 30 | "postcss": "^8.4.39", 31 | "tailwindcss": "^3.4.4", 32 | "typescript": "^5.2.2", 33 | "vite": "^5.3.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /frontend/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /frontend/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/src/App.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arinjain111/Blogwise/a51aa6fc6db2474201cf5abf338b436f04375aac/frontend/src/App.css -------------------------------------------------------------------------------- /frontend/src/App.tsx: -------------------------------------------------------------------------------- 1 | import './App.css' 2 | import { BrowserRouter, Route, Routes } from 'react-router-dom' 3 | import { Signup } from './pages/Signup' 4 | import { Signin} from './pages/Signin' 5 | import { Post } from './pages/Post' 6 | import { Posts } from './pages/Posts' 7 | import { Home } from './pages/Home' 8 | import { Write } from './HomepageComponent/Write' 9 | import { OurStory } from './HomepageComponent/OurStory' 10 | 11 | function App() { 12 | 13 | return ( 14 | <> 15 | 16 | 17 | } > 18 | }> 19 | }> 20 | }> 21 | }> 22 | }> 23 | }> 24 | 25 | 26 | 27 | ) 28 | } 29 | 30 | export default App 31 | -------------------------------------------------------------------------------- /frontend/src/HomepageComponent/Navbar.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "react-router-dom" 2 | 3 | export const Navbar = () => { 4 | return
5 |
6 |
7 |
8 | Blogwise 9 |
10 |
11 |
Our story
12 |
Write
13 |
14 | 15 | 16 | 17 |
18 |
19 |
20 |
21 | 22 |
23 |
24 |
25 | } -------------------------------------------------------------------------------- /frontend/src/HomepageComponent/OurStory.tsx: -------------------------------------------------------------------------------- 1 | import { DevelopmentPage } from "../components/DevelopmentPage" 2 | 3 | export const OurStory = () => { 4 | return
5 | 6 |
7 | } -------------------------------------------------------------------------------- /frontend/src/HomepageComponent/Write.tsx: -------------------------------------------------------------------------------- 1 | import axios from "axios" 2 | import { Avatar } from "../components/PostCard" 3 | import { BACKEND_URL } from "../config" 4 | import { useState } from "react" 5 | import { Link, useNavigate } from "react-router-dom" 6 | 7 | export const Write = () => { 8 | const [title,setTitle] = useState(""); 9 | const [description, setDescription] = useState(""); 10 | const navigate = useNavigate(); 11 | 12 | return
13 |
14 | 15 |
Blogwise
16 | 17 |
18 | 29 |
30 |
31 |
32 |
33 |
34 | { 35 | setTitle(e.target.value) 36 | }} type="text" placeholder="Title" className="text-6xl outline-none font-arin2 w-full"/> 37 | { 38 | setDescription(e.target.value); 39 | }} type="text" placeholder="A new story awaits . . ." className="text-lg w-full outline-none "> 40 |
41 |
42 |
43 | } -------------------------------------------------------------------------------- /frontend/src/Hooks/Index.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react" 2 | import { BACKEND_URL } from "../config"; 3 | import axios from "axios"; 4 | 5 | export interface Post { 6 | "content": string; 7 | "title": string; 8 | "id": number; 9 | "author": { 10 | "name": null 11 | } 12 | } 13 | 14 | export const usePost = ({ id }: {id: string}) => { 15 | const [loading, setloading] = useState(true); 16 | const [post, setpost] = useState(); 17 | 18 | useEffect(() => { 19 | axios.get(`${BACKEND_URL}/api/v1/post/${id}`,{ 20 | headers: { 21 | Authorization: localStorage.getItem("token") 22 | } 23 | }) 24 | .then(response => { 25 | setpost(response.data.post); 26 | setloading(false) 27 | }) 28 | }, []) 29 | 30 | return { 31 | loading, 32 | post 33 | } 34 | } 35 | 36 | export const usePosts = () => { 37 | const [loading, setloading] = useState(true); 38 | const [posts, setposts] = useState([]); 39 | 40 | useEffect(() => { 41 | axios.get(`${BACKEND_URL}/api/v1/post/bulk`,{ 42 | headers: { 43 | Authorization: localStorage.getItem("token") 44 | } 45 | }) 46 | .then(response => { 47 | setposts(response.data.posts); 48 | setloading(false) 49 | }) 50 | }, []) 51 | 52 | return { 53 | loading, 54 | posts 55 | } 56 | } -------------------------------------------------------------------------------- /frontend/src/assets/Write.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arinjain111/Blogwise/a51aa6fc6db2474201cf5abf338b436f04375aac/frontend/src/assets/Write.png -------------------------------------------------------------------------------- /frontend/src/assets/react.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/src/components/AppBar.tsx: -------------------------------------------------------------------------------- 1 | import { Avatar } from "./PostCard" 2 | import { Link } from "react-router-dom" 3 | import Write from "../assets/Write.png" 4 | 5 | 6 | export const Appbar = () =>{ 7 | return
8 |
9 | 10 | Blogwise 11 | 12 |
13 |
14 | 15 |
16 | Write 17 |
Write
18 |
19 | 20 |
21 | 22 |
23 |
24 |
25 | } -------------------------------------------------------------------------------- /frontend/src/components/Auth.tsx: -------------------------------------------------------------------------------- 1 | import { SigninInput } from "@arinjain111/medium-commons"; 2 | import axios from "axios"; 3 | import { ChangeEvent, useState } from "react"; 4 | import { Link, useNavigate } from "react-router-dom" 5 | import { BACKEND_URL } from "../config"; 6 | 7 | export const Auth = ({ type }: { type: "signin" | "signup" }) => { 8 | const navigate = useNavigate(); 9 | const [ postInputs, setPostInputs ] = useState({ 10 | name: "", 11 | email: "", 12 | password: "" 13 | 14 | }); 15 | 16 | async function sendRequest() { 17 | try{ 18 | const response = await axios.post(`${BACKEND_URL}/api/v1/user/${type === "signup" ? "signup" : "signin"}`, postInputs); 19 | const jwt = response.data; 20 | localStorage.setItem("token", jwt); 21 | navigate("/posts"); 22 | } catch(e) { 23 | alert("Error while signing up") 24 | } 25 | } 26 | 27 | return
28 |
29 |
30 |
31 |
32 | {type === "signin" ? "Welcome Back": "Create an account"} 33 |
34 |
35 | { type === "signin" ? "Dont have an account ?": "Already have an account ?" } 36 | 37 | { type === "signin" ? "Sign up": "Sign in" } 38 | 39 |
40 |
41 |
42 | {type === "signup" ? { 43 | setPostInputs({ 44 | ...postInputs, 45 | name: e.target.value, 46 | }) 47 | }} /> : null} 48 | 49 | { 50 | setPostInputs({ 51 | ...postInputs, 52 | email: e.target.value, 53 | }) 54 | }} /> 55 | 56 | { 57 | setPostInputs({ 58 | ...postInputs, 59 | password: e.target.value, 60 | }) 61 | }} /> 62 |
63 |
64 | 65 |
66 |
67 |
68 |
69 | } 70 | 71 | interface LabelledInputType { 72 | label: string; 73 | placeholer: string; 74 | onchange: (e: ChangeEvent) => void; 75 | type?: string; 76 | } 77 | 78 | function LabelledInput({ label, placeholer, onchange, type }: LabelledInputType) { 79 | return
80 | 81 | 82 |
83 | } -------------------------------------------------------------------------------- /frontend/src/components/DevelopmentPage.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "react-router-dom" 2 | 3 | export const DevelopmentPage = () => { 4 | return
5 |
6 |
7 | 404 8 |
9 |
10 | Currently in development... 11 |
12 |
13 | 14 | 15 | 16 |
17 |
18 |
19 | } -------------------------------------------------------------------------------- /frontend/src/components/PostCard.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "react-router-dom" 2 | 3 | interface PostCardProps { 4 | authorName : string, 5 | title: string, 6 | content: string, 7 | publishedDate: string 8 | id: number 9 | } 10 | 11 | export const PostCard = ({ 12 | id, 13 | authorName, 14 | title, 15 | content, 16 | publishedDate, 17 | 18 | }: PostCardProps) => { 19 | return 20 |
21 |
22 |
23 | 24 |
25 |
26 | { authorName } 27 |
28 |
29 |
30 | { title } 31 |
32 |
33 | { content.slice(0, 100) + "..." } 34 |
35 |
36 |
37 | { publishedDate } 38 |
39 |
40 | {`${Math.ceil(content.length / 100)}minute(s) read`} 41 |
42 |
43 |
44 | 45 | } 46 | 47 | interface Avatartype{ 48 | name: string, 49 | size?: "small" | "big" 50 | } 51 | 52 | export const Avatar:React.FC = ({name, size = "small"}) => { 53 | return
54 | {name[0]} 55 |
56 | } -------------------------------------------------------------------------------- /frontend/src/components/PostPage.tsx: -------------------------------------------------------------------------------- 1 | import { Appbar } from "./AppBar" 2 | import { Post } from "../Hooks/Index" 3 | import { Avatar } from "./PostCard" 4 | 5 | export const PostPage = ({ post }: {post: Post}) => { 6 | return
7 | 8 |
9 |
10 |
11 |
12 | {post.title} 13 |
14 |
15 | posted on 2nd December 2023 16 |
17 |
18 | {post.content} 19 |
20 |
21 |
22 |
23 |
Author
24 |
25 |
26 | 27 |
28 |
29 |
30 | {post.author.name} 31 |
32 |
33 | "Random catch phrase about the Authors ability to grab user's attention" 34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 43 | } -------------------------------------------------------------------------------- /frontend/src/components/PostPageSkeleton.tsx: -------------------------------------------------------------------------------- 1 | export const PostPageSkeleton = () => { 2 | return
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | } -------------------------------------------------------------------------------- /frontend/src/components/PostSkeleton.tsx: -------------------------------------------------------------------------------- 1 | export const PostSkeleton = () => { 2 | return
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | } -------------------------------------------------------------------------------- /frontend/src/components/Quote.tsx: -------------------------------------------------------------------------------- 1 | export const Quote = () => { 2 | return
3 |
4 |
5 |
6 | "The Customer Service I Recieved was Exceptional. The Support team went above and beyond to address my Concerns" 7 |
8 |
9 | Julies Winfiled 10 |
11 |
12 | CEO | Acne Corp 13 |
14 |
15 |
16 |
17 | } 18 | -------------------------------------------------------------------------------- /frontend/src/config.ts: -------------------------------------------------------------------------------- 1 | export const BACKEND_URL = "https://backend.arinjain.workers.dev" -------------------------------------------------------------------------------- /frontend/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | .font-arin { 6 | font-family: gt-super, Georgia, Cambria, "Times New Roman", Times, serif; 7 | } 8 | 9 | .font-arin2 { 10 | font-family: "Bodoni Moda", serif; 11 | font-optical-sizing: auto; 12 | font-weight: weight; 13 | font-style: normal; 14 | } 15 | -------------------------------------------------------------------------------- /frontend/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App.tsx' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /frontend/src/pages/Home.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "react-router-dom" 2 | export const Home = () => { 3 | return
4 |
5 |
6 |
Blogwise
7 |
8 |
9 | Our story 10 |
11 |
12 | Write 13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 |
21 |
22 | Welcome to Blogwise 23 |
24 |
25 |
26 | human stories & ideas 27 |
28 |
29 |
30 |
31 | } -------------------------------------------------------------------------------- /frontend/src/pages/Post.tsx: -------------------------------------------------------------------------------- 1 | import { useParams } from "react-router-dom"; 2 | import { usePost } from "../Hooks/Index" 3 | import { PostPage } from "../components/PostPage"; 4 | import { Appbar } from "../components/AppBar"; 5 | import { PostPageSkeleton } from "../components/PostPageSkeleton"; 6 | 7 | export const Post = () => { 8 | const {id} = useParams(); 9 | const {loading, post} = usePost({ 10 | id: id || "" 11 | }); 12 | if (loading) { 13 | return
14 | 15 | 16 |
17 | } 18 | // will check if the post Type check will reload or not. 19 | // if not loaded will not render the post 20 | return
21 | {post ? :null} 22 |
23 | } -------------------------------------------------------------------------------- /frontend/src/pages/Posts.tsx: -------------------------------------------------------------------------------- 1 | import { Appbar } from "../components/AppBar" 2 | import { PostCard } from "../components/PostCard" 3 | import { PostSkeleton } from "../components/PostSkeleton" 4 | import { usePosts } from "../Hooks/Index" 5 | 6 | export const Posts = () => { 7 | const {loading, posts} = usePosts() 8 | 9 | if (loading) { 10 | return
11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 |
23 | } 24 | return
25 | 26 |
27 |
28 | {posts.map( post => )} 35 |
36 |
37 |
38 | 39 | } -------------------------------------------------------------------------------- /frontend/src/pages/Signin.tsx: -------------------------------------------------------------------------------- 1 | import {Quote} from '../components/Quote' 2 | import {Auth} from '../components/Auth' 3 | 4 | export const Signin = () => { 5 | return
6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 |
15 | } -------------------------------------------------------------------------------- /frontend/src/pages/Signup.tsx: -------------------------------------------------------------------------------- 1 | import {Quote} from '../components/Quote' 2 | import {Auth} from '../components/Auth' 3 | 4 | export const Signup = () => { 5 | return
6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 |
15 | } -------------------------------------------------------------------------------- /frontend/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | export default { 3 | content: [ 4 | "./index.html", 5 | "./src/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | fontFamily: { 9 | 10 | }, 11 | extend: { 12 | height: { 13 | 'screen/98': '98vh', 14 | } 15 | }, 16 | }, 17 | plugins: [], 18 | } -------------------------------------------------------------------------------- /frontend/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 5 | "target": "ES2020", 6 | "useDefineForClassFields": true, 7 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 8 | "module": "ESNext", 9 | "skipLibCheck": true, 10 | 11 | /* Bundler mode */ 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "moduleDetection": "force", 17 | "noEmit": true, 18 | "jsx": "react-jsx", 19 | 20 | /* Linting */ 21 | "strict": true, 22 | "noUnusedLocals": true, 23 | "noUnusedParameters": true, 24 | "noFallthroughCasesInSwitch": true 25 | }, 26 | "include": ["src"] 27 | } 28 | -------------------------------------------------------------------------------- /frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { 5 | "path": "./tsconfig.app.json" 6 | }, 7 | { 8 | "path": "./tsconfig.node.json" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /frontend/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 5 | "skipLibCheck": true, 6 | "module": "ESNext", 7 | "moduleResolution": "bundler", 8 | "allowSyntheticDefaultImports": true, 9 | "strict": true, 10 | "noEmit": true 11 | }, 12 | "include": ["vite.config.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /frontend/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | --------------------------------------------------------------------------------