From 5112aa1d018ea56532be8ce6e3c5b4936c56567f Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Wed, 14 Feb 2024 20:01:36 -0500 Subject: [PATCH] init --- .gitignore | 175 +++++++++++++++++++++++++++++++++++++++++ .prettierrc | 5 ++ README.md | 15 ++++ bun.lockb | Bin 0 -> 7581 bytes package.json | 19 +++++ prisma/schema.prisma | 17 ++++ src/api/api/server.ts | 10 +++ src/api/api/trpc.ts | 17 ++++ src/api/data/prisma.ts | 4 + src/api/index.ts | 2 + src/api/util/config.ts | 0 tsconfig.json | 27 +++++++ 12 files changed, 291 insertions(+) create mode 100644 .gitignore create mode 100644 .prettierrc create mode 100644 README.md create mode 100755 bun.lockb create mode 100644 package.json create mode 100644 prisma/schema.prisma create mode 100644 src/api/api/server.ts create mode 100644 src/api/api/trpc.ts create mode 100644 src/api/data/prisma.ts create mode 100644 src/api/index.ts create mode 100644 src/api/util/config.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..468f82a --- /dev/null +++ b/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..5275bb7 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "trailingComma": "none", + "arrowParens": "avoid", + "tabWidth": 4 +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca33843 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# fishing-api + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run src/index.ts +``` + +This project was created using `bun init` in bun v1.0.25. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..b79560f6c52714138d66e9ab2f009c74a2a84ffe GIT binary patch literal 7581 zcmeHMdt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EWf~6Q$zCDrJ1w z0emigbM*_Krh>1$%!A2=6u`y3%MGK|p|G`F84XvbUM%UyrXLSj z(O+o2&vy^9Pava~`bSJ1st^ymrB88F>s z$SUAEiFhI>X+*f#O(G5x(gLwGTx zj}gE=I7?>95L?E)8Sdx|Ki0JU!ERyhPcWz7w2xfFzqhs>oSj33VPe;;VgJ%JvqyVg-aD#lHvf2fF!pbeLaz3wc1_e2%= zlBnY94}m|7F{VjAngA3kuKrjNx*$@ch>(ZN|8OA8Za~9q!m5D5=tH7Q{`yqZOH_2D W&?Ro5>TUp$6a0Zw`Xk}5_x)eW1^9vh literal 0 HcmV?d00001 diff --git a/package.json b/package.json new file mode 100644 index 0000000..c005eeb --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "fishing-api", + "module": "src/api/index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "@prisma/client": "^5.9.1", + "@trpc/client": "next", + "@trpc/server": "next", + "prisma": "^5.9.1", + "trpc-bun-adapter": "^1.1.0", + "zod": "^3.22.4" + } +} diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..db3cb68 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,17 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id String @id + name String + color String +} diff --git a/src/api/api/server.ts b/src/api/api/server.ts new file mode 100644 index 0000000..eca625a --- /dev/null +++ b/src/api/api/server.ts @@ -0,0 +1,10 @@ +import { createBunServeHandler } from "trpc-bun-adapter"; +import { appRouter } from "./trpc"; + +export const server = Bun.serve( + createBunServeHandler({ + router: appRouter + }) +); + +export default server; diff --git a/src/api/api/trpc.ts b/src/api/api/trpc.ts new file mode 100644 index 0000000..9e95876 --- /dev/null +++ b/src/api/api/trpc.ts @@ -0,0 +1,17 @@ +import { initTRPC } from "@trpc/server"; +import { z } from "zod"; + +const t = initTRPC.create(); + +export const router = t.router; +export const publicProcedure = t.procedure; + +export const appRouter = router({ + cast: publicProcedure.input(z.string()).query(async opts => { + const { input } = opts; + const response = `${input} cast their rod`; + return { response }; + }) +}); + +export type AppRouter = typeof appRouter; diff --git a/src/api/data/prisma.ts b/src/api/data/prisma.ts new file mode 100644 index 0000000..22d835f --- /dev/null +++ b/src/api/data/prisma.ts @@ -0,0 +1,4 @@ +import { PrismaClient } from "@prisma/client"; + +export const prisma = new PrismaClient(); +export default prisma; diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..75462ab --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,2 @@ +import "./api/server"; +import prisma from "S:/data/prisma"; diff --git a/src/api/util/config.ts b/src/api/util/config.ts new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8243fb1 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + /* Linting */ + "skipLibCheck": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true, + + "paths": { + "S:/*": ["./src/api/*"], + "C:/*": ["./src/bot/*"], + } + } +}