FoundKey/packages/backend/src/models/repositories/auth-session.ts
Johann150 6ce4b3fe2f
Some checks failed
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/test Pipeline failed
fix some lints
Many of these were fixed automatically with eslint --fix.

Some of them (e.g. adding return types to functions) were done manually.
2022-08-11 00:09:29 +02:00

21 lines
635 B
TypeScript

import { db } from '@/db/postgre.js';
import { AuthSession } from '@/models/entities/auth-session.js';
import { User } from '@/models/entities/user.js';
import { awaitAll } from '@/prelude/await-all.js';
import { Apps } from '../index.js';
export const AuthSessionRepository = db.getRepository(AuthSession).extend({
async pack(
src: AuthSession['id'] | AuthSession,
me?: { id: User['id'] } | null | undefined,
) {
const session = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
return await awaitAll({
id: session.id,
app: Apps.pack(session.appId, me),
token: session.token,
});
},
});