done #3
15 changed files with 226 additions and 177 deletions
13
.editorconfig
Normal file
13
.editorconfig
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = false
|
||||
|
||||
[*.{js,ts}]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[{*.{yml,mjs,json}}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
2
.github/workflows/pr.yml
vendored
2
.github/workflows/pr.yml
vendored
|
|
@ -8,5 +8,7 @@ jobs:
|
|||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
- name: install
|
||||
run: bun install
|
||||
- name: build
|
||||
run: bun run clean && bun run build
|
||||
|
|
|
|||
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
13
eslint.config.mjs
Normal file
13
eslint.config.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import pluginJs from '@eslint/js';
|
||||
import eslintConfigPrettier from 'eslint-config-prettier';
|
||||
import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
{ files: ['**/*.{js,mjs,cjs,ts}'] },
|
||||
{ languageOptions: { globals: globals.browser } },
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
eslintConfigPrettier,
|
||||
];
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
import { type YogaLogger } from "graphql-yoga";
|
||||
import pino from "pino";
|
||||
import { type YogaLogger } from 'graphql-yoga';
|
||||
import pino from 'pino';
|
||||
|
||||
export const logger = pino();
|
||||
|
||||
export const yogaLogger: YogaLogger = {
|
||||
debug(...args) {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error types dont match
|
||||
logger.debug(...args);
|
||||
},
|
||||
info(...args) {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error types dont match
|
||||
logger.info(...args);
|
||||
},
|
||||
warn(...args) {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error types dont match
|
||||
logger.warn(...args);
|
||||
},
|
||||
error(...args) {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error types dont match
|
||||
logger.error(...args);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
10
package.json
10
package.json
|
|
@ -6,11 +6,19 @@
|
|||
"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",
|
||||
"prisma": "^6.0.1"
|
||||
"eslint": "^9.16.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"globals": "^15.13.0",
|
||||
"prettier": "3.4.1",
|
||||
"prisma": "^6.0.1",
|
||||
"typescript-eslint": "^8.17.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
|
|
|
|||
13
prettier.config.mjs
Normal file
13
prettier.config.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* @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;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { logger } from "@lib/logger";
|
||||
import { z } from "zod";
|
||||
import { logger } from '@lib/logger';
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface Configuration {
|
||||
app_version: string;
|
||||
|
|
@ -8,7 +8,7 @@ export interface Configuration {
|
|||
export const LoadConfig = (): Configuration => {
|
||||
const { success, data, error } = z
|
||||
.object({
|
||||
APP_VERSION: z.string().default("development"),
|
||||
APP_VERSION: z.string().default('development'),
|
||||
})
|
||||
.safeParse(process.env);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { logger } from "@lib/logger";
|
||||
import { yoga } from "./yoga";
|
||||
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("", {
|
||||
return new Response('', {
|
||||
status: 500,
|
||||
statusText: "You fucked the goose",
|
||||
statusText: 'You fucked the goose',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const prisma = new PrismaClient();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { Configuration } from "@app/config";
|
||||
import { prisma } from "@app/prisma";
|
||||
import SchemaBuilder from "@pothos/core";
|
||||
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";
|
||||
} from '@pothos/plugin-prisma';
|
||||
import type { YogaInitialContext } from 'graphql-yoga';
|
||||
|
||||
type Context = YogaInitialContext & {
|
||||
config: Configuration;
|
||||
|
|
@ -24,6 +24,6 @@ export const builder = new SchemaBuilder<{
|
|||
// 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",
|
||||
onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn',
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { LoadConfig } from "@app/config";
|
||||
import type { YogaInitialContext } from "graphql-yoga";
|
||||
import { LoadConfig } from '@app/config';
|
||||
import type { YogaInitialContext } from 'graphql-yoga';
|
||||
|
||||
export const context = (initialContext: YogaInitialContext) => {
|
||||
const config = LoadConfig();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { yogaLogger } from "@lib/logger";
|
||||
import { createYoga } from "graphql-yoga";
|
||||
import { context } from "./context";
|
||||
import { schema } from "./schema";
|
||||
import { yogaLogger } from '@lib/logger';
|
||||
import { createYoga } from 'graphql-yoga';
|
||||
import { context } from './context';
|
||||
import { schema } from './schema';
|
||||
|
||||
export const yoga = createYoga({
|
||||
schema,
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import { prisma } from "@app/prisma";
|
||||
import { builder } from "./builder";
|
||||
import { prisma } from '@app/prisma';
|
||||
import { builder } from './builder';
|
||||
|
||||
const User = builder.prismaObject("User", {
|
||||
const User = builder.prismaObject('User', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID("id"),
|
||||
email: t.exposeString("email"),
|
||||
name: t.exposeString("name"),
|
||||
posts: t.relation("posts"),
|
||||
id: t.exposeID('id'),
|
||||
email: t.exposeString('email'),
|
||||
name: t.exposeString('name'),
|
||||
posts: t.relation('posts'),
|
||||
}),
|
||||
});
|
||||
|
||||
const Post = builder.prismaObject("Post", {
|
||||
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"),
|
||||
id: t.exposeID('id'),
|
||||
title: t.exposeString('title'),
|
||||
content: t.exposeString('content'),
|
||||
published: t.exposeBoolean('published'),
|
||||
author: t.relation('author'),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue