Skip to content

Commit

Permalink
chore(ci): clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
younes200 committed Dec 16, 2024
1 parent 200e785 commit a641f77
Showing 11 changed files with 58 additions and 344 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -47,11 +47,10 @@ The project is organized as a [monorepo](https://blog.scottlogic.com/2018/02/23/
├── apps/ # Main application containers
│ ├── frontend/ # Frontend application code
├── packages/ # Shared packages
│ ├── config/ # Configuration settings and files
│ ├── i18n/ # Internationalization settings and translations
│ ├── passport/ # Passport authentication settings
│ ├── prisma/ # Prisma ORM configurations and schema
│ ├── trpc/ # tRPC settings and utilities
│ ├── auth/ # Authentication settings
│ ├── db/ # Prisma ORM configurations and schema
│ ├── api/ # tRPC settings and utilities
│ ├── types/ # Shared TypeScript types
│ └── utils/ # Shared utilities
├── tests/ # Test scripts and test-related utilities
1 change: 1 addition & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
"@cutting/use-get-parent-size": "^2.1.4",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@godaddy/terminus": "^4.12.1",
"@mui": "link:@mui",
"@mui/icons-material": "^6.1.2",
"@mui/lab": "^5.0.0-alpha.153",
2 changes: 1 addition & 1 deletion apps/frontend/src/components/chapters/list-item.tsx
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ export const ChapterItem: React.FC<ChapterItemProps> = ({
}
};

const canEdit = project.user.id === user?.id || user?.role === "ADMIN";
const canEdit = project.user.id === user?.id || user?.role === "admin";

const handleDelete: React.MouseEventHandler<HTMLButtonElement> = (event) => {
event.stopPropagation();
2 changes: 1 addition & 1 deletion apps/frontend/src/components/chapters/panel.tsx
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ export function ChaptersPanel({ project, user }: ChaptersPanelProps) {
return (
<NoChaptersJob
projectId={project.id}
canGenerate={project.userId === user?.id || user?.role === "ADMIN"}
canGenerate={project.userId === user?.id || user?.role === "admin"}
/>
);
}
6 changes: 3 additions & 3 deletions apps/frontend/src/server/admin.ts
Original file line number Diff line number Diff line change
@@ -63,11 +63,11 @@ const getAdminRouter = () => {
branding: {
companyName: 'Celluloid',
withMadeWithLove: false,
logo: '/images/logo-admin.svg',
logo: '/logo-admin.svg',
theme: overrides
},
assets: {
styles: ['/styles/override.css'],
styles: ['/override.css'],
},
defaultTheme: noSidebar.id,
availableThemes: [dark, light, noSidebar],
@@ -247,7 +247,7 @@ const getAdminRouter = () => {
},
componentLoader,
});
if (process.env.NODE_ENV === "developement")
if (process.env.NODE_ENV === "development")
admin.watch()
return AdminJSExpress.buildRouter(admin);
};
25 changes: 17 additions & 8 deletions apps/frontend/src/server/main.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@ import { emailQueue, chaptersQueue } from "@celluloid/queue";

import { expressAuthHandler, expressAuthSession } from "@celluloid/auth";
import getAdminRouter from "./admin";
import { debug } from "node:util";
import { createTerminus } from '@godaddy/terminus';
import { prisma } from "@celluloid/prisma";


const app = express();
@@ -75,11 +76,19 @@ const server = ViteExpress.listen(app, 3000, () =>
console.log("Server is listening on port 3000..."),
);

process.on('SIGTERM', async () => {
debug('SIGTERM signal received: closing HTTP server')
server.close(async () => {
await emailQueue.stop();
await chaptersQueue.stop();
debug('HTTP server closed')
})

async function onSignal() {
console.log("server is starting cleanup")
// wsHandler.broadcastReconnectNotification()
await emailQueue.stop();
await chaptersQueue.stop();
await new Promise((resolve) => server.close(resolve));
await prisma.$disconnect()
return;
}

createTerminus(server, {
// healthChecks: { '/healthcheck': onHealthCheck },
signals: ['SIGTERM', 'SIGINT'],
onSignal
})
34 changes: 12 additions & 22 deletions apps/frontend/src/utils/ProjectUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
import { ProjectGraphRecord, UserRecord } from '@celluloid/types';
import * as R from 'ramda';
import type { ProjectGraphRecord, UserRecord } from "@celluloid/types";
import * as R from "ramda";

export function isOwner(
project: ProjectGraphRecord,
user: UserRecord
) {
export function isOwner(project: ProjectGraphRecord, user: UserRecord) {
return user.id === project.userId;
}

export function isAdmin(
user: UserRecord
) {
return user.role === 'Admin';
export function isAdmin(user: UserRecord) {
return user.role === "admin";
}

export function isMember(
project: ProjectGraphRecord,
user: UserRecord
) {
return !!R.find((elem: UserRecord) =>
elem.id === user.id
)(project.members);
export function isMember(project: ProjectGraphRecord, user: UserRecord) {
return !!R.find((elem: UserRecord) => elem.id === user.id)(project.members);
}

export function canAnnotate(
project: ProjectGraphRecord,
user: UserRecord
) {
return (isOwner(project, user) || isMember(project, user) || isAdmin(user)) && project.collaborative;
export function canAnnotate(project: ProjectGraphRecord, user: UserRecord) {
return (
(isOwner(project, user) || isMember(project, user) || isAdmin(user)) &&
project.collaborative
);
}

export const canShare = isOwner || isAdmin;
6 changes: 3 additions & 3 deletions apps/frontend/src/utils/UserUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserRecord } from "@celluloid/types";
import type { UserRecord } from "@celluloid/types";
import randomColor from "randomcolor";

export function getUserInitials(username: string): string {
@@ -14,9 +14,9 @@ export function getUserColor(id: string): string {
}

export function isTeacher(user?: UserRecord) {
return user && user.role === "Teacher";
return user && user.role === "teacher";
}

export function isAdmin(user?: UserRecord) {
return user && user.role === "Admin";
return user && user.role === "admin";
}
6 changes: 0 additions & 6 deletions packages/queue/src/mailer/transport.ts
Original file line number Diff line number Diff line change
@@ -55,12 +55,6 @@ export default function getTransport(): Promise<nodemailer.Transporter> {
});
}

if (!env.SMTP_HOST) {
throw new Error("Misconfiguration: no SMTP_HOST");
}
if (!env.SMTP_PORT) {
throw new Error("Misconfiguration: no SMTP_PORT");
}
console.log(env.SMTP_HOST, env.SMTP_PORT, env.SMTP_SECURE);
return nodemailer.createTransport({
host: env.SMTP_HOST,
Loading

0 comments on commit a641f77

Please sign in to comment.