Skip to content

Commit b24d5b5

Browse files
committed
Typescript Bootcamp
1 parent b68426d commit b24d5b5

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

rest-api/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rest-api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dotenv": "^16.0.2",
2222
"express": "^4.18.1",
2323
"pg": "^8.8.0",
24+
"reflect-metadata": "^0.1.13",
2425
"rimraf": "^3.0.2",
2526
"typeorm": "^0.3.9",
2627
"winston": "^3.8.2"

rest-api/src/data-source.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import {DataSource} from "typeorm";
2+
import {Course} from "./models/course";
3+
import {Lesson} from "./models/lesson";
24

35

46
export const AppDataSource = new DataSource({
@@ -15,7 +17,9 @@ export const AppDataSource = new DataSource({
1517
}
1618
},
1719
entities: [
18-
20+
Course,
21+
Lesson
1922
],
23+
synchronize: true,
2024
logging:true
2125
})

rest-api/src/models/lesson.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm";
22
import { Course } from "./course";
3+
import {JoinColumn} from "typeorm";
34

45
@Entity({
56
name: "LESSONS"
@@ -19,6 +20,9 @@ export class Lesson {
1920
seqNo: number;
2021

2122
@ManyToOne(() => Course, course => course.lessons)
23+
@JoinColumn({
24+
name: "courseId"
25+
})
2226
course: Course;
2327

2428
@CreateDateColumn()

rest-api/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if (result.error) {
77
process.exit(1);
88
}
99

10+
import "reflect-metadata";
1011
import * as express from 'express';
1112
import {root} from "./routes/root";
1213
import {isInteger} from "./utils";

rest-api/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"target": "ES5",
44
"outDir": "dist",
5-
"experimentalDecorators": true
5+
"experimentalDecorators": true,
6+
"emitDecoratorMetadata": true
67
}
78
}

0 commit comments

Comments
 (0)