Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Postmark setup- email for notifying admin on user sign" #101

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: "19.x"
node-version: '19.x'
# cache: yarn
# cache-dependency-path: './apps/web/package-lock.json'
- name: Install yarn
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: "19.x"
node-version: '19.x'
# cache: yarn
# cache-dependency-path: './apps/web/package-lock.json'
- name: Install yarn
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: "19.x"
node-version: '19.x'
# cache: yarn
# cache-dependency-path: './apps/server/package-lock.json'
- name: Install yarn
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ NextJS, NestJS, Prisma, PostgreSQL
1. Create a .env file in `apps/web` and `apps/server` and configure environment variables using the provided example files.

`apps/server/.env`
| VARIABLE | VALUE | | | |
| VARIABLE | VALUE | | | |
|--------------------|---------------------------------------------------------------------------------------------------------------------------------|---|---|---|
| DOMAIN | <http://localhost> | | | |
| BACKEND_PORT | 8080 | | | |
| SALT_ROUNDS | 10 | | | |
| DATABASE_URL | postgresql://user:pass@localhost:5432/db?schema=public | | | |
| JWT_SECRET | Execute the following to generate a random secret key: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" | | | |
| JWT_VALID_DURATION | 600 | | | |
| FRONTEND_DOMAIN | <http://localhost:3002> | | | |
| DOMAIN | <http://localhost> | | | |
| BACKEND_PORT | 8080 | | | |
| SALT_ROUNDS | 10 | | | |
| DATABASE_URL | postgresql://user:pass@localhost:5432/db?schema=public | | | |
| JWT_SECRET | Execute the following to generate a random secret key: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" | | | |
| JWT_VALID_DURATION | 600 | | | |
| FRONTEND_DOMAIN | <http://localhost:3002> | | | |

`apps/web/.env`
| VARIABLE | VALUE | | | |
| VARIABLE | VALUE | | | |
|--------------------|---------------------------------------------------------------------------------------------------------------------------------|---|---|---|
| DOMAIN | <http://localhost> | | | |
| FRONTEND_PORT | 3000 | | | |
| DOMAIN | <http://localhost> | | | |
| FRONTEND_PORT | 3000 | | | |

2. Install yarn dependencies. We currently use Yarn and Yarn workspaces to manage dependencies.

Expand Down
15 changes: 6 additions & 9 deletions apps/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
module.exports = {
presets: ["next/babel"],
plugins: [
[
"@locator/babel-jsx/dist",
{
presets: ["next/babel"],
plugins: [
["@locator/babel-jsx/dist", {
env: "development",
},
],
],
};
}]
]
};
3 changes: 2 additions & 1 deletion apps/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const app = express();
const proxy = createProxyMiddleware({
target: "http://localhost:3000", // all requests to be routed to frontend running on port 3000
router: {
"/api": "http://localhost:8080", // all requests prefixed with "/api" to be routed to backend running on port 3001
"/api/auth": "http://localhost:3000",
"/api/v1": "http://localhost:8080", // all requests prefixed with "/api" to be routed to backend running on port 3001
},
ws: true,
logLevel: "warn",
Expand Down
4 changes: 2 additions & 2 deletions apps/server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ BACKEND_PORT=8080
SALT_ROUNDS=10

# Prisma
DATABASE_URL=
DATABASE_URL=

JWT_SECRET=
JWT_SECRET=
JWT_REFRESH_SECRET=
JWT_VALID_DURATION=600
JWT_REFRESH_VALID_DURATION=604800
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"cookie-parser": "^1.4.6",
"jwt-decode": "^4.0.0",
"nestjs-config": "^1.4.11",
"next-auth": "^4.24.6",
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"postmark": "^4.0.2",
"prisma": "^5.2.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
Expand Down
8 changes: 4 additions & 4 deletions apps/server/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,28 @@ async function main() {
id: '777c1974-3104-4744-ae31-7a9296e7784a',
firstName: 'Helen',
lastName: 'Miao',
email: 'email1@gmail.com',
email: 'email1@kaiyangzhenggmail.onmicrosoft.com',
positionId: CHIEF_OF_STAFF_UUID,
},
{
id: '339cf78e-d13f-4069-b1f7-dee0c64afb31',
firstName: 'Kai',
lastName: 'Zheng',
email: 'email2@gmail.com',
email: 'email2@kaiyangzhenggmail.onmicrosoft.com',
positionId: CHIEF_FIN_OFFICER_UUID,
},
{
id: 'c6de4017-cb1f-44f1-a707-0f38239e0bca',
firstName: 'Iris',
lastName: 'Zhang',
email: 'email3@gmail.com',
email: 'email3@kaiyangzhenggmail.onmicrosoft.com',
positionId: AGG_DIR_UUID,
},
{
id: 'b386ef53-d2d1-4bfd-a44c-55b1750a874e',
firstName: 'Anshul',
lastName: 'Shirude',
email: 'email4@gmail.com',
email: 'email4@kaiyangzhenggmail.onmicrosoft.com',
positionId: CHIEF_LEARNING_ENGAGEMENT_UUID,
},
];
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AppController {
}

@UseGuards(LocalAuthGuard)
@Post('auth/login')
@Post('/auth/login')
@ApiOkResponse({ type: JwtEntity })
@ApiForbiddenResponse({ description: AppErrorMessage.FORBIDDEN })
@ApiUnprocessableEntityResponse({
Expand Down Expand Up @@ -76,7 +76,7 @@ export class AppController {
}

@UseGuards(JwtRefreshAuthGuard)
@Get('auth/refresh')
@Get('/auth/refresh')
@ApiBearerAuth()
@ApiOkResponse({ type: JwtEntity })
@ApiForbiddenResponse({ description: AppErrorMessage.FORBIDDEN })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PositionsService } from '../positions/positions.service';
import { LoggerServiceImpl } from '../logger/logger.service';
import { PostmarkService } from '../postmark/postmark.service';

describe('FormInstancesController', () => {
let controller: FormInstancesController;
Expand All @@ -29,7 +28,6 @@ describe('FormInstancesController', () => {
PositionsService,
PrismaService,
LoggerServiceImpl,
PostmarkService,
],
}).compile();

Expand Down
3 changes: 1 addition & 2 deletions apps/server/src/form-instances/form-instances.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { PrismaModule } from '../prisma/prisma.module';
import { FormTemplatesModule } from '../form-templates/form-templates.module';
import { PositionsModule } from '../positions/positions.module';
import { LoggerModule } from '../logger/logger.module';
import { PostmarkService } from '../postmark/postmark.service';

@Module({
controllers: [FormInstancesController],
providers: [FormInstancesService, PostmarkService],
providers: [FormInstancesService],
exports: [FormInstancesService],
imports: [PrismaModule, FormTemplatesModule, PositionsModule, LoggerModule],
})
Expand Down
2 changes: 0 additions & 2 deletions apps/server/src/form-instances/form-instances.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Prisma } from '@prisma/client';
import { FormTemplateErrorMessage } from '../form-templates/form-templates.errors';
import { FormInstanceErrorMessage } from './form-instance.errors';
import { PositionsErrorMessage } from '../positions/positions.errors';
import { PostmarkService } from '../postmark/postmark.service';

const formInstance1Id = 'formInstanceId1';
const formInstance2Id = 'formInstanceId2';
Expand Down Expand Up @@ -230,7 +229,6 @@ describe('FormInstancesService', () => {
FormInstancesService,
FormTemplatesService,
PositionsService,
PostmarkService,
{
provide: PrismaService,
useValue: db,
Expand Down
14 changes: 1 addition & 13 deletions apps/server/src/form-instances/form-instances.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import { PositionsErrorMessage } from '../positions/positions.errors';
import { SignatureErrorMessage } from '../signatures/signatures.errors';
import { EmployeeErrorMessage } from '../employees/employees.errors';
import { UserEntity } from '../auth/entities/user.entity';
import { PostmarkService } from '../postmark/postmark.service';

@Injectable()
export class FormInstancesService {
constructor(
private prisma: PrismaService,
private formTemplateService: FormTemplatesService,
private positionService: PositionsService,
private postmarkService: PostmarkService,
) {}

/**
Expand Down Expand Up @@ -275,7 +273,6 @@ export class FormInstancesService {
where: { id: formInstanceId },
include: {
signatures: { include: { signerPosition: true, userSignedBy: true } },
originator: true,
},
});

Expand Down Expand Up @@ -334,17 +331,8 @@ export class FormInstancesService {
signatures: { include: { signerPosition: true, userSignedBy: true } },
},
});
//this.postmarkService.sendEmail('weigl.a@northeastern.edu', 'test email: form signed by everyone', 'this is a test');
}
const emailBody: string = `Hi Iris, your form has been signed by user: ${JSON.stringify(
currentUser.email,
)}.`;
const emailSubject: string = `Form signed by user ${currentUser.email}`;
this.postmarkService.sendEmail(
'weigl.a@northeastern.edu',
emailSubject,
emailBody,
);

return updatedFormInstance;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function bootstrap() {
});
}

app.setGlobalPrefix('api');
app.setGlobalPrefix('api/v1');

const config = new DocumentBuilder()
.setTitle('MFA Form Automator API')
Expand Down
27 changes: 0 additions & 27 deletions apps/server/src/postmark/postmark.service.ts

This file was deleted.

2 changes: 2 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"gen-client": "openapi --input http://localhost:4000/api-json --output ./src/client --client axios"
},
"dependencies": {
"@azure/identity": "^4.0.1",
"@azure/storage-blob": "^12.17.0",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.4.9",
"@emotion/react": "^11.10.5",
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/client/services/DefaultService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DefaultService {
public static appControllerGetHello(): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'GET',
url: '/api',
url: '/api/v1',
});
}

Expand All @@ -32,7 +32,7 @@ export class DefaultService {
): CancelablePromise<JwtEntity | any> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/auth/login',
url: '/api/v1/auth/login',
body: requestBody,
mediaType: 'application/json',
errors: {
Expand All @@ -50,7 +50,7 @@ export class DefaultService {
public static appControllerRefresh(): CancelablePromise<JwtEntity> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/auth/refresh',
url: '/api/v1/auth/refresh',
errors: {
400: `Bad Request`,
403: `Unauthorized Request`,
Expand All @@ -66,7 +66,7 @@ export class DefaultService {
public static appControllerLogout(): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/auth/logout',
url: '/api/v1/auth/logout',
});
}

Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/client/services/DepartmentsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DepartmentsService {
): CancelablePromise<DepartmentEntity> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/departments',
url: '/api/v1/departments',
body: requestBody,
mediaType: 'application/json',
errors: {
Expand All @@ -43,7 +43,7 @@ export class DepartmentsService {
): CancelablePromise<Array<DepartmentEntity>> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/departments',
url: '/api/v1/departments',
query: {
'limit': limit,
},
Expand All @@ -64,7 +64,7 @@ export class DepartmentsService {
): CancelablePromise<DepartmentEntity> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/departments/{id}',
url: '/api/v1/departments/{id}',
path: {
'id': id,
},
Expand All @@ -88,7 +88,7 @@ export class DepartmentsService {
): CancelablePromise<DepartmentEntity> {
return __request(OpenAPI, {
method: 'PATCH',
url: '/api/departments/{id}',
url: '/api/v1/departments/{id}',
path: {
'id': id,
},
Expand All @@ -113,7 +113,7 @@ export class DepartmentsService {
): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/api/departments/{id}',
url: '/api/v1/departments/{id}',
path: {
'id': id,
},
Expand Down
Loading
Loading