remove existing
This commit is contained in:
parent
3182233bb2
commit
85ac3b6ffa
22 changed files with 0 additions and 346 deletions
2
.env
2
.env
|
|
@ -1,2 +0,0 @@
|
|||
APP_VERSION=1.0.0-alpha
|
||||
DATABASE_URL="file:./dev.db"
|
||||
14
.github/workflows/pr.yml
vendored
14
.github/workflows/pr.yml
vendored
|
|
@ -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
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
|||
node_modules
|
||||
build
|
||||
22
README.md
22
README.md
|
|
@ -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
|
||||
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -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
|
||||
);
|
||||
|
|
@ -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);
|
||||
},
|
||||
};
|
||||
35
package.json
35
package.json
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
BIN
prisma/dev.db
BIN
prisma/dev.db
Binary file not shown.
Binary file not shown.
|
|
@ -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");
|
||||
|
|
@ -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"
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
15
src/index.ts
15
src/index.ts
|
|
@ -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}`);
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const prisma = new PrismaClient();
|
||||
|
|
@ -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<typeof prisma>;
|
||||
}>({
|
||||
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',
|
||||
},
|
||||
});
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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,
|
||||
});
|
||||
|
|
@ -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();
|
||||
|
|
@ -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/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue