Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
4a49a5f9
Commit
4a49a5f9
authored
Nov 05, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ticket#23 added simple router to task and added project model to app-data-source and server fix
parent
f94eb2ec
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
2 deletions
+23
-2
app-data-source.ts
planner-api/src/app-data-source.ts
+2
-1
Task.ts
planner-api/src/models/Task.ts
+1
-1
tasks.ts
planner-api/src/routers/tasks.ts
+16
-0
server.ts
planner-api/src/server.ts
+4
-0
No files found.
planner-api/src/app-data-source.ts
View file @
4a49a5f9
import
{
DataSource
}
from
"typeorm"
;
import
{
User
}
from
'./models/User'
;
import
{
Task
}
from
'./models/Task'
;
import
{
Project
}
from
"./models/Project"
;
export
const
myDataSource
=
new
DataSource
({
type
:
"postgres"
,
...
...
@@ -9,7 +10,7 @@ export const myDataSource = new DataSource({
username
:
"pluser"
,
password
:
"pluser"
,
database
:
"planner"
,
entities
:
[
User
,
Task
],
entities
:
[
User
,
Task
,
Project
],
logging
:
true
,
synchronize
:
true
,
// in build switch to false
migrationsRun
:
false
...
...
planner-api/src/models/Task.ts
View file @
4a49a5f9
...
...
@@ -53,6 +53,6 @@ import {
@
ManyToMany
(()
=>
User
,
(
user
:
{
tasks
:
Task
[];
})
=>
user
.
tasks
)
assignedTo
!
:
User
[];
@
ManyToOne
(()
=>
Project
,(
task
:
{
project
:
Project
})
=>
task
.
project
)
@
ManyToOne
(()
=>
Project
,(
project
:{
tasks
:
Task
[]})
=>
project
.
tasks
)
project
!
:
Project
|
null
;
}
planner-api/src/routers/tasks.ts
0 → 100644
View file @
4a49a5f9
import
express
,{
Router
,
Request
,
Response
}
from
'express'
;
// import {User} from '../models/User';
// import {Project} from '../models/Project';
import
{
Task
}
from
'../models/Task'
;
import
{
myDataSource
}
from
'../app-data-source'
;
// import { nanoid } from 'nanoid';
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>
=>
{
const
tasks
=
await
dataSource
.
manager
.
find
(
Task
)
return
res
.
send
({
tasks
})
})
export
default
router
;
planner-api/src/server.ts
View file @
4a49a5f9
import
express
,
{
Express
}
from
'express'
;
import
cors
from
'cors'
;
import
users
from
'./routers/users'
;
import
tasks
from
'./routers/tasks'
;
import
projects
from
'./routers/projects'
;
import
{
myDataSource
}
from
'./app-data-source'
;
...
...
@@ -19,6 +21,8 @@ app.use(cors())
app
.
use
(
express
.
json
());
const
PORT
=
8000
;
app
.
use
(
'/users'
,
users
)
app
.
use
(
'/tasks'
,
tasks
)
app
.
use
(
'/projects'
,
projects
)
const
run
=
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment