Skip to content

Commit 517f526

Browse files
authored
Fix history build (#83)
* Fix history build Fix history building in wrong directory * Fix compose.dev.yml * Rename history entrypoint * Make history endpoint gateway-accessible The current endpoint is not accessible on production * Fix tests * Fix test typing Make use of Project References to ensure tests has relevant types * Remove root package-lock
1 parent 65f37ff commit 517f526

File tree

10 files changed

+45
-23
lines changed

10 files changed

+45
-23
lines changed

compose.dev.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ services:
4747
volumes:
4848
- /app/node_modules
4949
- ./services/collaboration:/app
50-
51-
collaboration-db:
52-
ports:
53-
- 27020:27017
5450

5551
collaboration-db:
5652
ports:

package-lock.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

services/history/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ docker compose down -v
2727

2828
- This endpoint retrieves the history of a user.
2929
- **HTTP Method**: `GET`
30-
- **Endpoint**: http://localhost:8086/api/history
30+
- **Endpoint**: http://localhost:8086/api/history/history
3131
- **Headers**
3232
- `Authorization: Bearer <JWT_ACCESS_TOKEN>` (Required)
3333
- The endpoint requires the user to include a JWT (JSON Web Token) in the HTTP Request Header for authentication and authorization. This token is generated during the authentication process (i.e., login) and contains information about the user's identity. The server verifies this token to ensure that the client is authorized to access the data.

services/history/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "history",
33
"version": "0.0.0",
4-
"main": "index.js",
4+
"main": "server.js",
55
"scripts": {
6-
"build": "npx tsc",
7-
"start": "npm run build && node ./dist/index.js",
8-
"dev": "nodemon --files ./src/index.ts",
9-
"lint": "npx eslint .",
10-
"lint:fix": "npx eslint . --fix",
6+
"build": "npx tsc --build src/tsconfig.json",
7+
"start": "npm run build && node ./dist/server.js",
8+
"dev": "nodemon --files ./src/server.ts",
9+
"lint": "npx eslint src tests",
10+
"lint:fix": "npx eslint src tests --fix",
1111
"test": "mocha --require ts-node/register tests/**/*.spec.ts --exit"
1212
},
1313
"author": "",

services/history/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ app.use(
2525

2626
// Routes
2727
app.use('/', router);
28-
app.use('/api/history', verifyAccessToken, historyRouter);
28+
app.use('/api/history/history', verifyAccessToken, historyRouter);
2929

3030
export default app;
File renamed without changes.

services/history/src/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* Visit https://aka.ms/tsconfig to read more about this file */
2+
{
3+
"compilerOptions": {
4+
"target": "es2016",
5+
"module": "CommonJS",
6+
"outDir": "../dist",
7+
"composite": true,
8+
"strict": true,
9+
"esModuleInterop": true,
10+
"skipLibCheck": true,
11+
"forceConsistentCasingInFileNames": true,
12+
},
13+
"include": ["**/*.ts"]
14+
}

services/history/tests/controllers/historyController.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('History Controller', function () {
3333

3434
it('Should return history with token', done => {
3535
chai.request(app)
36-
.get(`/api/history`)
36+
.get(`/api/history/history`)
3737
.set('Authorization', `Bearer ${user1Token}`)
3838
.end((err, res) => {
3939
expect(res).to.have.status(200);
@@ -45,7 +45,7 @@ describe('History Controller', function () {
4545

4646
it('Should return empty history for different token', done => {
4747
chai.request(app)
48-
.get(`/api/history`)
48+
.get(`/api/history/history`)
4949
.set('Authorization', `Bearer ${user3Token}`)
5050
.end((err, res) => {
5151
expect(res).to.have.status(200);
@@ -57,7 +57,7 @@ describe('History Controller', function () {
5757

5858
it('Should return 401 without accessToken', done => {
5959
chai.request(app)
60-
.get(`/api/history`)
60+
.get(`/api/history/history`)
6161
.end((err, res) => {
6262
expect(res).to.have.status(401);
6363
expect(res.body).to.have.property('message');
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2016",
4+
"module": "CommonJS",
5+
"composite": true,
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"skipLibCheck": true,
9+
"forceConsistentCasingInFileNames": true,
10+
},
11+
"references": [
12+
{ "path": "../src" }
13+
],
14+
"include": ["**/*.ts"]
15+
}

services/history/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
"compilerOptions": {
44
"target": "es2016",
55
"module": "CommonJS",
6+
"rootDir": "./src",
67
"outDir": "./dist",
7-
"types": ["mocha"],
88
"strict": true,
99
"esModuleInterop": true,
1010
"skipLibCheck": true,
1111
"forceConsistentCasingInFileNames": true,
1212
},
13-
"include": ["src/**/*.ts", "tests/**/*.ts"],
13+
"references": [
14+
{ "path": "./src" },
15+
{ "path": "./tests" }
16+
],
1417
"exclude": ["node_modules"],
1518
"ts-node": {
1619
"files": true

0 commit comments

Comments
 (0)