Merge branch 'master' into improve-local-setup
This commit is contained in:
commit
e05ec06638
7 changed files with 12 additions and 66 deletions
8
.github/workflows/pr.yaml
vendored
8
.github/workflows/pr.yaml
vendored
|
|
@ -5,7 +5,7 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
checks:
|
checks:
|
||||||
name: Checks
|
name: Checks
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -15,9 +15,13 @@ jobs:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
- name: Install
|
- name: Install
|
||||||
run: bun install
|
run: bun install
|
||||||
|
- name: Lint
|
||||||
|
run: bun lint
|
||||||
- name: Test
|
- name: Test
|
||||||
run: bun test
|
run: bun test
|
||||||
- name: Build
|
- name: Build
|
||||||
run: bun run build
|
run: bun run build
|
||||||
- name: Prisma Schema Check
|
- name: Svelte Check
|
||||||
|
run: bun check
|
||||||
|
- name: Prisma Check
|
||||||
run: bun prisma:validate
|
run: bun prisma:validate
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
// place files you want to import through the `$lib` alias in this folder.
|
// place files you want to import through the `$lib` alias in this folder.
|
||||||
export * from './components';
|
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@ export async function validateSession(event: ServerLoadEvent) {
|
||||||
redirect(302, '/login');
|
redirect(302, '/login');
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ builder.mutationFields((t) => ({
|
||||||
},
|
},
|
||||||
resolve: async (parent, args) => {
|
resolve: async (parent, args) => {
|
||||||
const author = await prisma.user.findUnique({
|
const author = await prisma.user.findUnique({
|
||||||
where: { id: Number(args.input.authorId) },
|
where: { id: args.input.authorId },
|
||||||
});
|
});
|
||||||
if (!author) {
|
if (!author) {
|
||||||
throw new Error('Author does not exist!');
|
throw new Error('Author does not exist!');
|
||||||
|
|
@ -89,7 +89,7 @@ builder.mutationFields((t) => ({
|
||||||
resolve: async (parent, args) => {
|
resolve: async (parent, args) => {
|
||||||
const post = await prisma.post.update({
|
const post = await prisma.post.update({
|
||||||
where: {
|
where: {
|
||||||
id: Number(args.input.id),
|
id: args.input.id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
title: args.input.title ?? undefined,
|
title: args.input.title ?? undefined,
|
||||||
|
|
@ -98,7 +98,7 @@ builder.mutationFields((t) => ({
|
||||||
...(args.input.authorId && {
|
...(args.input.authorId && {
|
||||||
author: {
|
author: {
|
||||||
connect: {
|
connect: {
|
||||||
id: Number(args.input.authorId),
|
id: args.input.authorId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -16,27 +16,6 @@ export const User = builder.prismaObject('User', {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const CreateUser = builder.inputType('CreateUser', {
|
|
||||||
fields: (t) => ({
|
|
||||||
email: t.string({
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
name: t.string({
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
const UpdateUser = builder.inputType('UpdateUser', {
|
|
||||||
fields: (t) => ({
|
|
||||||
id: t.id({
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
email: t.string(),
|
|
||||||
name: t.string(),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.queryFields((t) => ({
|
builder.queryFields((t) => ({
|
||||||
users: t.prismaField({
|
users: t.prismaField({
|
||||||
type: [User],
|
type: [User],
|
||||||
|
|
@ -45,39 +24,3 @@ builder.queryFields((t) => ({
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
builder.mutationFields((t) => ({
|
|
||||||
createUser: t.field({
|
|
||||||
type: User,
|
|
||||||
args: {
|
|
||||||
input: t.arg({ required: true, type: CreateUser }),
|
|
||||||
},
|
|
||||||
resolve: async (parent, args) => {
|
|
||||||
const post = await prisma.user.create({
|
|
||||||
data: {
|
|
||||||
email: args.input.email,
|
|
||||||
name: args.input.name,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return post;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
updateUser: t.field({
|
|
||||||
type: User,
|
|
||||||
args: {
|
|
||||||
input: t.arg({ required: true, type: UpdateUser }),
|
|
||||||
},
|
|
||||||
resolve: async (parent, args) => {
|
|
||||||
const post = await prisma.user.update({
|
|
||||||
where: {
|
|
||||||
id: Number(args.input.id),
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
email: args.input.email,
|
|
||||||
name: args.input.name ?? undefined,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return post;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ import { validateSession } from '$lib/server/auth';
|
||||||
|
|
||||||
export async function load(event) {
|
export async function load(event) {
|
||||||
await validateSession(event);
|
await validateSession(event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ export async function load(event) {
|
||||||
return {
|
return {
|
||||||
user: rest,
|
user: rest,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue