Skip to content

Commit

Permalink
More cleanup/naming tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
francisli committed Mar 29, 2024
1 parent b048099 commit 2e9281f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions server/plugins/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fp from 'fastify-plugin';
// the use of fastify-plugin is required to be able
// to export the decorators to the outer scope

export default fp(async function (fastify, _opts) {
export default fp(async function (fastify) {
// set up secure encrypted cookie-based sessions
await fastify.register(import('@fastify/secure-session'), {
key: Buffer.from(process.env.SESSION_SECRET_KEY, 'hex'),
Expand All @@ -16,7 +16,7 @@ export default fp(async function (fastify, _opts) {
// add a user object reference to the request instance
fastify.decorateRequest('user', null);
// add a hook to check for a signed in user on every request
fastify.addHook('onRequest', async (request, _reply) => {
fastify.addHook('onRequest', async (request) => {
// first check cookie-based session
const id = request.session.get('userId');
if (id) {
Expand Down
8 changes: 4 additions & 4 deletions server/plugins/prisma.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import fp from 'fastify-plugin';
import { PrismaClient } from '@prisma/client';

const prismaPlugin = fp(async (server, _options) => {
const prismaPlugin = fp(async (fastify) => {
const prisma = new PrismaClient({
datasourceUrl: process.env.DATABASE_URL,
});

await prisma.$connect();

// Make Prisma Client available through the fastify server instance: server.prisma
server.decorate('prisma', prisma);
fastify.decorate('prisma', prisma);

server.addHook('onClose', async (server) => {
await server.prisma.$disconnect();
fastify.addHook('onClose', async (fastify) => {
await fastify.prisma.$disconnect();
});
});

Expand Down
10 changes: 0 additions & 10 deletions server/plugins/support.js

This file was deleted.

0 comments on commit 2e9281f

Please sign in to comment.