.
This commit is contained in:
parent
0ae16f2d9f
commit
84661b06dd
13
.prettierrc
13
.prettierrc
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"bracketSpacing": true,
|
|
||||||
"useTabs": false,
|
|
||||||
"printWidth": 100,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": false,
|
|
||||||
"trailingComma": "es5",
|
|
||||||
"jsxSingleQuote": true,
|
|
||||||
"jsxBracketSameLine": false,
|
|
||||||
"arrowParens": "always",
|
|
||||||
"rcVerbose": true
|
|
||||||
}
|
|
||||||
3
.vscode/extensions.json
vendored
Normal file
3
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["esbenp.prettier-vscode", "biomejs.biome"]
|
||||||
|
}
|
||||||
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
@ -1,6 +1,23 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "SERVER: Run in Development Mode",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeExecutable": "npm",
|
||||||
|
"runtimeArgs": ["run", "dev"],
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SERVER: Run in Production Mode",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeExecutable": "npm",
|
||||||
|
"runtimeArgs": ["run", "start"],
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"preLaunchTask": "npm: build"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Attach to Turbo Server API (ts-node-dev)",
|
"name": "Attach to Turbo Server API (ts-node-dev)",
|
||||||
"type": "node",
|
"type": "node",
|
||||||
|
|||||||
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@ -17,15 +17,18 @@
|
|||||||
"typescript.preferences.importModuleSpecifier": "shortest",
|
"typescript.preferences.importModuleSpecifier": "shortest",
|
||||||
|
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.organizeImports": "explicit",
|
"source.fixAll": "explicit",
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.biome": "explicit",
|
||||||
|
"source.organizeImports.biome": "explicit",
|
||||||
|
"source.removeUnusedImports": "explicit"
|
||||||
},
|
},
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "biomejs.biome",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.formatOnPaste": false,
|
"editor.formatOnPaste": false,
|
||||||
"prettier.useEditorConfig": false,
|
|
||||||
"prettier.useTabs": false,
|
"[javascript][typescript][json][jsonc]": {
|
||||||
"prettier.configPath": ".prettierrc",
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
|
||||||
// other vscode settings
|
// other vscode settings
|
||||||
"[handlebars]": {
|
"[handlebars]": {
|
||||||
|
|||||||
@ -6,7 +6,12 @@ import {
|
|||||||
UniqueID,
|
UniqueID,
|
||||||
} from "@/core/common/domain";
|
} from "@/core/common/domain";
|
||||||
|
|
||||||
import { Account, AccountStatus, IAccountProps, IAccountService } from "@/contexts/accounts/domain";
|
import {
|
||||||
|
type Account,
|
||||||
|
AccountStatus,
|
||||||
|
type IAccountProps,
|
||||||
|
type IAccountService,
|
||||||
|
} from "@/contexts/accounts/domain";
|
||||||
import { Maybe, Result } from "@/core/common/helpers";
|
import { Maybe, Result } from "@/core/common/helpers";
|
||||||
import { ITransactionManager } from "@/core/common/infrastructure/database";
|
import { ITransactionManager } from "@/core/common/infrastructure/database";
|
||||||
import { logger } from "@/core/common/infrastructure/logger";
|
import { logger } from "@/core/common/infrastructure/logger";
|
||||||
@ -1,7 +1,6 @@
|
|||||||
import { Account, IAccountService } from "@/contexts/accounts/domain";
|
import { Account, IAccountService } from "@/contexts/accounts/domain";
|
||||||
import { Collection, Result } from "@/core/common/helpers";
|
import { Collection, Result } from "@/core/common/helpers";
|
||||||
import { ITransactionManager } from "@/core/common/infrastructure/database";
|
import { ITransactionManager } from "@/core/common/infrastructure/database";
|
||||||
import { logger } from "@/core/common/infrastructure/logger";
|
|
||||||
|
|
||||||
export class ListAccountsUseCase {
|
export class ListAccountsUseCase {
|
||||||
constructor(
|
constructor(
|
||||||
@ -1,11 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
AggregateRoot,
|
AggregateRoot,
|
||||||
EmailAddress,
|
type EmailAddress,
|
||||||
PhoneNumber,
|
type PhoneNumber,
|
||||||
PostalAddress,
|
PostalAddress,
|
||||||
TINNumber,
|
type TINNumber,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
} from "@/core/common/domain";
|
} from "@/core";
|
||||||
import { Maybe, Result } from "@/core/common/helpers";
|
import { Maybe, Result } from "@/core/common/helpers";
|
||||||
import { AccountStatus } from "../value-objects";
|
import { AccountStatus } from "../value-objects";
|
||||||
|
|
||||||
@ -58,6 +58,7 @@ export interface IAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Account extends AggregateRoot<IAccountProps> implements IAccount {
|
export class Account extends AggregateRoot<IAccountProps> implements IAccount {
|
||||||
|
id: UniqueID;
|
||||||
static create(props: IAccountProps, id?: UniqueID): Result<Account, Error> {
|
static create(props: IAccountProps, id?: UniqueID): Result<Account, Error> {
|
||||||
const account = new Account(props, id);
|
const account = new Account(props, id);
|
||||||
|
|
||||||
@ -8,8 +8,8 @@ import {
|
|||||||
} from "@/core/common/domain";
|
} from "@/core/common/domain";
|
||||||
import { Maybe, Result } from "@/core/common/helpers";
|
import { Maybe, Result } from "@/core/common/helpers";
|
||||||
import {
|
import {
|
||||||
ISequelizeMapper,
|
type ISequelizeMapper,
|
||||||
MapperParamsType,
|
type MapperParamsType,
|
||||||
SequelizeMapper,
|
SequelizeMapper,
|
||||||
} from "@/core/common/infrastructure/sequelize/sequelize-mapper";
|
} from "@/core/common/infrastructure/sequelize/sequelize-mapper";
|
||||||
import { AccountCreationAttributes, AccountModel } from "../sequelize/account.model";
|
import { AccountCreationAttributes, AccountModel } from "../sequelize/account.model";
|
||||||
@ -4,7 +4,7 @@ import { EmailAddress, UniqueID } from "@/core/common/domain";
|
|||||||
import { Collection, Result } from "@/core/common/helpers";
|
import { Collection, Result } from "@/core/common/helpers";
|
||||||
import { SequelizeRepository } from "@/core/common/infrastructure";
|
import { SequelizeRepository } from "@/core/common/infrastructure";
|
||||||
import { Transaction } from "sequelize";
|
import { Transaction } from "sequelize";
|
||||||
import { accountMapper, IAccountMapper } from "../mappers/account.mapper";
|
import { IAccountMapper, accountMapper } from "../mappers/account.mapper";
|
||||||
import { AccountModel } from "./account.model";
|
import { AccountModel } from "./account.model";
|
||||||
|
|
||||||
class AccountRepository extends SequelizeRepository<Account> implements IAccountRepository {
|
class AccountRepository extends SequelizeRepository<Account> implements IAccountRepository {
|
||||||
@ -1,4 +1,4 @@
|
|||||||
export interface IListAccountsRequestDTO {}
|
export type IListAccountsRequestDTO = {}
|
||||||
|
|
||||||
export interface ICreateAccountRequestDTO {
|
export interface ICreateAccountRequestDTO {
|
||||||
id: string;
|
id: string;
|
||||||
@ -33,8 +33,8 @@ export class AuthenticatedUser
|
|||||||
extends AggregateRoot<IAuthenticatedUserProps>
|
extends AggregateRoot<IAuthenticatedUserProps>
|
||||||
implements IAuthenticatedUser
|
implements IAuthenticatedUser
|
||||||
{
|
{
|
||||||
public accessToken: string = "";
|
public accessToken = "";
|
||||||
public refreshToken: string = "";
|
public refreshToken = "";
|
||||||
|
|
||||||
static create(props: IAuthenticatedUserProps, id: UniqueID): Result<AuthenticatedUser, Error> {
|
static create(props: IAuthenticatedUserProps, id: UniqueID): Result<AuthenticatedUser, Error> {
|
||||||
const user = new AuthenticatedUser(props, id);
|
const user = new AuthenticatedUser(props, id);
|
||||||
@ -1,9 +1,9 @@
|
|||||||
import { AggregateRoot, UniqueID } from "@/core/common/domain";
|
import { AggregateRoot, UniqueID } from "@/core/common/domain";
|
||||||
import { Result } from "@/core/common/helpers";
|
import { Result } from "@/core/common/helpers";
|
||||||
|
|
||||||
export interface IRoleProps {}
|
export type IRoleProps = {};
|
||||||
|
|
||||||
export interface IRole {}
|
export type IRole = {};
|
||||||
|
|
||||||
export class Role extends AggregateRoot<IRoleProps> implements IRole {
|
export class Role extends AggregateRoot<IRoleProps> implements IRole {
|
||||||
static create(props: IRoleProps, id: UniqueID): Result<Role, Error> {
|
static create(props: IRoleProps, id: UniqueID): Result<Role, Error> {
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export type IUserPermissionRepository = {}
|
||||||
@ -1,6 +1,13 @@
|
|||||||
import { EmailAddress } from "@/core/common/domain";
|
import { EmailAddress } from "@/core/common/domain";
|
||||||
import { Result } from "@/core/common/helpers";
|
import { Result } from "@/core/common/helpers";
|
||||||
import { AuthenticatedUser, IJWTPayload, LoginData, RegisterData, TabContext, Token } from "..";
|
import {
|
||||||
|
AuthenticatedUser,
|
||||||
|
type IJWTPayload,
|
||||||
|
type LoginData,
|
||||||
|
type RegisterData,
|
||||||
|
TabContext,
|
||||||
|
Token,
|
||||||
|
} from "..";
|
||||||
|
|
||||||
import { UniqueID } from "@/core/common/domain";
|
import { UniqueID } from "@/core/common/domain";
|
||||||
import { IAuthenticatedUserRepository, JWTPayload } from "..";
|
import { IAuthenticatedUserRepository, JWTPayload } from "..";
|
||||||
@ -28,4 +28,8 @@ export class UserRoles extends ValueObject<UserRolesProps> {
|
|||||||
getValue() {
|
getValue() {
|
||||||
return this.props.value;
|
return this.props.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toPrimitive() {
|
||||||
|
return this.props.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import bcrypt from "bcrypt";
|
||||||
import { ValueObject } from "@/core/common/domain";
|
import { ValueObject } from "@/core/common/domain";
|
||||||
import { Result } from "@/core/common/helpers";
|
import { Result } from "@/core/common/helpers";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@ -29,4 +29,9 @@ export class PlainPassword extends ValueObject<PlainPasswordProps> {
|
|||||||
toString() {
|
toString() {
|
||||||
return this.props.value;
|
return this.props.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toPrimitive() {
|
||||||
|
return this.props.value;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -29,4 +29,9 @@ export class Token extends ValueObject<TokenProps> {
|
|||||||
toString() {
|
toString() {
|
||||||
return this.props.value;
|
return this.props.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toPrimitive() {
|
||||||
|
return this.props.value;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -6,8 +6,8 @@ import {
|
|||||||
SequelizeMapper,
|
SequelizeMapper,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
} from "@/core";
|
} from "@/core";
|
||||||
import { AuthenticatedUser, HashPassword, Username } from "../../domain";
|
import { AuthUserCreationAttributes, AuthUserModel } from '../sequelize';
|
||||||
import { AuthUserCreationAttributes, AuthUserModel } from "../sequelize";
|
import { AuthenticatedUser, HashPassword, Username } from '../../domain';
|
||||||
|
|
||||||
export interface IAuthenticatedUserMapper
|
export interface IAuthenticatedUserMapper
|
||||||
extends ISequelizeMapper<AuthUserModel, AuthUserCreationAttributes, AuthenticatedUser> {}
|
extends ISequelizeMapper<AuthUserModel, AuthUserCreationAttributes, AuthenticatedUser> {}
|
||||||
@ -52,8 +52,8 @@ export class AuthenticatedUserMapper
|
|||||||
public mapToPersistence(
|
public mapToPersistence(
|
||||||
source: AuthenticatedUser,
|
source: AuthenticatedUser,
|
||||||
params?: MapperParamsType
|
params?: MapperParamsType
|
||||||
): Result<AuthUserCreationAttributes, Error> {
|
): AuthUserCreationAttributes {
|
||||||
return Result.ok({
|
return {
|
||||||
id: source.id.toString(),
|
id: source.id.toString(),
|
||||||
username: source.username.toString(),
|
username: source.username.toString(),
|
||||||
email: source.email.toString(),
|
email: source.email.toString(),
|
||||||
@ -61,7 +61,7 @@ export class AuthenticatedUserMapper
|
|||||||
roles: source.getRoles().map((role) => role.toString()),
|
roles: source.getRoles().map((role) => role.toString()),
|
||||||
//access_token: source.accessToken,
|
//access_token: source.accessToken,
|
||||||
//refresh_token: source.refreshToken,
|
//refresh_token: source.refreshToken,
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,6 +1,10 @@
|
|||||||
import { UniqueID } from "@/core/common/domain";
|
import { UniqueID } from "@/core/common/domain";
|
||||||
import { Result } from "@/core/common/helpers";
|
import { Result } from "@/core/common/helpers";
|
||||||
import { ISequelizeMapper, MapperParamsType, SequelizeMapper } from "@/core/common/infrastructure";
|
import {
|
||||||
|
type ISequelizeMapper,
|
||||||
|
type MapperParamsType,
|
||||||
|
SequelizeMapper,
|
||||||
|
} from "@/core/common/infrastructure";
|
||||||
import { TabContext } from "../../domain";
|
import { TabContext } from "../../domain";
|
||||||
import { TabContextCreationAttributes, TabContextModel } from "../sequelize";
|
import { TabContextCreationAttributes, TabContextModel } from "../sequelize";
|
||||||
|
|
||||||
@ -49,12 +53,12 @@ export class TabContextMapper
|
|||||||
public mapToPersistence(
|
public mapToPersistence(
|
||||||
source: TabContext,
|
source: TabContext,
|
||||||
params?: MapperParamsType
|
params?: MapperParamsType
|
||||||
): Result<TabContextCreationAttributes, Error> {
|
): TabContextCreationAttributes {
|
||||||
return Result.ok({
|
return {
|
||||||
id: source.id.toString(),
|
id: source.id.toString(),
|
||||||
tab_id: source.tabId.toString(),
|
tab_id: source.tabId.toString(),
|
||||||
user_id: source.userId.toString(),
|
user_id: source.userId.toString(),
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import { EmailAddress, UniqueID } from "@/core/common/domain";
|
import { EmailAddress, UniqueID } from "@/core/common/domain";
|
||||||
import { Result } from "@/core/common/helpers";
|
import { Result } from "@/core/common/helpers";
|
||||||
import {
|
import {
|
||||||
ISequelizeMapper,
|
type ISequelizeMapper,
|
||||||
MapperParamsType,
|
type MapperParamsType,
|
||||||
SequelizeMapper,
|
SequelizeMapper,
|
||||||
} from "@/core/common/infrastructure/sequelize/sequelize-mapper";
|
} from "@/core/common/infrastructure/sequelize/sequelize-mapper";
|
||||||
import { User, Username } from "../../domain";
|
import { User, Username } from "../../domain";
|
||||||
@ -38,16 +38,13 @@ class UserMapper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public mapToPersistence(
|
public mapToPersistence(source: User, params?: MapperParamsType): UserCreationAttributes {
|
||||||
source: User,
|
return {
|
||||||
params?: MapperParamsType
|
|
||||||
): Result<UserCreationAttributes, Error> {
|
|
||||||
return Result.ok({
|
|
||||||
id: source.id.toString(),
|
id: source.id.toString(),
|
||||||
username: source.username.toString(),
|
username: source.username.toString(),
|
||||||
email: source.email.toString(),
|
email: source.email.toString(),
|
||||||
//roles: source.getRoles().map((role) => role.toString()),
|
//roles: source.getRoles().map((role) => role.toString()),
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import { UniqueID } from "@/core/common/domain";
|
import { UniqueID } from "@/core/common/domain";
|
||||||
import { ApiError, ExpressController } from "@/core/common/presentation";
|
import { ApiError, ExpressController } from "@/core/common/presentation";
|
||||||
import { AuthenticatedUser } from "../../domain";
|
|
||||||
//import { authProvider } from "@/contexts/auth/infraestructure";
|
//import { authProvider } from "@/contexts/auth/infraestructure";
|
||||||
import { NextFunction, Response } from "express";
|
import { NextFunction, Response } from "express";
|
||||||
|
import { AuthenticatedUser } from "../../domain";
|
||||||
import { AuthenticatedRequest } from "../express/types";
|
import { AuthenticatedRequest } from "../express/types";
|
||||||
import { authProvider } from "../passport";
|
import { authProvider } from "../passport";
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user