Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dzangolab/fastify into update/super…
Browse files Browse the repository at this point in the history
…tokens-node
  • Loading branch information
dipendraupreti committed Mar 26, 2024
2 parents bbf7fcb + f33af7b commit ee0ec65
Show file tree
Hide file tree
Showing 34 changed files with 584 additions and 213 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# [0.64.0](https://github.com/dzangolab/fastify/compare/v0.63.0...v0.64.0) (2024-03-23)


### Features

* **user:** add permissions while creating role ([#622](https://github.com/dzangolab/fastify/issues/622)) ([5023a51](https://github.com/dzangolab/fastify/commit/5023a5151a210b4a6d71b83be53e08c16e2a4cd3))



# [0.63.0](https://github.com/dzangolab/fastify/compare/v0.62.4...v0.63.0) (2024-03-22)


### Features

* **config:** add multi-stream support for logger config ([#616](https://github.com/dzangolab/fastify/issues/616)) ([d9ebb2e](https://github.com/dzangolab/fastify/commit/d9ebb2efc4a5785d5e2b6519b4decb1014f6f1af))



## [0.62.4](https://github.com/dzangolab/fastify/compare/v0.62.3...v0.62.4) (2024-03-21)


### Bug Fixes

* update db filter input type ([#624](https://github.com/dzangolab/fastify/issues/624)) ([7a24d4c](https://github.com/dzangolab/fastify/commit/7a24d4c1a1f308fc9d33d0f387d3866b8dac1e05))



## [0.62.3](https://github.com/dzangolab/fastify/compare/v0.62.2...v0.62.3) (2024-03-20)



## [0.62.2](https://github.com/dzangolab/fastify/compare/v0.62.1...v0.62.2) (2024-03-07)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dzangolab/fastify",
"version": "0.62.2",
"version": "0.64.0",
"private": true,
"repository": {
"type": "git",
Expand Down
7 changes: 4 additions & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dzangolab/fastify-config",
"version": "0.62.2",
"version": "0.64.0",
"description": "Fastify config plugin",
"homepage": "https://github.com/dzangolab/fastify/tree/main/packages/config#readme",
"repository": {
Expand Down Expand Up @@ -36,11 +36,12 @@
"@typescript-eslint/parser": "5.62.0",
"@vitest/coverage-istanbul": "0.32.2",
"eslint": "8.56.0",
"eslint-config-custom": "0.62.2",
"eslint-config-custom": "0.64.0",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"prettier": "2.8.8",
"tsconfig": "0.62.2",
"pino": "8.8.0",
"tsconfig": "0.64.0",
"typescript": "4.9.5",
"vite": "4.3.9",
"vitest": "0.32.0"
Expand Down
31 changes: 28 additions & 3 deletions packages/config/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
import type {
DestinationStream,
Level,
LoggerOptions,
StreamEntry,
} from "pino";

interface AppConfig {
id: number;
name: string;
origin: string;
supportedRoles: string[];
}

type Compressor = (source: string, destination: string) => string;

interface ApiConfig {
appName: string;
appOrigin: string[];
apps?: AppConfig[];
baseUrl: string;
env: string;
logger: {
level: string;
transport?: {
target: string;
base?: LoggerOptions["base"];
formatters?: LoggerOptions["formatters"];
level: Level;
prettyPrint?: {
options: {
colorize: boolean;
ignore: string;
translateTime: string;
};
};
rotation?: {
enabled: boolean;
options: {
compress?: boolean | string | Compressor;
filenames: string[];
interval?: string;
maxFiles?: number;
maxSize?: string;
path: string;
size?: string;
};
};
streams?: (DestinationStream | StreamEntry)[];
transport?: LoggerOptions["transport"];
timestamp?: LoggerOptions["timestamp"];
};
name: string;
pagination?: {
Expand Down
18 changes: 9 additions & 9 deletions packages/firebase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dzangolab/fastify-firebase",
"version": "0.62.2",
"version": "0.64.0",
"description": "Fastify firebase plugin",
"homepage": "https://github.com/dzangolab/fastify/tree/main/packages/firebase#readme",
"repository": {
Expand Down Expand Up @@ -35,30 +35,30 @@
"zod": "3.22.4"
},
"devDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-mercurius": "0.62.2",
"@dzangolab/fastify-slonik": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@dzangolab/fastify-mercurius": "0.64.0",
"@dzangolab/fastify-slonik": "0.64.0",
"@types/node": "18.16.18",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@vitest/coverage-istanbul": "0.32.2",
"eslint": "8.56.0",
"eslint-config-custom": "0.62.2",
"eslint-config-custom": "0.64.0",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"mercurius": "12.2.0",
"prettier": "2.8.8",
"slonik": "37.2.0",
"supertokens-node": "15.0.4",
"tsconfig": "0.62.2",
"tsconfig": "0.64.0",
"typescript": "4.9.5",
"vite": "4.3.9",
"vitest": "0.32.0"
},
"peerDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-mercurius": "0.62.2",
"@dzangolab/fastify-slonik": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@dzangolab/fastify-mercurius": "0.64.0",
"@dzangolab/fastify-slonik": "0.64.0",
"fastify": ">=4.10.2",
"fastify-plugin": ">=4.4.0",
"firebase-admin": "12.0.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/mailer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dzangolab/fastify-mailer",
"version": "0.62.2",
"version": "0.64.0",
"description": "Fastify mailer plugin",
"homepage": "https://github.com/dzangolab/fastify/tree/main/packages/mailer#readme",
"repository": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"nodemailer-mjml": "1.2.24"
},
"devDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@types/mjml": "4.7.4",
"@types/node": "18.16.18",
"@types/nodemailer": "6.4.14",
Expand All @@ -48,18 +48,18 @@
"@typescript-eslint/parser": "5.62.0",
"@vitest/coverage-istanbul": "0.32.2",
"eslint": "8.56.0",
"eslint-config-custom": "0.62.2",
"eslint-config-custom": "0.64.0",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"mjml": "4.14.1",
"prettier": "2.8.8",
"tsconfig": "0.62.2",
"tsconfig": "0.64.0",
"typescript": "4.9.5",
"vite": "4.3.9",
"vitest": "0.32.2"
},
"peerDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"fastify": ">=4.9.2",
"fastify-plugin": ">=4.3.0",
"mjml": ">=4.13.0"
Expand Down
14 changes: 7 additions & 7 deletions packages/mercurius/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dzangolab/fastify-mercurius",
"version": "0.62.2",
"version": "0.64.0",
"description": "Fastify mercurius plugin",
"homepage": "https://github.com/dzangolab/fastify/tree/main/packages/mercurius#readme",
"repository": {
Expand Down Expand Up @@ -31,28 +31,28 @@
"typecheck": "tsc --noEmit -p tsconfig.json --composite false"
},
"devDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-slonik": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@dzangolab/fastify-slonik": "0.64.0",
"@types/node": "18.16.18",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@vitest/coverage-istanbul": "0.32.2",
"eslint": "8.56.0",
"eslint-config-custom": "0.62.2",
"eslint-config-custom": "0.64.0",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"graphql": "16.6.0",
"mercurius": "12.2.0",
"prettier": "2.8.8",
"slonik": "37.2.0",
"tsconfig": "0.62.2",
"tsconfig": "0.64.0",
"typescript": "4.9.5",
"vite": "4.3.9",
"vitest": "0.32.2"
},
"peerDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-slonik": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@dzangolab/fastify-slonik": "0.64.0",
"fastify": ">=4.9.2",
"fastify-plugin": ">=4.3.0",
"graphql": ">=16.6.0",
Expand Down
22 changes: 11 additions & 11 deletions packages/multi-tenant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dzangolab/fastify-multi-tenant",
"version": "0.62.2",
"version": "0.64.0",
"description": "Fastify multi-tenant plugin",
"homepage": "https://github.com/dzangolab/fastify/tree/main/packages/multi-tenant#readme",
"repository": {
Expand Down Expand Up @@ -37,10 +37,10 @@
"pg": "8.11.3"
},
"devDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-mercurius": "0.62.2",
"@dzangolab/fastify-slonik": "0.62.2",
"@dzangolab/fastify-user": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@dzangolab/fastify-mercurius": "0.64.0",
"@dzangolab/fastify-slonik": "0.64.0",
"@dzangolab/fastify-user": "0.64.0",
"@types/humps": "2.0.6",
"@types/lodash.merge": "4.6.9",
"@types/node": "18.16.18",
Expand All @@ -49,25 +49,25 @@
"@typescript-eslint/parser": "5.62.0",
"@vitest/coverage-istanbul": "0.32.2",
"eslint": "8.56.0",
"eslint-config-custom": "0.62.2",
"eslint-config-custom": "0.64.0",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"mercurius": "12.2.0",
"prettier": "2.8.8",
"slonik": "37.2.0",
"supertokens-node": "15.0.4",
"tsconfig": "0.62.2",
"tsconfig": "0.64.0",
"typescript": "4.9.5",
"vite": "4.3.9",
"vite-tsconfig-paths": "4.2.3",
"vitest": "0.32.2",
"zod": "3.22.4"
},
"peerDependencies": {
"@dzangolab/fastify-config": "0.62.2",
"@dzangolab/fastify-mercurius": "0.62.2",
"@dzangolab/fastify-slonik": "0.62.2",
"@dzangolab/fastify-user": "0.62.2",
"@dzangolab/fastify-config": "0.64.0",
"@dzangolab/fastify-mercurius": "0.64.0",
"@dzangolab/fastify-slonik": "0.64.0",
"@dzangolab/fastify-user": "0.64.0",
"fastify": ">=4.9.2",
"fastify-plugin": ">=4.3.0",
"mercurius": ">=12.2.0",
Expand Down
20 changes: 16 additions & 4 deletions packages/multi-tenant/src/lib/validateTenantSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ const validateTenantInput = (
const validationResult = tenantInputSchema.safeParse(mappedTenantInput);

if (!validationResult.success) {
if (
validationResult.error.issues.some((issue) => {
return issue.path.includes("slug");
})
) {
throw {
name: "ERROR_INVALID_SLUG",
message: "Invalid slug",
statusCode: 422,
};
}

throw {
message: validationResult.error.issues[0].message,
issues: validationResult.error.issues,
name: "ERROR_INVALID_DOMAIN",
message: "Invalid domain",
statusCode: 422,
};
}
Expand All @@ -59,8 +71,8 @@ const validateTenantUpdate = (

if (!validationResult.success) {
throw {
message: validationResult.error.issues[0].message,
issues: validationResult.error.issues,
name: "ERROR_INVALID_DOMAIN",
message: "Invalid domain",
statusCode: 422,
};
}
Expand Down
16 changes: 12 additions & 4 deletions packages/multi-tenant/src/model/tenants/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TenantService<

if (getAllReservedSlugs(this.config).includes(data[slugColumn] as string)) {
throw {
name: "CREATE_TENANT_FAILED",
name: "ERROR_RESERVED_SLUG",
message: `The requested ${slugColumn} "${data[slugColumn]}" is reserved and cannot be used`,
statusCode: 422,
};
Expand All @@ -58,7 +58,7 @@ class TenantService<
getAllReservedDomains(this.config).includes(data[domainColumn] as string)
) {
throw {
name: "CREATE_TENANT_FAILED",
name: "ERROR_RESERVED_DOMAIN",
message: `The requested ${domainColumn} "${data[domainColumn]}" is reserved and cannot be used`,
statusCode: 422,
};
Expand Down Expand Up @@ -106,9 +106,17 @@ class TenantService<
const { slug: slugColumn, domain: domainColumn } =
multiTenantConfig.table.columns;

if (tenants.some((tenant) => tenant[slugColumn] === slug)) {
throw {
name: "ERROR_SLUG_ALREADY_EXISTS",
message: `The specified ${slugColumn} "${slug}" already exits`,
statusCode: 422,
};
}

throw {
name: "FIELD_VALIDATION_FAILED",
message: `The specified ${slugColumn} "${slug}" or ${domainColumn} "${domain}" already exits`,
name: "ERROR_DOMAIN_ALREADY_EXISTS",
message: `The specified ${domainColumn} "${domain}" already exits`,
statusCode: 422,
};
}
Expand Down
Loading

0 comments on commit ee0ec65

Please sign in to comment.