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
9c65cae3
Commit
9c65cae3
authored
Nov 02, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#8
added set up working credentials for base
parent
c741d378
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
app-data-source.ts
planner-api/src/app-data-source.ts
+7
-5
User.ts
planner-api/src/models/User.ts
+12
-11
users.ts
planner-api/src/routers/users.ts
+2
-1
No files found.
planner-api/src/app-data-source.ts
View file @
9c65cae3
import
{
DataSource
}
from
"typeorm"
import
{
DataSource
}
from
"typeorm"
;
import
{
User
}
from
'./models/User'
;
export
const
myDataSource
=
new
DataSource
({
export
const
myDataSource
=
new
DataSource
({
type
:
"postgres"
,
type
:
"postgres"
,
host
:
"localhost"
,
host
:
"localhost"
,
port
:
3308
,
port
:
5432
,
username
:
"
test
"
,
username
:
"
pluser
"
,
password
:
"
test
"
,
password
:
"
pluser
"
,
database
:
"planner"
,
database
:
"planner"
,
entities
:
[
"./models/*.ts"
],
// entities: ["./models/*.ts"],
entities
:
[
User
],
logging
:
true
,
logging
:
true
,
synchronize
:
true
,
synchronize
:
true
,
})
})
\ No newline at end of file
planner-api/src/models/User.ts
View file @
9c65cae3
...
@@ -44,30 +44,31 @@ export class User extends BaseEntity implements IUser {
...
@@ -44,30 +44,31 @@ export class User extends BaseEntity implements IUser {
@
Column
({
name
:
'last_name'
,
type
:
'varchar'
,
length
:
30
,
nullable
:
false
})
@
Column
({
name
:
'last_name'
,
type
:
'varchar'
,
length
:
30
,
nullable
:
false
})
surname
!
:
string
surname
!
:
string
@
Column
({
name
:
'
last_n
ame'
,
type
:
'varchar'
,
length
:
30
,
nullable
:
false
})
@
Column
({
name
:
'
displayN
ame'
,
type
:
'varchar'
,
length
:
30
,
nullable
:
false
})
displayName
!
:
string
displayName
!
:
string
@
Column
({
type
:
'varchar'
,
length
:
20
,
unique
:
true
,
nullable
:
false
})
@
Column
({
type
:
'varchar'
,
length
:
20
,
unique
:
true
,
nullable
:
false
})
email
!
:
string
email
!
:
string
@
Column
({
type
:
'varchar'
,
length
:
10
,
unique
:
true
})
@
Column
({
type
:
'varchar'
,
length
:
10
,
unique
:
true
,
nullable
:
true
})
phone
!
:
string
phone
?:
string
@
Column
({
type
:
'varchar'
,
nullable
:
false
})
password
!
:
string
@
CreateDateColumn
()
@
CreateDateColumn
()
// @CreateDateColumn({ name: 'created_at', type: Date, default: new Date() })
// @CreateDateColumn({ name: 'created_at', type: Date, default: new Date() })
// createdAt: Date
// createdAt: Date
@
Column
({
@
Column
({
type
:
"enum"
,
type
:
"enum"
,
enum
:
[
"worker"
,
"director"
],
enum
:
[
"worker"
,
"director"
],
default
:
"
ghost
"
default
:
"
worker
"
})
})
role
!
:
UserRoleType
role
!
:
UserRoleType
@
Exclude
()
@
Column
({
type
:
'varchar'
,
nullable
:
false
,
select
:
false
})
password
!
:
string
...
...
planner-api/src/routers/users.ts
View file @
9c65cae3
import
express
,{
Router
,
Request
,
Response
}
from
'express'
;
import
express
,{
Router
,
Request
,
Response
}
from
'express'
;
import
{
User
}
from
'../models/User'
;
import
{
User
}
from
'../models/User'
;
//
import {DataSource} from 'typeorm';
import
{
DataSource
}
from
'typeorm'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
myDataSource
}
from
'../app-data-source'
;
const
router
:
Router
=
express
.
Router
();
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
const
dataSource
=
myDataSource
;
// const dataSource = myDataSource;
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
const
users
:
any
=
await
dataSource
.
manager
.
find
(
User
)
const
users
:
any
=
await
dataSource
.
manager
.
find
(
User
)
...
...
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