moved dto's out of server folder.

This commit is contained in:
rykuno 2024-08-31 13:35:16 -05:00
parent ed50dc25f3
commit e512fab9f9
16 changed files with 21 additions and 153 deletions

View file

@ -1,23 +1,5 @@
import { z } from 'zod';
/* -------------------------------------------------------------------------- */
/* DTO */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ---------------------------------- About --------------------------------- */
/*
Data Transfer Objects (DTOs) are used to define the shape of data that is passed.
They are used to validate data and ensure that the correct data is being passed
to the correct methods.
*/
/* ---------------------------------- Notes --------------------------------- */
/*
DTO's are pretty flexible. You can use them anywhere you want in this application to
validate or shape data. They are especially useful in API routes and services to
ensure that the correct data is being passed around.
*/
/* -------------------------------------------------------------------------- */
export const registerEmailDto = z.object({
email: z.string().email()
});

View file

@ -1,23 +1,5 @@
import { z } from 'zod';
/* -------------------------------------------------------------------------- */
/* DTO */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ---------------------------------- About --------------------------------- */
/*
Data Transfer Objects (DTOs) are used to define the shape of data that is passed.
They are used to validate data and ensure that the correct data is being passed
to the correct methods.
*/
/* ---------------------------------- Notes --------------------------------- */
/*
DTO's are pretty flexible. You can use them anywhere you want in this application to
validate or shape data. They are especially useful in API routes and services to
ensure that the correct data is being passed around.
*/
/* -------------------------------------------------------------------------- */
export const signInEmailDto = z.object({
email: z.string().email(),
token: z.string()

View file

@ -1,23 +1,5 @@
import { z } from 'zod';
/* -------------------------------------------------------------------------- */
/* DTO */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ---------------------------------- About --------------------------------- */
/*
Data Transfer Objects (DTOs) are used to define the shape of data that is passed.
They are used to validate data and ensure that the correct data is being passed
to the correct methods.
*/
/* ---------------------------------- Notes --------------------------------- */
/*
DTO's are pretty flexible. You can use them anywhere you want in this application to
validate or shape data. They are especially useful in API routes and services to
ensure that the correct data is being passed around.
*/
/* -------------------------------------------------------------------------- */
export const updateEmailDto = z.object({
email: z.string().email()
});

View file

@ -1,23 +1,5 @@
import { z } from 'zod';
/* -------------------------------------------------------------------------- */
/* DTO */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ---------------------------------- About --------------------------------- */
/*
Data Transfer Objects (DTOs) are used to define the shape of data that is passed.
They are used to validate data and ensure that the correct data is being passed
to the correct methods.
*/
/* ---------------------------------- Notes --------------------------------- */
/*
DTO's are pretty flexible. You can use them anywhere you want in this application to
validate or shape data. They are especially useful in API routes and services to
ensure that the correct data is being passed around.
*/
/* -------------------------------------------------------------------------- */
export const verifyEmailDto = z.object({
token: z.string()
});

View file

@ -1,7 +0,0 @@
import { Hono } from 'hono';
import type { BlankSchema } from 'hono/types';
import type { HonoTypes } from '../types/hono.type';
// export interface Controller {
// routes()
// }

View file

@ -1,6 +1,3 @@
export interface Email {
subject(): string
html(): string;

View file

@ -4,13 +4,13 @@ import { inject, injectable } from 'tsyringe';
import { zValidator } from '@hono/zod-validator';
import { IamService } from '../services/iam.service';
import { LuciaProvider } from '../providers/lucia.provider';
import { signInEmailDto } from '../../../dtos/signin-email.dto';
import { updateEmailDto } from '../../../dtos/update-email.dto';
import { verifyEmailDto } from '../../../dtos/verify-email.dto';
import { registerEmailDto } from '../../../dtos/register-email.dto';
import { limiter } from '../middlewares/rate-limiter.middlware';
import { requireAuth } from '../middlewares/auth.middleware';
import { Controler } from '../common/classes/controller.class';
import { registerEmailDto } from '$lib/dtos/register-email.dto';
import { signInEmailDto } from '$lib/dtos/signin-email.dto';
import { updateEmailDto } from '$lib/dtos/update-email.dto';
import { verifyEmailDto } from '$lib/dtos/verify-email.dto';
@injectable()
export class IamController extends Controler {

View file

@ -1,7 +0,0 @@
import { z } from 'zod';
export const registerEmailDto = z.object({
email: z.string().email()
});
export type RegisterEmailDto = z.infer<typeof registerEmailDto>;

View file

@ -1,8 +0,0 @@
import { z } from 'zod';
export const signInEmailDto = z.object({
email: z.string().email(),
token: z.string()
});
export type SignInEmailDto = z.infer<typeof signInEmailDto>;

View file

@ -1,6 +0,0 @@
import { z } from 'zod';
export const updateEmailDto = z.object({
email: z.string().email()
});
export type UpdateEmailDto = z.infer<typeof updateEmailDto>;

View file

@ -1,6 +0,0 @@
import { z } from 'zod';
export const verifyEmailDto = z.object({
token: z.string()
});
export type VerifyEmailDto = z.infer<typeof verifyEmailDto>;

View file

@ -1,15 +1,15 @@
import { inject, injectable } from "tsyringe";
import { JobsService } from "../services/jobs.service";
// Example on how to create a job that runs once a week at midnight on Sunday
@injectable()
export class AuthCleanupJobs {
private queue;
constructor(
@inject(JobsService) private jobsService: JobsService,
) {
constructor(@inject(JobsService) private jobsService: JobsService) {
/* ------------------------------ Create Queue ------------------------------ */
this.queue = this.jobsService.createQueue('test')
this.queue = this.jobsService.createQueue('auth_cleanup')
/* ---------------------------- Register Workers ---------------------------- */
this.worker();

View file

@ -3,8 +3,8 @@ import { MailerService } from './mailer.service';
import { TokensService } from './tokens.service';
import { LuciaProvider } from '../providers/lucia.provider';
import { UsersRepository } from '../repositories/users.repository';
import type { SignInEmailDto } from '../dtos/signin-email.dto';
import type { RegisterEmailDto } from '../dtos/register-email.dto';
import type { SignInEmailDto } from '../../../dtos/signin-email.dto';
import type { RegisterEmailDto } from '../../../dtos/register-email.dto';
import { LoginRequestsRepository } from '../repositories/login-requests.repository';
import { LoginVerificationEmail } from '../emails/login-verification.email';
import { DatabaseProvider } from '../providers/database.provider';

View file

@ -4,8 +4,7 @@ import { RedisProvider } from "../providers/redis.provider";
@injectable()
export class JobsService {
constructor(@inject(RedisProvider) private readonly redis: RedisProvider) {
}
constructor(@inject(RedisProvider) private readonly redis: RedisProvider) { }
createQueue(name: string) {
return new Queue(name, { connection: this.redis })

View file

@ -1,9 +1,9 @@
import { fail, redirect } from '@sveltejs/kit';
import { zod } from 'sveltekit-superforms/adapters';
import { signInEmailDto } from '$lib/dtos/signin-email.dto.js';
import { setError, superValidate } from 'sveltekit-superforms';
import { registerEmailDto } from '$lib/dtos/register-email.dto.js';
import { StatusCodes } from '$lib/constants/status-codes';
import { registerEmailDto } from '$lib/dtos/register-email.dto';
import { signInEmailDto } from '$lib/dtos/signin-email.dto';
import { setError, superValidate } from 'sveltekit-superforms';
export const load = async () => {
return {

View file

@ -1,34 +1,13 @@
<!-- <script>
import { enhance } from '$app/forms';
</script>
<h3>Register</h3>
<form action="?/register" method="POST" use:enhance>
<label for="email">Email</label>
<input name="email" type="email" />
<button type="submit">Register</button>
</form>
<h3>Verify</h3>
<form action="?/signin" method="POST" use:enhance>
<label for="email">Email</label>
<input name="email" type="email" />
<label for="token">Token</label>
<input name="token" type="text" />
<button type="submit">Login</button>
</form> -->
<script lang="ts">
import { Button } from "$lib/components/ui/button/index.js";
import * as Card from "$lib/components/ui/card/index.js";
import { Input } from "$lib/components/ui/input/index.js";
import { Label } from "$lib/components/ui/label/index.js";
import { Button } from '$lib/components/ui/button/index.js';
import * as Card from '$lib/components/ui/card/index.js';
import { Input } from '$lib/components/ui/input/index.js';
import { superForm } from 'sveltekit-superforms';
import * as Form from '$lib/components/ui/form';
import { zodClient } from 'sveltekit-superforms/adapters';
import { registerEmailDto } from "$lib/dtos/register-email.dto.js";
import { signInEmailDto } from "$lib/dtos/signin-email.dto.js";
import PinInput from "$lib/components/pin-input.svelte";
import { registerEmailDto } from '$lib/dtos/register-email.dto.js';
import { signInEmailDto } from '$lib/dtos/signin-email.dto.js';
import PinInput from '$lib/components/pin-input.svelte';
const { data } = $props();
@ -52,7 +31,6 @@
const { form: emailRegisterFormData, enhance: emailRegisterEnhance } = emailRegisterForm;
const { form: emailSigninFormData, enhance: emailSigninEnhance } = emailSigninForm;
</script>
<Card.Root class="mx-auto mt-24 max-w-sm">