diff --git a/.env b/.env deleted file mode 100644 index c98868d..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -APP_VERSION=1.0.0-alpha -DATABASE_URL="file:./dev.db" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index f782dbb..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: PR Checks -on: [pull_request] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest - - name: install - run: bun install - - name: build - run: bun run clean && bun run build diff --git a/.gitignore b/.gitignore deleted file mode 100644 index dd87e2d..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -build diff --git a/README.md b/README.md deleted file mode 100644 index 9bfae56..0000000 --- a/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Hestia - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run src/index.ts -``` - -## Stack - -- **Bun** Package manager -- **Yoga** GraphQL Server -- **Pothos** GraphQL Schema Builder -- **Prisma** Database ORM -- **Pino** Logger -- **Zod** Schema validation diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index e9ebac8..0000000 Binary files a/bun.lockb and /dev/null differ diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 9add6b6..0000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,14 +0,0 @@ -// @ts-check - -import eslint from '@eslint/js'; -import tseslint from 'typescript-eslint'; -// @ts-expect-error No type-def -import eslintConfigPrettier from 'eslint-config-prettier'; - -export default tseslint.config( - { files: ['{app,src}/**/*.{js,mjs,ts}'] }, - { ignores: ['build/*'] }, - eslint.configs.recommended, - tseslint.configs.recommended, - eslintConfigPrettier -); \ No newline at end of file diff --git a/lib/logger/index.ts b/lib/logger/index.ts deleted file mode 100644 index 7dea51d..0000000 --- a/lib/logger/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { type YogaLogger } from 'graphql-yoga'; -import pino from 'pino'; - -export const logger = pino(); - -export const yogaLogger: YogaLogger = { - debug(...args) { - // @ts-expect-error types dont match - logger.debug(...args); - }, - info(...args) { - // @ts-expect-error types dont match - logger.info(...args); - }, - warn(...args) { - // @ts-expect-error types dont match - logger.warn(...args); - }, - error(...args) { - // @ts-expect-error types dont match - logger.error(...args); - }, -}; diff --git a/package.json b/package.json deleted file mode 100644 index 5e233b8..0000000 --- a/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "hestia", - "module": "src/index.ts", - "type": "module", - "scripts": { - "build": "bun build ./src/index.ts --outdir ./build", - "clean": "rm -rf ./build", - "dev": "bun --watch src/index.ts | pino-pretty", - "format": "prettier . --write", - "lint": "", - "prisma:generate": "prisma generate" - }, - "devDependencies": { - "@eslint/js": "^9.16.0", - "@types/bun": "latest", - "eslint": "^9.16.0", - "eslint-config-prettier": "^9.1.0", - "prettier": "3.4.1", - "prisma": "^6.0.1", - "typescript-eslint": "^8.17.0" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "@pothos/core": "^4.3.0", - "@pothos/plugin-prisma": "^4.4.0", - "@prisma/client": "6.0.1", - "graphql": "^16.9.0", - "graphql-yoga": "^5.10.4", - "pino": "^9.5.0", - "pino-pretty": "^13.0.0", - "zod": "^3.23.8" - } -} diff --git a/prettier.config.mjs b/prettier.config.mjs deleted file mode 100644 index 674afc2..0000000 --- a/prettier.config.mjs +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @see https://prettier.io/docs/en/configuration.html - * @type {import("prettier").Config} - */ -const config = { - trailingComma: 'es5', - tabWidth: 4, - useTabs: true, - semi: true, - singleQuote: true, -}; - -export default config; diff --git a/prisma/dev.db b/prisma/dev.db deleted file mode 100644 index 33bbdb7..0000000 Binary files a/prisma/dev.db and /dev/null differ diff --git a/prisma/dev.db-journal b/prisma/dev.db-journal deleted file mode 100644 index 8c85613..0000000 Binary files a/prisma/dev.db-journal and /dev/null differ diff --git a/prisma/migrations/20241202163245_init/migration.sql b/prisma/migrations/20241202163245_init/migration.sql deleted file mode 100644 index 16407fb..0000000 --- a/prisma/migrations/20241202163245_init/migration.sql +++ /dev/null @@ -1,19 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "email" TEXT NOT NULL, - "name" TEXT -); - --- CreateTable -CREATE TABLE "Post" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "title" TEXT NOT NULL, - "content" TEXT, - "published" BOOLEAN NOT NULL DEFAULT false, - "authorId" INTEGER NOT NULL, - CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml deleted file mode 100644 index e5e5c47..0000000 --- a/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma deleted file mode 100644 index 0f11436..0000000 --- a/prisma/schema.prisma +++ /dev/null @@ -1,31 +0,0 @@ -// 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" -} - -generator pothos { - provider = "prisma-pothos-types" -} - -datasource db { - provider = "sqlite" - url = env("DATABASE_URL") -} - -model User { - id Int @id @default(autoincrement()) - email String @unique - name String? - posts Post[] -} - -model Post { - id Int @id @default(autoincrement()) - title String - content String? - published Boolean @default(false) - author User @relation(fields: [authorId], references: [id]) - authorId Int -} diff --git a/src/config/index.ts b/src/config/index.ts deleted file mode 100644 index ad70abe..0000000 --- a/src/config/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { logger } from '@lib/logger'; -import { z } from 'zod'; - -export interface Configuration { - app_version: string; -} - -export const LoadConfig = (): Configuration => { - const { success, data, error } = z - .object({ - APP_VERSION: z.string().default('development'), - }) - .safeParse(process.env); - - if (!success) { - logger.error(error.message); - } - - return { - app_version: data!.APP_VERSION, - }; -}; diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 8d71ef1..0000000 --- a/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { logger } from '@lib/logger'; -import { yoga } from './yoga'; - -const server = Bun.serve({ - fetch: yoga.fetch, - error: (error) => { - logger.error(error.message); - return new Response('', { - status: 500, - statusText: 'You fucked the goose', - }); - }, -}); - -logger.info(`Server is running on: ${server.url}${yoga.graphqlEndpoint}`); diff --git a/src/prisma/index.ts b/src/prisma/index.ts deleted file mode 100644 index 9b6c4ce..0000000 --- a/src/prisma/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { PrismaClient } from '@prisma/client'; - -export const prisma = new PrismaClient(); diff --git a/src/yoga/builder.ts b/src/yoga/builder.ts deleted file mode 100644 index 750955c..0000000 --- a/src/yoga/builder.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Configuration } from '@app/config'; -import { prisma } from '@app/prisma'; -import SchemaBuilder from '@pothos/core'; -import PrismaPlugin, { - type PrismaTypesFromClient, -} from '@pothos/plugin-prisma'; -import type { YogaInitialContext } from 'graphql-yoga'; - -type Context = YogaInitialContext & { - config: Configuration; -}; - -export const builder = new SchemaBuilder<{ - Context: Context; - PrismaTypes: PrismaTypesFromClient; -}>({ - plugins: [PrismaPlugin], - prisma: { - client: prisma, - // defaults to false, uses /// comments from prisma schema as descriptions - // for object types, relations and exposed fields. - // descriptions can be omitted by setting description to false - exposeDescriptions: false, - // use where clause from prismaRelatedConnection for totalCount (defaults to true) - filterConnectionTotalCount: true, - // warn when not using a query parameter correctly - onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn', - }, -}); diff --git a/src/yoga/context.ts b/src/yoga/context.ts deleted file mode 100644 index fac5b95..0000000 --- a/src/yoga/context.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { LoadConfig } from '@app/config'; -import type { YogaInitialContext } from 'graphql-yoga'; - -export const context = (initialContext: YogaInitialContext) => { - const config = LoadConfig(); - return { - ...initialContext, - config, - }; -}; diff --git a/src/yoga/index.ts b/src/yoga/index.ts deleted file mode 100644 index 35233ab..0000000 --- a/src/yoga/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { yogaLogger } from '@lib/logger'; -import { createYoga } from 'graphql-yoga'; -import { context } from './context'; -import { schema } from './schema'; - -export const yoga = createYoga({ - schema, - context: context, - logging: yogaLogger, -}); diff --git a/src/yoga/schema.ts b/src/yoga/schema.ts deleted file mode 100644 index bb3006e..0000000 --- a/src/yoga/schema.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { prisma } from '@app/prisma'; -import { builder } from './builder'; - -const User = builder.prismaObject('User', { - fields: (t) => ({ - id: t.exposeID('id'), - email: t.exposeString('email'), - name: t.exposeString('name'), - posts: t.relation('posts'), - }), -}); - -const Post = builder.prismaObject('Post', { - fields: (t) => ({ - id: t.exposeID('id'), - title: t.exposeString('title'), - content: t.exposeString('content'), - published: t.exposeBoolean('published'), - author: t.relation('author'), - }), -}); - -builder.queryType({ - fields: (t) => ({ - version: t.string({ - resolve: (parent, args, context) => context.config.app_version, - }), - users: t.prismaField({ - type: [User], - resolve: async () => { - return await prisma.user.findMany(); - }, - }), - posts: t.prismaField({ - type: [Post], - resolve: async () => { - return await prisma.post.findMany(); - }, - }), - }), -}); - -export const schema = builder.toSchema(); diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 75671cb..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false, - - // Path mapping - "baseUrl": ".", - "paths": { - "@app": ["./src"], - "@app/*": ["./src/*"], - "@lib": ["./lib"], - "@lib/*": ["./lib/*"] - } - } -}