Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove any direct db connection #8

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# next.js
/.next/
/out/
/prisma/schema.prisma

# production
/build
Expand Down
43 changes: 0 additions & 43 deletions Dockerfile

This file was deleted.

26 changes: 0 additions & 26 deletions docker-compose.yml

This file was deleted.

50 changes: 0 additions & 50 deletions lib/auth.js

This file was deleted.

33 changes: 0 additions & 33 deletions lib/db.js

This file was deleted.

32 changes: 0 additions & 32 deletions lib/middleware.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import cors from 'cors';
import { getSession } from './session';
import { getAuthToken } from './auth';
import { unauthorized, badRequest, serverError } from './response';

export function use(middleware) {
return (req, res) =>
Expand All @@ -16,32 +13,3 @@ export function use(middleware) {
}

export const useCors = use(cors());

export const useSession = use(async (req, res, next) => {
let session;

try {
session = await getSession(req);
} catch (e) {
console.error(e);
return serverError(res, e.message);
}

if (!session) {
return badRequest(res);
}

req.session = session;
next();
});

export const useAuth = use(async (req, res, next) => {
const token = await getAuthToken(req);

if (!token) {
return unauthorized(res);
}

req.auth = token;
next();
});
Loading