Fix linting errors
This commit is contained in:
@@ -49,7 +49,7 @@ export class Actions {
|
||||
@Post('track')
|
||||
@Middleware([requirePublicKey])
|
||||
@CatchAsync
|
||||
public async track(req: Request, res: Response, next: NextFunction) {
|
||||
public async track(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
// Zod validation - errors automatically handled by global error handler
|
||||
@@ -155,7 +155,7 @@ export class Actions {
|
||||
@Post('send')
|
||||
@Middleware([requireSecretKey])
|
||||
@CatchAsync
|
||||
public async send(req: Request, res: Response, next: NextFunction) {
|
||||
public async send(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
// Zod validation - errors automatically handled by global error handler
|
||||
@@ -244,12 +244,7 @@ export class Actions {
|
||||
: (data as Record<string, unknown> | undefined);
|
||||
|
||||
// Create or update contact with metadata
|
||||
const contact = await ContactService.upsert(
|
||||
auth.projectId,
|
||||
recipient.email,
|
||||
recipientData,
|
||||
subscribed,
|
||||
);
|
||||
const contact = await ContactService.upsert(auth.projectId, recipient.email, recipientData, subscribed);
|
||||
|
||||
// Get merged data including non-persistent fields for template rendering
|
||||
const mergedData = ContactService.getMergedData(contact, data as Record<string, unknown> | undefined);
|
||||
|
||||
@@ -23,7 +23,7 @@ export class Activity {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getActivities(req: Request, res: Response, next: NextFunction) {
|
||||
public async getActivities(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const limit = Math.min(parseInt(req.query.limit as string) || 50, 100);
|
||||
const cursor = req.query.cursor as string | undefined;
|
||||
@@ -64,7 +64,7 @@ export class Activity {
|
||||
@Get('stats')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getStats(req: Request, res: Response, next: NextFunction) {
|
||||
public async getStats(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const startDate = req.query.startDate ? new Date(req.query.startDate as string) : undefined;
|
||||
const endDate = req.query.endDate ? new Date(req.query.endDate as string) : undefined;
|
||||
@@ -84,7 +84,7 @@ export class Activity {
|
||||
@Get('recent-count')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getRecentCount(req: Request, res: Response, next: NextFunction) {
|
||||
public async getRecentCount(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const minutes = Math.min(parseInt(req.query.minutes as string) || 5, 60); // Max 60 minutes
|
||||
|
||||
@@ -100,7 +100,7 @@ export class Activity {
|
||||
@Get('types')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getTypes(_req: Request, res: Response, next: NextFunction) {
|
||||
public async getTypes(_req: Request, res: Response, _next: NextFunction) {
|
||||
const types = Object.values(ActivityType);
|
||||
return res.status(200).json({types});
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export class Activity {
|
||||
@Get('upcoming')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getUpcoming(req: Request, res: Response, next: NextFunction) {
|
||||
public async getUpcoming(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const limit = Math.min(parseInt(req.query.limit as string) || 50, 100);
|
||||
const daysAhead = Math.min(parseInt(req.query.daysAhead as string) || 30, 90);
|
||||
|
||||
@@ -15,7 +15,7 @@ import {CatchAsync} from '../utils/asyncHandler.js';
|
||||
export class Auth {
|
||||
@Post('login')
|
||||
@CatchAsync
|
||||
public async login(req: Request, res: Response, next: NextFunction) {
|
||||
public async login(req: Request, res: Response, _next: NextFunction) {
|
||||
const {email, password} = AuthenticationSchemas.login.parse(req.body);
|
||||
|
||||
const user = await UserService.email(email);
|
||||
@@ -46,7 +46,7 @@ export class Auth {
|
||||
|
||||
@Post('signup')
|
||||
@CatchAsync
|
||||
public async signup(req: Request, res: Response, next: NextFunction) {
|
||||
public async signup(req: Request, res: Response, _next: NextFunction) {
|
||||
const {email, password} = AuthenticationSchemas.login.parse(req.body);
|
||||
|
||||
const user = await UserService.email(email);
|
||||
|
||||
@@ -19,7 +19,7 @@ export class Campaigns {
|
||||
@Post('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async create(req: Request, res: Response, next: NextFunction) {
|
||||
private async create(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {name, description, subject, body, from, fromName, replyTo, audienceType, audienceCondition, segmentId} =
|
||||
CampaignSchemas.create.parse(req.body);
|
||||
@@ -62,7 +62,7 @@ export class Campaigns {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async list(req: Request, res: Response, next: NextFunction) {
|
||||
private async list(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const status = req.query.status as CampaignStatus | undefined;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
@@ -95,7 +95,7 @@ export class Campaigns {
|
||||
@Get(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async get(req: Request, res: Response, next: NextFunction) {
|
||||
private async get(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -114,7 +114,7 @@ export class Campaigns {
|
||||
@Put(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async update(req: Request, res: Response, next: NextFunction) {
|
||||
private async update(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
const {name, description, subject, body, from, fromName, replyTo, audienceType, audienceCondition, segmentId} =
|
||||
@@ -160,7 +160,7 @@ export class Campaigns {
|
||||
@Delete(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async delete(req: Request, res: Response, next: NextFunction) {
|
||||
private async delete(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -179,7 +179,7 @@ export class Campaigns {
|
||||
@Post(':id/duplicate')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async duplicate(req: Request, res: Response, next: NextFunction) {
|
||||
private async duplicate(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -199,7 +199,7 @@ export class Campaigns {
|
||||
@Post(':id/send')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async send(req: Request, res: Response, next: NextFunction) {
|
||||
private async send(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
const scheduledFor = req.body?.scheduledFor;
|
||||
@@ -230,7 +230,7 @@ export class Campaigns {
|
||||
@Post(':id/cancel')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async cancel(req: Request, res: Response, next: NextFunction) {
|
||||
private async cancel(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -250,7 +250,7 @@ export class Campaigns {
|
||||
@Get(':id/stats')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async stats(req: Request, res: Response, next: NextFunction) {
|
||||
private async stats(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -269,7 +269,7 @@ export class Campaigns {
|
||||
@Post(':id/test')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async sendTest(req: Request, res: Response, next: NextFunction) {
|
||||
private async sendTest(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
const {email} = CampaignSchemas.sendTest.parse(req.body);
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Contacts {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async list(req: Request, res: Response, next: NextFunction) {
|
||||
public async list(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const limit = Math.min(parseInt(req.query.limit as string) || 20, 100);
|
||||
const cursor = req.query.cursor as string | undefined;
|
||||
@@ -52,7 +52,7 @@ export class Contacts {
|
||||
@Get('fields')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getAvailableFields(req: Request, res: Response, next: NextFunction) {
|
||||
public async getAvailableFields(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
try {
|
||||
@@ -78,7 +78,7 @@ export class Contacts {
|
||||
@Get('fields/:field/values')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getFieldValues(req: Request, res: Response, next: NextFunction) {
|
||||
public async getFieldValues(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const field = req.params.field;
|
||||
const limit = Math.min(parseInt(req.query.limit as string) || 100, 200);
|
||||
@@ -111,7 +111,7 @@ export class Contacts {
|
||||
@Get(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async get(req: Request, res: Response, next: NextFunction) {
|
||||
public async get(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const contactId = req.params.id;
|
||||
|
||||
@@ -131,7 +131,7 @@ export class Contacts {
|
||||
@Post('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async create(req: Request, res: Response, next: NextFunction) {
|
||||
public async create(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {email, data, subscribed} = req.body;
|
||||
|
||||
@@ -161,7 +161,7 @@ export class Contacts {
|
||||
@Patch(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async update(req: Request, res: Response, next: NextFunction) {
|
||||
public async update(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const contactId = req.params.id;
|
||||
const {email, data, subscribed} = req.body;
|
||||
@@ -182,7 +182,7 @@ export class Contacts {
|
||||
@Delete(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async delete(req: Request, res: Response, next: NextFunction) {
|
||||
public async delete(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const contactId = req.params.id;
|
||||
|
||||
@@ -201,7 +201,7 @@ export class Contacts {
|
||||
*/
|
||||
@Get('public/:id')
|
||||
@CatchAsync
|
||||
public async getPublic(req: Request, res: Response, next: NextFunction) {
|
||||
public async getPublic(req: Request, res: Response, _next: NextFunction) {
|
||||
const contactId = req.params.id;
|
||||
|
||||
if (!contactId) {
|
||||
@@ -223,7 +223,7 @@ export class Contacts {
|
||||
*/
|
||||
@Post('public/:id/subscribe')
|
||||
@CatchAsync
|
||||
public async subscribePublic(req: Request, res: Response, next: NextFunction) {
|
||||
public async subscribePublic(req: Request, res: Response, _next: NextFunction) {
|
||||
const contactId = req.params.id;
|
||||
|
||||
if (!contactId) {
|
||||
@@ -245,7 +245,7 @@ export class Contacts {
|
||||
*/
|
||||
@Post('public/:id/unsubscribe')
|
||||
@CatchAsync
|
||||
public async unsubscribePublic(req: Request, res: Response, next: NextFunction) {
|
||||
public async unsubscribePublic(req: Request, res: Response, _next: NextFunction) {
|
||||
const contactId = req.params.id;
|
||||
|
||||
if (!contactId) {
|
||||
@@ -268,7 +268,7 @@ export class Contacts {
|
||||
@Post('import')
|
||||
@Middleware([requireAuth, upload.single('file')])
|
||||
@CatchAsync
|
||||
public async importCsv(req: Request, res: Response, next: NextFunction) {
|
||||
public async importCsv(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
if (!req.file) {
|
||||
@@ -302,7 +302,7 @@ export class Contacts {
|
||||
@Get('import/:jobId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getImportStatus(req: Request, res: Response, next: NextFunction) {
|
||||
public async getImportStatus(req: Request, res: Response, _next: NextFunction) {
|
||||
const jobId = req.params.jobId;
|
||||
|
||||
if (!jobId) {
|
||||
@@ -333,7 +333,7 @@ export class Contacts {
|
||||
@Get('fields/:field/usage')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getFieldUsage(req: Request, res: Response, next: NextFunction) {
|
||||
public async getFieldUsage(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const field = req.params.field;
|
||||
|
||||
@@ -360,7 +360,7 @@ export class Contacts {
|
||||
@Delete('fields/:field')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async deleteField(req: Request, res: Response, next: NextFunction) {
|
||||
public async deleteField(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const field = req.params.field;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class Domains {
|
||||
@Get('project/:projectId')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async getProjectDomains(req: Request, res: Response, next: NextFunction) {
|
||||
public async getProjectDomains(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {projectId} = DomainSchemas.projectId.parse(req.params);
|
||||
|
||||
@@ -46,7 +46,7 @@ export class Domains {
|
||||
@Post('')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async addDomain(req: Request, res: Response, next: NextFunction) {
|
||||
public async addDomain(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {projectId, domain} = DomainSchemas.create.parse(req.body);
|
||||
|
||||
@@ -106,7 +106,7 @@ export class Domains {
|
||||
@Get(':id/verify')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async checkVerification(req: Request, res: Response, next: NextFunction) {
|
||||
public async checkVerification(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = UtilitySchemas.id.parse(req.params);
|
||||
|
||||
@@ -143,7 +143,7 @@ export class Domains {
|
||||
@Delete(':id')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async removeDomain(req: Request, res: Response, next: NextFunction) {
|
||||
public async removeDomain(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = UtilitySchemas.id.parse(req.params);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export class Events {
|
||||
@Post('track')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async track(req: Request, res: Response, next: NextFunction) {
|
||||
public async track(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {name, contactId, emailId, data} = req.body;
|
||||
|
||||
@@ -35,7 +35,7 @@ export class Events {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async list(req: Request, res: Response, next: NextFunction) {
|
||||
public async list(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const eventName = req.query.eventName as string | undefined;
|
||||
const limit = parseInt(req.query.limit as string) || 100;
|
||||
@@ -52,7 +52,7 @@ export class Events {
|
||||
@Get('stats')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async stats(req: Request, res: Response, next: NextFunction) {
|
||||
public async stats(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const startDate = req.query.startDate ? new Date(req.query.startDate as string) : undefined;
|
||||
const endDate = req.query.endDate ? new Date(req.query.endDate as string) : undefined;
|
||||
@@ -69,7 +69,7 @@ export class Events {
|
||||
@Get('contact/:contactId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getContactEvents(req: Request, res: Response, next: NextFunction) {
|
||||
public async getContactEvents(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const contactId = req.params.contactId;
|
||||
const limit = parseInt(req.query.limit as string) || 50;
|
||||
@@ -90,7 +90,7 @@ export class Events {
|
||||
@Get('names')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getEventNames(req: Request, res: Response, next: NextFunction) {
|
||||
public async getEventNames(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
const eventNames = await EventService.getUniqueEventNames(auth.projectId!);
|
||||
@@ -106,7 +106,7 @@ export class Events {
|
||||
@Get(':eventName/usage')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getEventUsage(req: Request, res: Response, next: NextFunction) {
|
||||
public async getEventUsage(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const eventName = req.params.eventName;
|
||||
|
||||
@@ -133,7 +133,7 @@ export class Events {
|
||||
@Delete(':eventName')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async deleteEvent(req: Request, res: Response, next: NextFunction) {
|
||||
public async deleteEvent(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const eventName = req.params.eventName;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Github {
|
||||
|
||||
@Get('callback')
|
||||
@CatchAsync
|
||||
public async callback(req: Request, res: Response, next: NextFunction) {
|
||||
public async callback(req: Request, res: Response, _next: NextFunction) {
|
||||
if (!GITHUB_OAUTH_ENABLED) {
|
||||
return res.status(404).json({error: 'GitHub OAuth is not configured'});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class Google {
|
||||
|
||||
@Get('callback')
|
||||
@CatchAsync
|
||||
public async callback(req: Request, res: Response, next: NextFunction) {
|
||||
public async callback(req: Request, res: Response, _next: NextFunction) {
|
||||
if (!GOOGLE_OAUTH_ENABLED) {
|
||||
return res.status(404).json({error: 'Google OAuth is not configured'});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class Projects {
|
||||
@Get(':id/setup-state')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async getSetupState(req: Request, res: Response, next: NextFunction) {
|
||||
private async getSetupState(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -89,7 +89,7 @@ export class Projects {
|
||||
@Get(':id/members')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
private async getMembers(req: Request, res: Response, next: NextFunction) {
|
||||
private async getMembers(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export class Segments {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async list(req: Request, res: Response, next: NextFunction) {
|
||||
public async list(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
const segments = await SegmentService.list(auth.projectId!);
|
||||
@@ -30,7 +30,7 @@ export class Segments {
|
||||
@Get(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async get(req: Request, res: Response, next: NextFunction) {
|
||||
public async get(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const segmentId = req.params.id;
|
||||
|
||||
@@ -50,7 +50,7 @@ export class Segments {
|
||||
@Get(':id/contacts')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getContacts(req: Request, res: Response, next: NextFunction) {
|
||||
public async getContacts(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const segmentId = req.params.id;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
@@ -72,7 +72,7 @@ export class Segments {
|
||||
@Post('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async create(req: Request, res: Response, next: NextFunction) {
|
||||
public async create(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {name, description, condition, trackMembership} = req.body;
|
||||
|
||||
@@ -101,7 +101,7 @@ export class Segments {
|
||||
@Patch(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async update(req: Request, res: Response, next: NextFunction) {
|
||||
public async update(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const segmentId = req.params.id;
|
||||
const {name, description, condition, trackMembership} = req.body;
|
||||
@@ -131,7 +131,7 @@ export class Segments {
|
||||
@Delete(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async delete(req: Request, res: Response, next: NextFunction) {
|
||||
public async delete(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const segmentId = req.params.id;
|
||||
|
||||
@@ -151,7 +151,7 @@ export class Segments {
|
||||
@Post(':id/compute')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async compute(req: Request, res: Response, next: NextFunction) {
|
||||
public async compute(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const segmentId = req.params.id;
|
||||
|
||||
@@ -171,7 +171,7 @@ export class Segments {
|
||||
@Post(':id/refresh')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async refresh(req: Request, res: Response, next: NextFunction) {
|
||||
public async refresh(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const segmentId = req.params.id;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export class Templates {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async list(req: Request, res: Response, next: NextFunction) {
|
||||
public async list(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
const pageSize = Math.min(parseInt(req.query.pageSize as string) || 20, 100);
|
||||
@@ -36,7 +36,7 @@ export class Templates {
|
||||
@Get(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async get(req: Request, res: Response, next: NextFunction) {
|
||||
public async get(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const templateId = req.params.id;
|
||||
|
||||
@@ -56,7 +56,7 @@ export class Templates {
|
||||
@Post('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async create(req: Request, res: Response, next: NextFunction) {
|
||||
public async create(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {name, description, subject, body, from, fromName, replyTo, type} = req.body;
|
||||
|
||||
@@ -100,7 +100,7 @@ export class Templates {
|
||||
@Patch(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async update(req: Request, res: Response, next: NextFunction) {
|
||||
public async update(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const templateId = req.params.id;
|
||||
const {name, description, subject, body, from, fromName, replyTo, type} = req.body;
|
||||
@@ -135,7 +135,7 @@ export class Templates {
|
||||
@Delete(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async delete(req: Request, res: Response, next: NextFunction) {
|
||||
public async delete(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const templateId = req.params.id;
|
||||
|
||||
@@ -155,7 +155,7 @@ export class Templates {
|
||||
@Post(':id/duplicate')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async duplicate(req: Request, res: Response, next: NextFunction) {
|
||||
public async duplicate(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const templateId = req.params.id;
|
||||
|
||||
@@ -175,7 +175,7 @@ export class Templates {
|
||||
@Get(':id/usage')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getUsage(req: Request, res: Response, next: NextFunction) {
|
||||
public async getUsage(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const templateId = req.params.id;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export class Uploads {
|
||||
@Post('image')
|
||||
@Middleware([requireAuth, upload.single('image')])
|
||||
@CatchAsync
|
||||
public async uploadImage(req: Request, res: Response, next: NextFunction) {
|
||||
public async uploadImage(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
try {
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Users {
|
||||
@Get('@me')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async me(req: Request, res: Response, next: NextFunction) {
|
||||
public async me(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
if (!auth.userId) {
|
||||
@@ -39,7 +39,7 @@ export class Users {
|
||||
@Get('@me/projects')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async meProjects(req: Request, res: Response, next: NextFunction) {
|
||||
public async meProjects(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
if (!auth.userId) {
|
||||
@@ -54,7 +54,7 @@ export class Users {
|
||||
@Post('@me/projects')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async createProject(req: Request, res: Response, next: NextFunction) {
|
||||
public async createProject(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
|
||||
if (!auth.userId) {
|
||||
@@ -88,7 +88,7 @@ export class Users {
|
||||
@Patch('@me/projects/:id')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async updateProject(req: Request, res: Response, next: NextFunction) {
|
||||
public async updateProject(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
const data = ProjectSchemas.update.parse(req.body);
|
||||
@@ -120,7 +120,7 @@ export class Users {
|
||||
@Post('@me/projects/:id/regenerate-keys')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async regenerateProjectKeys(req: Request, res: Response, next: NextFunction) {
|
||||
public async regenerateProjectKeys(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -158,7 +158,7 @@ export class Users {
|
||||
@Post('@me/projects/:id/checkout')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async createCheckoutSession(req: Request, res: Response, next: NextFunction) {
|
||||
public async createCheckoutSession(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -237,7 +237,7 @@ export class Users {
|
||||
@Post('@me/projects/:id/billing-portal')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async createBillingPortalSession(req: Request, res: Response, next: NextFunction) {
|
||||
public async createBillingPortalSession(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -287,7 +287,7 @@ export class Users {
|
||||
@Get('@me/projects/:id/billing-limits')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async getBillingLimits(req: Request, res: Response, next: NextFunction) {
|
||||
public async getBillingLimits(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -320,7 +320,7 @@ export class Users {
|
||||
@Put('@me/projects/:id/billing-limits')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async updateBillingLimits(req: Request, res: Response, next: NextFunction) {
|
||||
public async updateBillingLimits(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -387,7 +387,7 @@ export class Users {
|
||||
@Get('@me/projects/:id/billing-consumption')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async getBillingConsumption(req: Request, res: Response, next: NextFunction) {
|
||||
public async getBillingConsumption(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -487,7 +487,7 @@ export class Users {
|
||||
@Get('@me/projects/:id/billing-invoices')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async getBillingInvoices(req: Request, res: Response, next: NextFunction) {
|
||||
public async getBillingInvoices(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -575,7 +575,7 @@ export class Users {
|
||||
@Get('@me/projects/:id/security')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async getSecurityHealth(req: Request, res: Response, next: NextFunction) {
|
||||
public async getSecurityHealth(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -608,7 +608,7 @@ export class Users {
|
||||
@Post('@me/projects/:id/reset')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async resetProject(req: Request, res: Response, next: NextFunction) {
|
||||
public async resetProject(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
@@ -684,7 +684,7 @@ export class Users {
|
||||
@Delete('@me/projects/:id')
|
||||
@Middleware([isAuthenticated])
|
||||
@CatchAsync
|
||||
public async deleteProject(req: Request, res: Response, next: NextFunction) {
|
||||
public async deleteProject(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {id} = req.params;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Controller, Post} from '@overnightjs/core';
|
||||
import type {Prisma} from '@plunk/db';
|
||||
import {EmailStatus} from '@plunk/db';
|
||||
import type {NextFunction, Request, Response} from 'express';
|
||||
import type {Request, Response} from 'express';
|
||||
import signale from 'signale';
|
||||
import type Stripe from 'stripe';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export class Workflows {
|
||||
@Get('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async list(req: Request, res: Response, next: NextFunction) {
|
||||
public async list(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
const pageSize = Math.min(parseInt(req.query.pageSize as string) || 20, 100);
|
||||
@@ -36,7 +36,7 @@ export class Workflows {
|
||||
@Get('fields')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getAvailableFields(req: Request, res: Response, next: NextFunction) {
|
||||
public async getAvailableFields(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const eventName = req.query.eventName as string | undefined;
|
||||
|
||||
@@ -59,7 +59,7 @@ export class Workflows {
|
||||
@Get(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async get(req: Request, res: Response, next: NextFunction) {
|
||||
public async get(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
|
||||
@@ -79,7 +79,7 @@ export class Workflows {
|
||||
@Post('')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async create(req: Request, res: Response, next: NextFunction) {
|
||||
public async create(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const {name, description, eventName, enabled, allowReentry} = req.body;
|
||||
|
||||
@@ -109,7 +109,7 @@ export class Workflows {
|
||||
@Patch(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async update(req: Request, res: Response, next: NextFunction) {
|
||||
public async update(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const {name, description, triggerType, triggerConfig, enabled, allowReentry} = req.body;
|
||||
@@ -137,7 +137,7 @@ export class Workflows {
|
||||
@Delete(':id')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async delete(req: Request, res: Response, next: NextFunction) {
|
||||
public async delete(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
|
||||
@@ -157,7 +157,7 @@ export class Workflows {
|
||||
@Post(':id/steps')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async addStep(req: Request, res: Response, next: NextFunction) {
|
||||
public async addStep(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const {type, name, position, config, templateId, autoConnect} = req.body;
|
||||
@@ -189,7 +189,7 @@ export class Workflows {
|
||||
@Patch(':id/steps/:stepId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async updateStep(req: Request, res: Response, next: NextFunction) {
|
||||
public async updateStep(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const stepId = req.params.stepId;
|
||||
@@ -216,7 +216,7 @@ export class Workflows {
|
||||
@Delete(':id/steps/:stepId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async deleteStep(req: Request, res: Response, next: NextFunction) {
|
||||
public async deleteStep(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const stepId = req.params.stepId;
|
||||
@@ -237,7 +237,7 @@ export class Workflows {
|
||||
@Post(':id/transitions')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async createTransition(req: Request, res: Response, next: NextFunction) {
|
||||
public async createTransition(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const {fromStepId, toStepId, condition, priority} = req.body;
|
||||
@@ -267,7 +267,7 @@ export class Workflows {
|
||||
@Delete(':id/transitions/:transitionId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async deleteTransition(req: Request, res: Response, next: NextFunction) {
|
||||
public async deleteTransition(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const transitionId = req.params.transitionId;
|
||||
@@ -288,7 +288,7 @@ export class Workflows {
|
||||
@Post(':id/executions')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async startExecution(req: Request, res: Response, next: NextFunction) {
|
||||
public async startExecution(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const {contactId, context} = req.body;
|
||||
@@ -313,7 +313,7 @@ export class Workflows {
|
||||
@Get(':id/executions')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async listExecutions(req: Request, res: Response, next: NextFunction) {
|
||||
public async listExecutions(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
@@ -336,7 +336,7 @@ export class Workflows {
|
||||
@Get(':id/executions/:executionId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async getExecution(req: Request, res: Response, next: NextFunction) {
|
||||
public async getExecution(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const executionId = req.params.executionId;
|
||||
@@ -357,7 +357,7 @@ export class Workflows {
|
||||
@Delete(':id/executions/:executionId')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async cancelExecution(req: Request, res: Response, next: NextFunction) {
|
||||
public async cancelExecution(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
const executionId = req.params.executionId;
|
||||
@@ -378,7 +378,7 @@ export class Workflows {
|
||||
@Post(':id/executions/cancel-all')
|
||||
@Middleware([requireAuth])
|
||||
@CatchAsync
|
||||
public async cancelAllExecutions(req: Request, res: Response, next: NextFunction) {
|
||||
public async cancelAllExecutions(req: Request, res: Response, _next: NextFunction) {
|
||||
const auth = res.locals.auth as AuthResponse;
|
||||
const workflowId = req.params.id;
|
||||
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import {beforeEach, describe, expect, it} from 'vitest';
|
||||
import {factories, getPrismaClient} from '../../../../../test/helpers';
|
||||
import {factories} from '../../../../../test/helpers';
|
||||
import {EventService} from '../../services/EventService';
|
||||
import {WorkflowService} from '../../services/WorkflowService';
|
||||
|
||||
describe('Workflows Controller', () => {
|
||||
let projectId: string;
|
||||
let userId: string;
|
||||
const prisma = getPrismaClient();
|
||||
|
||||
beforeEach(async () => {
|
||||
const {project, user} = await factories.createUserWithProject();
|
||||
const {project} = await factories.createUserWithProject();
|
||||
projectId = project.id;
|
||||
userId = user.id;
|
||||
});
|
||||
|
||||
// ========================================
|
||||
|
||||
Reference in New Issue
Block a user