Commit 9c65cae3 authored by “Yevgeniy's avatar “Yevgeniy

#8 added set up working credentials for base

parent c741d378
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
...@@ -44,17 +44,15 @@ export class User extends BaseEntity implements IUser { ...@@ -44,17 +44,15 @@ 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_name', type: 'varchar', length:30,nullable: false }) @Column({ name: 'displayName', 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()
...@@ -64,10 +62,13 @@ export class User extends BaseEntity implements IUser { ...@@ -64,10 +62,13 @@ export class User extends BaseEntity implements IUser {
@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
......
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment