clean up dead code/unused imports

This commit is contained in:
Erin 2023-11-12 16:16:12 -05:00
parent ec543afcb2
commit f6536baec2
8 changed files with 7 additions and 48 deletions

View file

@ -1,4 +1,4 @@
import {BeforeInsert, Column, Entity, ManyToOne, PrimaryColumn} from 'typeorm'; import {Column, Entity, ManyToOne, PrimaryColumn} from 'typeorm';
import {AuthProvider} from '$lib/server/auth'; import {AuthProvider} from '$lib/server/auth';
import {User} from '$lib/server/entity/User'; import {User} from '$lib/server/entity/User';
@ -20,9 +20,4 @@ export class AuthMethod {
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })
user!: User; user!: User;
@BeforeInsert()
private beforeInsert () {
this.id = ulidMonotonic();
}
} }

View file

@ -1,4 +1,4 @@
import {BeforeInsert, Entity, ManyToOne, PrimaryColumn} from 'typeorm'; import {Entity, ManyToOne, PrimaryColumn} from 'typeorm';
import {AuthMethod} from '$lib/server/entity/AuthMethod'; import {AuthMethod} from '$lib/server/entity/AuthMethod';
import {ulidMonotonic} from '$lib/server/ulid'; import {ulidMonotonic} from '$lib/server/ulid';
@ -17,9 +17,4 @@ export class AuthSession {
authMethod!: AuthMethod; authMethod!: AuthMethod;
// TODO expiration of sessions? // TODO expiration of sessions?
@BeforeInsert()
private beforeInsert () {
this.id = ulidMonotonic();
}
} }

View file

@ -1,5 +1,5 @@
import * as crypto from 'node:crypto'; import * as crypto from 'node:crypto';
import {BeforeInsert, Column, Entity, ManyToOne, PrimaryColumn} from 'typeorm'; import {Column, Entity, PrimaryColumn} from 'typeorm';
import {AuthProvider} from '$lib/server/auth'; import {AuthProvider} from '$lib/server/auth';
import {ulidMonotonic} from '$lib/server/ulid'; import {ulidMonotonic} from '$lib/server/ulid';

View file

@ -1,4 +1,4 @@
import {BeforeInsert, Entity, ManyToOne, PrimaryColumn} from 'typeorm'; import {Entity, ManyToOne, PrimaryColumn} from 'typeorm';
import {Node} from '$lib/server/entity/Node'; import {Node} from '$lib/server/entity/Node';
import {ulidMonotonic} from '$lib/server/ulid'; import {ulidMonotonic} from '$lib/server/ulid';
@ -21,9 +21,4 @@ export class Edge {
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })
tail!: Node; tail!: Node;
@BeforeInsert()
beforeInsert () {
this.id = ulidMonotonic();
}
} }

View file

@ -1,4 +1,4 @@
import {BeforeInsert, Column, Entity, OneToMany, PrimaryColumn} from 'typeorm'; import {Column, Entity, OneToMany, PrimaryColumn} from 'typeorm';
import {Edge} from '$lib/server/entity/Edge'; import {Edge} from '$lib/server/entity/Edge';
import {ulidMonotonic} from '$lib/server/ulid'; import {ulidMonotonic} from '$lib/server/ulid';
@ -22,9 +22,4 @@ export class Node {
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })
incomingEdges!: Edge[]; incomingEdges!: Edge[];
@BeforeInsert()
private beforeInsert () {
this.id = ulidMonotonic();
}
} }

View file

@ -1,5 +1,4 @@
import { import {
BeforeInsert,
Column, Column,
CreateDateColumn, CreateDateColumn,
Entity, Entity,
@ -23,9 +22,4 @@ export class User {
@OneToMany(() => AuthMethod, authMethod => authMethod.user) @OneToMany(() => AuthMethod, authMethod => authMethod.user)
authMethods!: AuthMethod[]; authMethods!: AuthMethod[];
@BeforeInsert()
private beforeInsert () {
this.id = ulidMonotonic();
}
} }

View file

@ -3,14 +3,6 @@ import {getUserFromSessionID} from '$lib/server/sessionutil';
import type {LayoutServerLoad} from './$types'; import type {LayoutServerLoad} from './$types';
async function findSession (sessionID?: string) {
const dataSource = await getDataSource();
const sessionsRepo = dataSource.getRepository(AuthSession);
if (!sessionID) { return null; }
return await sessionsRepo.findOne({where: {id: sessionID}});
}
export const load: LayoutServerLoad = async ({cookies}) => { export const load: LayoutServerLoad = async ({cookies}) => {
return JSON.parse(JSON.stringify({ return JSON.parse(JSON.stringify({
user: await getUserFromSessionID(cookies.get(Cookie.SESSION_ID)), user: await getUserFromSessionID(cookies.get(Cookie.SESSION_ID)),

View file

@ -1,16 +1,9 @@
import {redirect} from '@sveltejs/kit'; import {redirect} from '@sveltejs/kit';
import * as crypto from 'node:crypto';
import {AuthProvider, authProviderImplementations} from '$lib/server/auth';
import {Cookie} from '$lib/server/cookies';
import {getDataSource} from '$lib/server/db'; import {getDataSource} from '$lib/server/db';
import {AuthState} from '$lib/server/entity/AuthState'; import {AuthState} from '$lib/server/entity/AuthState';
import {env} from '$env/dynamic/private';
import {
AuthProvider,
type AuthProviderImplementation,
authProviderImplementations,
} from '$lib/server/auth';
import {Cookie} from '$lib/server/cookies';
import type {PageServerLoad} from './$types'; import type {PageServerLoad} from './$types';
export const load: PageServerLoad = async ({cookies, params, url}) => { export const load: PageServerLoad = async ({cookies, params, url}) => {