Skip to content

Commit

Permalink
refactor: better project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lewebsimple committed Dec 4, 2023
1 parent f085f04 commit 96ecaf1
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 188 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
useHead({ title: "Home" });
useHead({ title: "Accueil" });
</script>

<template>
Expand Down
File renamed without changes.
6 changes: 0 additions & 6 deletions app/types/utils.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AuthRole } from "@prisma/client";

import { auth } from "~/auth/server/utils/auth";

import type { SeedFn } from "../seed";
import type { SeedFn } from "~/prisma/server/seed";

export const seedAdminUser: SeedFn = async (prisma) => {
const adminUserData = {
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions graphql/server/types.ts

This file was deleted.

2 changes: 2 additions & 0 deletions graphql/server/utils/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type PrismaTypes from "@pothos/plugin-prisma/generated";
import PrismaUtils from "@pothos/plugin-prisma-utils";
import RelayPlugin from "@pothos/plugin-relay";
import ScopeAuthPlugin from "@pothos/plugin-scope-auth";
import SimpleObjectsPlugin from "@pothos/plugin-simple-objects";
import { Prisma } from "@prisma/client";

import { type Scalars } from "~/graphql/server/types/scalars";
Expand All @@ -22,6 +23,7 @@ export const builder = new SchemaBuilder<{
PrismaPlugin,
PrismaUtils,
RelayPlugin,
SimpleObjectsPlugin,
],
prisma: {
client: prisma,
Expand Down
6 changes: 4 additions & 2 deletions graphql/server/utils/schema.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { writeFileSync } from "fs";
import { lexicographicSortSchema, printSchema } from "graphql";

import * as types from "../types";
import * as appInfo from "~/app/server/types/app-info";
import * as authUser from "~/auth/server/types/auth-user";
import * as scalars from "~/graphql/server/types/scalars";

// Initialize builder
builder.queryType({});
builder.mutationType({});
//builder.subscriptionType({});
Function.prototype(types);
Function.prototype({ appInfo, authUser, scalars });

export const schema = builder.toSchema();

Expand Down
33 changes: 33 additions & 0 deletions graphql/utils/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,37 @@ export type Scalars = {
Upload: { input: File; output: File; }
};

export enum AuthRole {
Administrator = 'ADMINISTRATOR',
Unverified = 'UNVERIFIED',
Verified = 'VERIFIED'
}

export type AuthRoleFilter = {
equals?: InputMaybe<AuthRole>;
in?: InputMaybe<Array<AuthRole>>;
notIn?: InputMaybe<Array<AuthRole>>;
};

export type AuthUser = Node & {
__typename?: 'AuthUser';
email: Scalars['String']['output'];
globalId: Scalars['ID']['output'];
id: Scalars['ID']['output'];
role: AuthRole;
};

export type AuthUserFilter = {
role?: InputMaybe<AuthRoleFilter>;
};

export type AuthUserOrderBy = {
email?: InputMaybe<OrderBy>;
role?: InputMaybe<OrderBy>;
};

export type AuthUserUniqueFilter = {
email: Scalars['String']['input'];
};

export type Mutation = {
Expand All @@ -35,6 +61,11 @@ export type Node = {
globalId: Scalars['ID']['output'];
};

export enum OrderBy {
Asc = 'Asc',
Desc = 'Desc'
}

export type PageInfo = {
__typename?: 'PageInfo';
endCursor?: Maybe<Scalars['String']['output']>;
Expand All @@ -56,6 +87,8 @@ export type QueryAuthUsersArgs = {
before?: InputMaybe<Scalars['String']['input']>;
first?: InputMaybe<Scalars['Int']['input']>;
last?: InputMaybe<Scalars['Int']['input']>;
orderBy: AuthUserOrderBy;
where: AuthUserFilter;
};

export type QueryAuthUsersConnection = {
Expand Down
2 changes: 1 addition & 1 deletion jobs/server/plugins/bullmq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const queues = [dummyQueue];
const workers = [dummyWorker];

export default defineNitroPlugin(async (nitroApp) => {
await Promise.all(Object.values(queues).map((queue) => queue.obliterate()));
await Promise.all(Object.values(queues).map((queue) => queue.obliterate({ force: true })));
logger.success(`${Object.keys(queues).length} job queue(s) cleared`);

Function.prototype(workers);
Expand Down
29 changes: 0 additions & 29 deletions jobs/server/utils/dummy.ts

This file was deleted.

27 changes: 27 additions & 0 deletions jobs/server/utils/job-dummy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { logger } from "@nuxt/kit";
import { type Job, Queue, QueueEvents, Worker } from "bullmq";

const { connection } = useRuntimeConfig();

// Dummy job data / return types
export type DummyJobData = {};
export type DummyJobReturn = {
message: string;
};

export const dummyQueue = new Queue<DummyJobData, DummyJobReturn>("DummyJob", { connection });
export const dummyQueueEvents = new QueueEvents("DummyJob", { connection });

export const dummyWorker = new Worker<DummyJobData, DummyJobReturn>(
"DummyJob",
async (job: Job<DummyJobData>) => {
return { message: `Dummy job ${job.name} executed successfully` };
},
{ connection },
)
.on("failed", async (job, error) => {
logger.error(`Dummy job ${job?.name} failed with error: ${error.message}`);
})
.on("completed", async (job) => {
logger.success(job.returnvalue.message);
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"release": "pnpm lint && changelogen --release --push"
},
"prisma": {
"seed": "tsx prisma/seed.ts"
"seed": "tsx prisma/server/seed.ts"
},
"dependencies": {
"@lucia-auth/adapter-prisma": "^3.0.2",
Expand All @@ -25,6 +25,7 @@
"@pothos/plugin-prisma-utils": "^0.13.0",
"@pothos/plugin-relay": "^3.45.0",
"@pothos/plugin-scope-auth": "^3.20.0",
"@pothos/plugin-simple-objects": "^3.7.0",
"@prisma/client": "^5.6.0",
"@urql/vue": "^1.1.2",
"bullmq": "^4.14.4",
Expand Down Expand Up @@ -64,4 +65,4 @@
"*.{js,ts,vue}": "eslint --fix",
"*.{css,scss,vue}": "stylelint --fix"
}
}
}
Loading

0 comments on commit 96ecaf1

Please sign in to comment.