Skip to content

Commit 71e12e6

Browse files
authored
Merge branch 'dev' into feat/user-application-post
2 parents b6b6753 + b442d3e commit 71e12e6

8 files changed

Lines changed: 1344 additions & 956 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
timeout-minutes: 30
11-
env:
11+
env:
1212
MJ_APIKEY_PUBLIC: ${{ secrets.MJ_APIKEY_PUBLIC }}
1313
MJ_APIKEY_PRIVATE: ${{ secrets.MJ_APIKEY_PRIVATE }}
1414
DATABASE_URL: ${{ secrets.DATABASE_URL_TEST }}
@@ -38,7 +38,7 @@ jobs:
3838
run: |
3939
if [ ${{ github.event.pull_request.base.ref }} == "main" ]; then
4040
yarn test:unit
41-
fi
41+
fi
4242
4343
- name: Push latest schema to the test database
4444
run: npx prisma db push --accept-data-loss
@@ -47,4 +47,4 @@ jobs:
4747
run: |
4848
if [ ${{ github.event.pull_request.base.ref }} == "main" ]; then
4949
yarn test:e2e --testTimeout=300000
50-
fi
50+
fi

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ $ yarn studio
7979
> [!TIP]
8080
> It is recommended to use `db push` to [prototype your schema](https://www.prisma.io/docs/orm/prisma-migrate/workflows/prototyping-your-schema)
8181
82+
### Troubleshooting Prisma not detecting openssl
83+
If you get this message after running any of the prisma command:
84+
```bash
85+
prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
86+
Please manually install OpenSSL and try installing Prisma again.
87+
```
88+
try running `yarn install` command to install all the dependencies in docker
89+
8290
## Running the app
8391

8492
```bash
@@ -153,6 +161,9 @@ Once the services are spun up, go to your docker desktop, chingu-dashboard-be co
153161

154162
Using the container actions, select 'Open in terminal'.
155163

164+
> [!IMPORTANT]
165+
> After spinning up the Docker services, run `yarn install`
166+
156167
From here, type all the commands [above](#prismaStudio).
157168

158169
## PG Admin

dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine
1+
FROM node:22-alpine
22

33
WORKDIR /usr/src/app
44

package.json

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,73 +43,75 @@
4343
"test": "yarn test:e2e --silent && yarn test:unit --silent"
4444
},
4545
"dependencies": {
46-
"@casl/ability": "^6.7.2",
47-
"@casl/prisma": "^1.5.0",
48-
"@eslint/eslintrc": "^3.2.0",
49-
"@eslint/js": "^9.17.0",
50-
"@nestjs/common": "^10.4.15",
51-
"@nestjs/config": "^3.3.0",
52-
"@nestjs/core": "^10.4.15",
53-
"@nestjs/jwt": "^10.2.0",
54-
"@nestjs/passport": "^10.0.3",
55-
"@nestjs/platform-express": "^10.4.15",
56-
"@nestjs/schedule": "^4.1.2",
57-
"@nestjs/swagger": "^8.1.0",
58-
"@prisma/client": "^5.22.0",
46+
"@casl/ability": "^6.7.3",
47+
"@casl/prisma": "1.5.1",
48+
"@eslint/eslintrc": "^3.3.1",
49+
"@eslint/js": "^9.23.0",
50+
"@nestjs/common": "^11.0.12",
51+
"@nestjs/config": "^4.0.1",
52+
"@nestjs/core": "^11.0.12",
53+
"@nestjs/jwt": "^11.0.0",
54+
"@nestjs/passport": "^11.0.5",
55+
"@nestjs/platform-express": "^11.0.12",
56+
"@nestjs/schedule": "^5.0.1",
57+
"@nestjs/swagger": "^11.0.7",
58+
"@prisma/client": "6",
5959
"bcrypt": "^5.1.1",
6060
"class-transformer": "^0.5.1",
6161
"class-validator": "^0.14.1",
6262
"cookie-parser": "^1.4.7",
6363
"dotenv": "^16.4.7",
64-
"globals": "^15.13.0",
65-
"lint-staged": "^15.2.11",
64+
"express": "4.0.0",
65+
"globals": "^16.0.0",
66+
"lint-staged": "^15.5.0",
6667
"morgan": "^1.10.0",
67-
"node-mailjet": "^6.0.6",
68+
"node-mailjet": "^6.0.8",
6869
"passport": "^0.7.0",
6970
"passport-discord": "^0.1.4",
7071
"passport-jwt": "^4.0.1",
7172
"passport-local": "^1.0.0",
7273
"reflect-metadata": "^0.2.2",
73-
"rxjs": "^7.8.1",
74-
"swagger-ui-express": "^5.0.1"
74+
"rxjs": "^7.8.2",
75+
"swagger-ui-express": "^5.0.1",
76+
"webpack": "^5.0.0"
7577
},
7678
"devDependencies": {
77-
"@nestjs/cli": "^10.4.9",
78-
"@nestjs/schematics": "^10.2.3",
79-
"@nestjs/testing": "^10.4.15",
79+
"@nestjs/cli": "^11.0.5",
80+
"@nestjs/schematics": "^11.0.2",
81+
"@nestjs/testing": "^11.0.12",
8082
"@types/bcrypt": "^5.0.2",
8183
"@types/cookie-parser": "^1.4.8",
82-
"@types/express": "^5.0.0",
84+
"@types/express": "^5.0.1",
8385
"@types/jest": "^29.5.14",
8486
"@types/morgan": "^1.9.9",
85-
"@types/node": "^22.10.2",
86-
"@types/node-mailjet": "^3.3.12",
87+
"@types/node": "^22.13.11",
88+
"@types/node-mailjet": "^4.0.0",
8789
"@types/passport-discord": "^0.1.14",
8890
"@types/passport-jwt": "^4.0.1",
8991
"@types/passport-local": "^1.0.38",
9092
"@types/supertest": "^6.0.2",
91-
"@typescript-eslint/eslint-plugin": "^8.18.1",
92-
"@typescript-eslint/parser": "^8.18.1",
93+
"@typescript-eslint/eslint-plugin": "^8.27.0",
94+
"@typescript-eslint/parser": "^8.27.0",
9395
"cross-env": "^7.0.3",
94-
"dotenv-cli": "^7.4.4",
95-
"eslint": "^8.57.0",
96-
"eslint-config-prettier": "^9.1.0",
97-
"eslint-plugin-jest-extended": "^2.4.0",
98-
"eslint-plugin-prettier": "^5.2.1",
96+
"dotenv-cli": "^8.0.0",
97+
"eslint": "^9.23.0",
98+
"eslint-config-prettier": "^10.1.1",
99+
"eslint-plugin-jest-extended": "^3.0.0",
100+
"eslint-plugin-prettier": "^5.2.3",
99101
"husky": "^9.1.7",
100102
"jest": "^29.7.0",
101103
"jest-extended": "^4.0.2",
102104
"jest-mock-extended": "^3.0.7",
103105
"joi": "^17.13.3",
104-
"prettier": "^3.4.2",
105-
"prisma": "5.22.0",
106+
"prettier": "^3.5.3",
107+
"prisma": "6",
106108
"source-map-support": "^0.5.21",
107-
"supertest": "^7.0.0",
108-
"ts-jest": "^29.2.5",
109-
"ts-loader": "9.4.4",
109+
"supertest": "^7.1.0",
110+
"ts-jest": "^29.2.6",
111+
"ts-loader": "9.5.2",
110112
"ts-node": "^10.9.2",
111113
"tsconfig-paths": "^4.2.0",
112-
"typescript": "^5.7.2"
114+
"typescript": "^5.8.2"
113115
},
114116
"jest": {
115117
"moduleFileExtensions": [

src/ability/conditions/ideations.ability.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ export const manageOwnIdeationById = async (
1010
ideationId: number,
1111
) => {
1212
if (user.roles?.includes("admin")) return;
13+
1314
const ideation = await prisma.projectIdea.findUnique({
14-
where: {
15-
id: ideationId,
16-
},
15+
where: { id: ideationId },
16+
select: { voyageTeamMemberId: true },
1717
});
18+
1819
if (!ideation) {
1920
throw new NotFoundException(`Ideation (id:${ideationId}) not found`);
2021
}
22+
2123
// ideation is not linked to any members, this should never happen unless the user gets deleted
2224
// or removed from the team?
2325
// in this case we should let the rest of the team manage it
@@ -26,6 +28,7 @@ export const manageOwnIdeationById = async (
2628
`Ideation access control: You do not have sufficient permission to access this resource.`,
2729
);
2830
}
31+
2932
if (
3033
!user.voyageTeams
3134
.map((vt) => vt.memberId)

src/ideations/ideations.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Module } from "@nestjs/common";
22
import { IdeationsService } from "./ideations.service";
33
import { IdeationsController } from "./ideations.controller";
44
import { PrismaModule } from "../prisma/prisma.module";
5+
56
@Module({
67
controllers: [IdeationsController],
78
providers: [IdeationsService],

src/ideations/ideations.service.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,25 @@ export class IdeationsService {
122122
// teamId: number,
123123
updateIdeationDto: UpdateIdeationDto,
124124
) {
125+
// First check if user has permission to update this ideation
126+
await manageOwnIdeationById(req.user, ideationId);
127+
128+
// Then validate the update data
129+
if (!updateIdeationDto) {
130+
throw new BadRequestException("Update data is required");
131+
}
132+
125133
const { title, description, vision } = updateIdeationDto;
126134

127-
await manageOwnIdeationById(req.user, ideationId);
135+
// await manageOwnIdeationById(req.user, ideationId);
128136

129137
// TODO: might need to check if user can update it
130138
// (they should only be able to update it when they have the only vote)
131139
try {
132140
//only allow the user that created the idea to edit it
133141
return this.prisma.projectIdea.update({
134-
where: {
135-
id: ideationId,
136-
},
137-
data: {
138-
title,
139-
description,
140-
vision,
141-
},
142+
where: { id: ideationId },
143+
data: { title, description, vision },
142144
});
143145
} catch (e) {
144146
throw e;

0 commit comments

Comments
 (0)