Rifki Salim
Rifki Salim
Explore posts from servers
DTDrizzle Team
Created by Rifki Salim on 1/10/2024 in #help
Ensure Drizzle findMany conforms to Typebox schema
Hi All, I am running into an issue when using drizzle with an elysia app. I have the following typebox schema which uses drizzle-typebox to generate types for typebox
import { t } from "elysia";
...
import { createSelectSchema } from "drizzle-typebox";

export const companiesSchema = createSelectSchema(companies);

const getCompaniesSchema = {
query: t.Object({
page: t.Optional(t.Numeric()),
limit: t.Optional(t.Numeric()),
}),
response: t.Object({
200: t.Object({
data: t.Array(companiesSchema),
pagination: t.Object({
page: t.Number(),
limit: t.Number(),
total_count: t.Number(),
}),
}),
}),
};

export { getCompaniesSchema };
import { t } from "elysia";
...
import { createSelectSchema } from "drizzle-typebox";

export const companiesSchema = createSelectSchema(companies);

const getCompaniesSchema = {
query: t.Object({
page: t.Optional(t.Numeric()),
limit: t.Optional(t.Numeric()),
}),
response: t.Object({
200: t.Object({
data: t.Array(companiesSchema),
pagination: t.Object({
page: t.Number(),
limit: t.Number(),
total_count: t.Number(),
}),
}),
}),
};

export { getCompaniesSchema };
in the file where i define the route handler for the Elysia app, the getCompanies function is highlighted saying that the response object does not match the schema provided in the interface.
import { Handler } from "elysia";


import {
companiesSchema,
getCompaniesSchema,
} from "../routes/schema/companies-schema";

// Services
import {
getPaginatedCompanies,
getAllCompanies,
} from "../services/companies-service";

interface ICompaniesHandler {
getCompanies: Handler<typeof getCompaniesSchema>;
addCompany: Handler;
}

const companiesHandler: ICompaniesHandler = {
getCompanies: async ({ query, set }) => {
// Extract Page and Limit
const { page = 1, limit = 5 } = query;

// Init Offset
const offset = (page - 1) * limit;

// Get Companies and Count
const companies = await getPaginatedCompanies.execute({
limit,
offset,
});
const total_count = (await getAllCompanies.execute()).length;

set.status = 200;

const response = {
data: companies,
pagination: {
page,
limit,
total_count,
},
};

return response;
},
addCompany: async ({}) => {},
};

export default companiesHandler;
import { Handler } from "elysia";


import {
companiesSchema,
getCompaniesSchema,
} from "../routes/schema/companies-schema";

// Services
import {
getPaginatedCompanies,
getAllCompanies,
} from "../services/companies-service";

interface ICompaniesHandler {
getCompanies: Handler<typeof getCompaniesSchema>;
addCompany: Handler;
}

const companiesHandler: ICompaniesHandler = {
getCompanies: async ({ query, set }) => {
// Extract Page and Limit
const { page = 1, limit = 5 } = query;

// Init Offset
const offset = (page - 1) * limit;

// Get Companies and Count
const companies = await getPaginatedCompanies.execute({
limit,
offset,
});
const total_count = (await getAllCompanies.execute()).length;

set.status = 200;

const response = {
data: companies,
pagination: {
page,
limit,
total_count,
},
};

return response;
},
addCompany: async ({}) => {},
};

export default companiesHandler;
any idea on how to fix this? thanks in advance!
1 replies
NNovu
Created by Rifki Salim on 8/11/2023 in #💬│support
AxiosError and Notifications not being sent
We are accessing the Novu API (Novu Web/Hosted Version) using the @Novu/node package and recently when we try to send bulk notifications we get this error:
AxiosError: Request failed with status code 400

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at settle (/app/node_modules/@novu/node/node_modules/axios/lib/core/settle.js:19:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.handleStreamEnd (/app/node_modules/@novu/node/node_modules/axios/lib/adapters/http.js:497:11)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.emit (node:events:525:35)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at endReadableNT (node:internal/streams/readable:1358:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at processTicksAndRejections (node:internal/process/task_queues:83:21)
AxiosError: Request failed with status code 400

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at settle (/app/node_modules/@novu/node/node_modules/axios/lib/core/settle.js:19:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.handleStreamEnd (/app/node_modules/@novu/node/node_modules/axios/lib/adapters/http.js:497:11)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.emit (node:events:525:35)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at endReadableNT (node:internal/streams/readable:1358:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at processTicksAndRejections (node:internal/process/task_queues:83:21)
Normal triggered notifications aren't showing up on the activity feed either. Bulk Trigger code
let eventsList: IBulkEvents[] = [];

users.map((value, index) => {
eventsList.push({
name: "announcement-new-season",
to: {
subscriberId: value.id,
email: value.email,
},
payload: {
user_name: value.displayName,
season_number: season.number,
season_game: season.game,
},
});
});
await novu.bulkTrigger(eventsList);
const data = { seasonId: season.id };
let eventsList: IBulkEvents[] = [];

users.map((value, index) => {
eventsList.push({
name: "announcement-new-season",
to: {
subscriberId: value.id,
email: value.email,
},
payload: {
user_name: value.displayName,
season_number: season.number,
season_game: season.game,
},
});
});
await novu.bulkTrigger(eventsList);
const data = { seasonId: season.id };
I also noticed that our @Novu/node package version is 0.14.0. Is the cause of this error due to our package being out of date?
17 replies
NNovu
Created by Rifki Salim on 3/24/2023 in #💬│support
Self Hosted instance tries to connect to localhost instead of custom URL
Hi Team. I was able to successfully setup Novu using docker and the containers managed to start up with no issues. I have set up the env variables in the .env file successfully. However, when I try to connect to my self hosted instance and sign up, I get "Network Error" in the UI. Upon checking the console, I see that the POST request related to registering the user is being sent to http://localhost:3000/v1/auth/register instead of the custom URL which would obviously fail
xhr.js:247 POST http://localhost:3000/v1/auth/register net::ERR_CONNECTION_REFUSED
xhr.js:247 POST http://localhost:3000/v1/auth/register net::ERR_CONNECTION_REFUSED
I checked similar threads and tried to use ghcr.io/joeyeamigh/novu/web:nv-1803 as the web container, but I get the same issue. Additionally, I am using NGINX as a reverse proxy and I have set the context paths accordingly
14 replies
NNovu
Created by Rifki Salim on 2/23/2023 in #💬│support
Self Host Novu
Hi there! I recently came across Novu and I think it is a really cool way to manage notifcations across multiple channels. That being said, I would like to deploy Novu on a Virtual Private server via docker. However, the documentation on doing this seems to be a bit limited. I would like to use this deployment of Novu for production and use a custom domain for the Novu dashboard with SSL. Is there a recommended way to do this?
1 replies