Skip to content

Commit e553240

Browse files
committed
run knip to remove unused code
1 parent 437768d commit e553240

File tree

113 files changed

+482
-1731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+482
-1731
lines changed

packages/api/src/authz/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const canView = await authzService.canViewProject(userId, projectId);
7171
const canWrite = await authzService.canAccessProject(
7272
userId,
7373
projectId,
74-
"write"
74+
"write",
7575
);
7676

7777
// Get user context

packages/api/src/authz/service.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export class AuthorizationService {
6565
*/
6666
async getUserContext(
6767
userId: string,
68-
organizationId: string
68+
organizationId: string,
6969
): Promise<UserContext> {
7070
try {
7171
console.log(
72-
`Checking user context for userId: ${userId}, organizationId: ${organizationId}`
72+
`Checking user context for userId: ${userId}, organizationId: ${organizationId}`,
7373
);
7474

7575
// Get user's organization role
@@ -79,16 +79,16 @@ export class AuthorizationService {
7979
.where(
8080
and(
8181
eq(userOrganization.userId, userId),
82-
eq(userOrganization.organizationId, organizationId)
83-
)
82+
eq(userOrganization.organizationId, organizationId),
83+
),
8484
)
8585
.limit(1);
8686

8787
console.log(`User org result:`, userOrg);
8888

8989
if (!userOrg) {
9090
console.log(
91-
`User ${userId} not found in organization ${organizationId}`
91+
`User ${userId} not found in organization ${organizationId}`,
9292
);
9393
throw new ApiError("User not found in organization", 403);
9494
}
@@ -113,17 +113,17 @@ export class AuthorizationService {
113113
*/
114114
async getProjectContext(
115115
projectId: string,
116-
organizationId?: string
116+
organizationId?: string,
117117
): Promise<ProjectContext> {
118118
try {
119119
console.log(
120-
`[AUTHZ] Getting project context for projectId: ${projectId}, organizationId: ${organizationId}`
120+
`[AUTHZ] Getting project context for projectId: ${projectId}, organizationId: ${organizationId}`,
121121
);
122122

123123
const whereConditions = organizationId
124124
? and(
125125
eq(project.id, projectId),
126-
eq(project.organizationId, organizationId)
126+
eq(project.organizationId, organizationId),
127127
)
128128
: eq(project.id, projectId);
129129

@@ -142,12 +142,12 @@ export class AuthorizationService {
142142
name: projectData.name,
143143
visibility: projectData.visibility,
144144
}
145-
: "null"
145+
: "null",
146146
);
147147

148148
if (!projectData) {
149149
console.log(
150-
`[AUTHZ] Project not found for projectId: ${projectId}, organizationId: ${organizationId}`
150+
`[AUTHZ] Project not found for projectId: ${projectId}, organizationId: ${organizationId}`,
151151
);
152152
throw new ApiError("Project not found", 404);
153153
}
@@ -171,22 +171,22 @@ export class AuthorizationService {
171171
userId: string,
172172
projectId: string,
173173
action: Permission,
174-
organizationId?: string
174+
organizationId?: string,
175175
): Promise<boolean> {
176176
try {
177177
const projectContext = await this.getProjectContext(
178178
projectId,
179-
organizationId
179+
organizationId,
180180
);
181181
const userContext = await this.getUserContext(
182182
userId,
183-
projectContext.organizationId
183+
projectContext.organizationId,
184184
);
185185

186186
// Check organization-level permissions
187187
const orgPermission = this.checkOrganizationPermission(
188188
userContext.roles[0] || "",
189-
action
189+
action,
190190
);
191191

192192
if (orgPermission) {
@@ -196,7 +196,7 @@ export class AuthorizationService {
196196
// Check project-level permissions
197197
const projectPermission = this.checkProjectPermission(
198198
userContext.roles[0] || "",
199-
action
199+
action,
200200
);
201201

202202
return projectPermission;
@@ -212,16 +212,16 @@ export class AuthorizationService {
212212
async canAccessOrganization(
213213
userId: string,
214214
organizationId: string,
215-
action: Permission
215+
action: Permission,
216216
): Promise<boolean> {
217217
try {
218218
console.log(
219-
`Checking organization access for userId: ${userId}, organizationId: ${organizationId}, action: ${action}`
219+
`Checking organization access for userId: ${userId}, organizationId: ${organizationId}, action: ${action}`,
220220
);
221221
const userContext = await this.getUserContext(userId, organizationId);
222222
const hasPermission = this.checkOrganizationPermission(
223223
userContext.roles[0] || "",
224-
action
224+
action,
225225
);
226226
console.log(`Organization access result: ${hasPermission}`);
227227
return hasPermission;
@@ -237,23 +237,23 @@ export class AuthorizationService {
237237
async canViewProject(
238238
userId: string,
239239
projectId: string,
240-
organizationId?: string
240+
organizationId?: string,
241241
): Promise<boolean> {
242242
try {
243243
const projectContext = await this.getProjectContext(
244244
projectId,
245-
organizationId
245+
organizationId,
246246
);
247247
const userContext = await this.getUserContext(
248248
userId,
249-
projectContext.organizationId
249+
projectContext.organizationId,
250250
);
251251

252252
// Check if user has organization access
253253
const hasOrgAccess = await this.canAccessOrganization(
254254
userId,
255255
projectContext.organizationId,
256-
"read"
256+
"read",
257257
);
258258

259259
if (!hasOrgAccess) {
@@ -293,8 +293,8 @@ export class AuthorizationService {
293293
.where(
294294
and(
295295
eq(userProject.userId, userId),
296-
eq(userProject.projectId, projectId)
297-
)
296+
eq(userProject.projectId, projectId),
297+
),
298298
)
299299
.limit(1);
300300

@@ -325,7 +325,7 @@ export class AuthorizationService {
325325
if (role in AuthorizationService.PROJECT_PERMISSIONS) {
326326
const projectRole = role as ProjectRole;
327327
return AuthorizationService.PROJECT_PERMISSIONS[projectRole].map(
328-
(p) => `project:${p}`
328+
(p) => `project:${p}`,
329329
);
330330
}
331331

@@ -336,7 +336,7 @@ export class AuthorizationService {
336336
* Get project permissions for organization roles
337337
*/
338338
private getProjectPermissionsForOrgRole(
339-
orgRole: OrganizationRole
339+
orgRole: OrganizationRole,
340340
): Permission[] {
341341
switch (orgRole) {
342342
case "OWNER":
@@ -355,7 +355,7 @@ export class AuthorizationService {
355355
*/
356356
private checkOrganizationPermission(
357357
role: string,
358-
action: Permission
358+
action: Permission,
359359
): boolean {
360360
const permissions =
361361
AuthorizationService.ORGANIZATION_PERMISSIONS[role as OrganizationRole] ||
@@ -378,13 +378,13 @@ export class AuthorizationService {
378378
async removeUserRoles(
379379
userId: string,
380380
organizationId?: string,
381-
projectId?: string
381+
projectId?: string,
382382
): Promise<void> {
383383
try {
384384
if (organizationId) {
385385
// Remove organization role
386386
console.log(
387-
`Removing user ${userId} from organization ${organizationId}`
387+
`Removing user ${userId} from organization ${organizationId}`,
388388
);
389389
}
390390
if (projectId) {

packages/api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ app.use(
1717
cors({
1818
origin: config.cors.origin,
1919
credentials: true,
20-
})
20+
}),
2121
);
2222

2323
// Rate limiting

packages/api/src/middleware/async.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Request, Response, NextFunction } from 'express';
2-
import { AsyncHandler } from '../types';
1+
import { Request, Response, NextFunction } from "express";
2+
import { AsyncHandler } from "../types";
33

44
export function asyncHandler(fn: AsyncHandler) {
55
return (req: Request, res: Response, next: NextFunction): void => {

packages/api/src/middleware/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const authenticateUser = clerkRequireAuth({
1111
export async function mapAuthToUser(
1212
req: AuthenticatedRequest,
1313
res: Response,
14-
next: NextFunction
14+
next: NextFunction,
1515
): Promise<void> {
1616
// Clerk middleware sets req.auth, we need to map it to req.user for our existing code
1717
const auth = getAuth(req);

packages/api/src/middleware/authorization.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function requirePermission(options: AuthorizationOptions) {
1818
return async (
1919
req: AuthenticatedRequest,
2020
res: Response,
21-
next: NextFunction
21+
next: NextFunction,
2222
): Promise<void> => {
2323
try {
2424
if (!req.user) {
@@ -36,21 +36,21 @@ export function requirePermission(options: AuthorizationOptions) {
3636
hasPermission = await authzService.canViewProject(
3737
userId,
3838
resourceId,
39-
organizationId
39+
organizationId,
4040
);
4141
} else {
4242
hasPermission = await authzService.canAccessProject(
4343
userId,
4444
resourceId,
4545
options.action,
46-
organizationId
46+
organizationId,
4747
);
4848
}
4949
} else if (options.resource === "organization" && organizationId) {
5050
hasPermission = await authzService.canAccessOrganization(
5151
userId,
5252
organizationId,
53-
options.action
53+
options.action,
5454
);
5555
}
5656

@@ -130,7 +130,7 @@ export function requireProjectView() {
130130
export async function extractOrganizationContext(
131131
req: AuthenticatedRequest,
132132
res: Response,
133-
next: NextFunction
133+
next: NextFunction,
134134
): Promise<void> {
135135
try {
136136
if (!req.user) {
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import { Request, Response, NextFunction } from 'express';
2-
import { AuthenticatedRequest, ApiError, ErrorHandler } from '../types';
3-
import { config } from '../config';
1+
import { Request, Response, NextFunction } from "express";
2+
import { AuthenticatedRequest, ApiError, ErrorHandler } from "../types";
3+
import { config } from "../config";
44

55
export const errorHandler: ErrorHandler = (
66
error: Error,
77
req: AuthenticatedRequest,
88
res: Response,
9-
next: NextFunction
9+
next: NextFunction,
1010
): void => {
1111
let statusCode = 500;
12-
let message = 'Internal server error';
12+
let message = "Internal server error";
1313

1414
if (error instanceof ApiError) {
1515
statusCode = error.statusCode;
1616
message = error.message;
17-
} else if (error.name === 'ValidationError') {
17+
} else if (error.name === "ValidationError") {
1818
statusCode = 400;
19-
message = 'Validation error';
20-
} else if (error.name === 'UnauthorizedError') {
19+
message = "Validation error";
20+
} else if (error.name === "UnauthorizedError") {
2121
statusCode = 401;
22-
message = 'Unauthorized';
22+
message = "Unauthorized";
2323
}
2424

2525
// Log error in development
26-
if (config.nodeEnv === 'development') {
27-
console.error('Error:', error);
26+
if (config.nodeEnv === "development") {
27+
console.error("Error:", error);
2828
}
2929

3030
res.status(statusCode).json({
3131
success: false,
3232
error: message,
33-
...(config.nodeEnv === 'development' && { stack: error.stack }),
33+
...(config.nodeEnv === "development" && { stack: error.stack }),
3434
});
3535
};
3636

3737
export const notFoundHandler = (req: Request, res: Response): void => {
3838
res.status(404).json({
3939
success: false,
40-
error: 'Route not found',
40+
error: "Route not found",
4141
});
4242
};

0 commit comments

Comments
 (0)