├── .gitignore ├── BitCoin-Backend ├── .gitignore ├── index.js ├── nodemon.json ├── package.json ├── src │ ├── app │ │ ├── Modules │ │ │ ├── Bitcoin-module │ │ │ │ └── Database │ │ │ │ │ ├── database.module.ts │ │ │ │ │ └── database.provider.ts │ │ │ └── Users-module │ │ │ │ ├── Controllers │ │ │ │ ├── features.controller.ts │ │ │ │ ├── index.ts │ │ │ │ ├── login.controller.ts │ │ │ │ ├── loginHistory.controller.ts │ │ │ │ ├── roles.controller.ts │ │ │ │ └── users.controller.ts │ │ │ │ ├── DTO │ │ │ │ ├── features.dto.ts │ │ │ │ ├── index.ts │ │ │ │ ├── login.dto.ts │ │ │ │ ├── loginhistory.dto.ts │ │ │ │ ├── roles.dto.ts │ │ │ │ └── users.dto.ts │ │ │ │ ├── Database │ │ │ │ ├── database.module.ts │ │ │ │ └── database.provider.ts │ │ │ │ ├── Entities │ │ │ │ ├── Features.ts │ │ │ │ ├── Login.ts │ │ │ │ ├── LoginHistory.ts │ │ │ │ ├── Roles.ts │ │ │ │ └── Users.ts │ │ │ │ ├── Interfaces │ │ │ │ ├── IFeatures.service.ts │ │ │ │ ├── IFeatures.ts │ │ │ │ ├── ILogin.service.ts │ │ │ │ ├── ILogin.ts │ │ │ │ ├── ILoginHistory.service.ts │ │ │ │ ├── ILoginHistory.ts │ │ │ │ ├── IRoles.service.ts │ │ │ │ ├── IRoles.ts │ │ │ │ ├── IUsers.service.ts │ │ │ │ ├── IUsers.ts │ │ │ │ └── index.ts │ │ │ │ ├── Providers │ │ │ │ └── users.providers.ts │ │ │ │ ├── Services │ │ │ │ ├── features.service.ts │ │ │ │ ├── index.ts │ │ │ │ ├── login.service.ts │ │ │ │ ├── loginHistory.service.ts │ │ │ │ ├── roles.service.ts │ │ │ │ └── users.service.ts │ │ │ │ └── users.module.ts │ │ └── app.module.ts │ └── server.ts ├── tsconfig.json └── tslint.json ├── BitCoin-Frontend ├── .angular-cli.json ├── .editorconfig ├── .gitignore ├── README.md ├── e2e │ ├── app.e2e-spec.ts │ ├── app.po.ts │ └── tsconfig.e2e.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── protractor.conf.js ├── src │ ├── app │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── app.routing.ts │ │ ├── modules │ │ │ ├── bitcoin-module │ │ │ │ ├── bitcoin-module.ts │ │ │ │ ├── bitcoin-routing.ts │ │ │ │ ├── bitcoin.service.spec.ts │ │ │ │ ├── bitcoin.service.ts │ │ │ │ └── components │ │ │ │ │ ├── bitcoin.collection.ts │ │ │ │ │ ├── current-price │ │ │ │ │ ├── current-price.component.css │ │ │ │ │ ├── current-price.component.html │ │ │ │ │ ├── current-price.component.spec.ts │ │ │ │ │ └── current-price.component.ts │ │ │ │ │ └── history-price │ │ │ │ │ ├── history-price.component.css │ │ │ │ │ ├── history-price.component.html │ │ │ │ │ ├── history-price.component.spec.ts │ │ │ │ │ └── history-price.component.ts │ │ │ ├── manage-module │ │ │ │ ├── components │ │ │ │ │ ├── change-password │ │ │ │ │ │ ├── change-password.component.css │ │ │ │ │ │ ├── change-password.component.html │ │ │ │ │ │ ├── change-password.component.spec.ts │ │ │ │ │ │ └── change-password.component.ts │ │ │ │ │ ├── manage.collection.ts │ │ │ │ │ └── person-detail │ │ │ │ │ │ ├── person-detail.component.css │ │ │ │ │ │ ├── person-detail.component.html │ │ │ │ │ │ ├── person-detail.component.spec.ts │ │ │ │ │ │ └── person-detail.component.ts │ │ │ │ ├── manage-module.ts │ │ │ │ ├── manage-routing.ts │ │ │ │ ├── manage.service.spec.ts │ │ │ │ └── manage.service.ts │ │ │ └── page-module │ │ │ │ ├── page.component.css │ │ │ │ ├── page.component.html │ │ │ │ ├── page.component.spec.ts │ │ │ │ ├── page.component.ts │ │ │ │ ├── page.module.ts │ │ │ │ └── page.routing.ts │ │ └── shared │ │ │ ├── components │ │ │ ├── collection.ts │ │ │ ├── login │ │ │ │ ├── login.component.css │ │ │ │ ├── login.component.html │ │ │ │ ├── login.component.spec.ts │ │ │ │ └── login.component.ts │ │ │ └── templates │ │ │ │ ├── header │ │ │ │ ├── header.component.css │ │ │ │ ├── header.component.html │ │ │ │ ├── header.component.spec.ts │ │ │ │ └── header.component.ts │ │ │ │ ├── not-found │ │ │ │ ├── not-found.component.css │ │ │ │ ├── not-found.component.html │ │ │ │ ├── not-found.component.spec.ts │ │ │ │ └── not-found.component.ts │ │ │ │ └── side-menu │ │ │ │ ├── side-menu.component.css │ │ │ │ ├── side-menu.component.html │ │ │ │ ├── side-menu.component.spec.ts │ │ │ │ └── side-menu.component.ts │ │ │ ├── directives │ │ │ └── collection.ts │ │ │ ├── guards │ │ │ └── login.guard.ts │ │ │ ├── helpers │ │ │ ├── collection.ts │ │ │ ├── cookie-helper.service.spec.ts │ │ │ ├── cookie-helper.service.ts │ │ │ ├── http-helper.service.spec.ts │ │ │ └── http-helper.service.ts │ │ │ ├── models │ │ │ ├── collection.ts │ │ │ └── login-result.ts │ │ │ ├── services │ │ │ ├── auth.service.spec.ts │ │ │ ├── auth.service.ts │ │ │ ├── collection.ts │ │ │ ├── data-access.service.spec.ts │ │ │ └── data-access.service.ts │ │ │ ├── shared.modules.ts │ │ │ └── utils │ │ │ └── collections │ ├── assets │ │ └── .gitkeep │ ├── environments │ │ ├── environment.UAT.ts │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ ├── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.spec.json │ └── typings.d.ts ├── tsconfig.json └── tslint.json ├── ReadME.md ├── SQL └── CreateTable.sql └── ScreenShot ├── bitcoin_1.png ├── bitcoin_2.png └── bitcoin_3.png /.gitignore: -------------------------------------------------------------------------------- 1 | BitCoin-Backend/package-lock.json 2 | /BitCoin-Backend/README.md 3 | -------------------------------------------------------------------------------- /BitCoin-Backend/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /BitCoin-Backend/index.js: -------------------------------------------------------------------------------- 1 | require('ts-node/register'); 2 | require('./src/server'); 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BitCoin-Backend/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "node ./index" 6 | } 7 | -------------------------------------------------------------------------------- /BitCoin-Backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nest-typescript-starter", 3 | "version": "1.0.0", 4 | "description": "Nest TypeScript starter repository", 5 | "license": "MIT", 6 | "scripts": { 7 | "start": "node index.js", 8 | "start:watch": "nodemon", 9 | "prestart:prod": "tsc", 10 | "start:prod": "node dist/server.js" 11 | }, 12 | "dependencies": { 13 | "@nestjs/common": "^4.4.0", 14 | "@nestjs/core": "^4.4.0", 15 | "@nestjs/microservices": "^4.4.0", 16 | "@nestjs/swagger": "^1.1.3", 17 | "@nestjs/testing": "^4.4.0", 18 | "@nestjs/typeorm": "^1.0.1", 19 | "@nestjs/websockets": "^4.4.0", 20 | "@types/body-parser": "^1.16.8", 21 | "@types/express": "^4.0.39", 22 | "@types/sequelize": "^4.0.79", 23 | "body-parser": "^1.18.2", 24 | "moment": "^2.20.1", 25 | "moment-timezone": "^0.5.14", 26 | "mongoose": "^5.0.0-rc0", 27 | "mssql": "^4.1.0", 28 | "redis": "^2.7.1", 29 | "reflect-metadata": "^0.1.10", 30 | "rxjs": "^5.5.5", 31 | "sequelize": "^4.28.6", 32 | "sequelize-typescript": "^0.6.1", 33 | "typeorm": "^0.1.9" 34 | }, 35 | "devDependencies": { 36 | "@types/moment": "^2.13.0", 37 | "@types/mongoose": "^4.7.31", 38 | "@types/node": "^8.0.28", 39 | "nodemon": "^1.12.1", 40 | "ts-node": "^3.3.0", 41 | "typescript": "^2.6.2" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Bitcoin-module/Database/database.module.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Module } from '@nestjs/common'; 4 | import { databaseProviders } from './database.provider'; 5 | 6 | @Module({ 7 | components: [...databaseProviders], 8 | exports: [...databaseProviders] 9 | }) 10 | 11 | export class DatabaseModule { } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Bitcoin-module/Database/database.provider.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import * as mongoose from 'mongoose'; 4 | 5 | export const databaseProviders = [ 6 | { 7 | provide: 'MongoDBConnection', 8 | useFactory: async (): Promise => { 9 | (mongoose as any).Promise = global.Promise; 10 | return await mongoose.connect('mongodb://localhost:27017/IronManNest', { 11 | useMongoClient: true 12 | }) 13 | } 14 | } 15 | ] -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Controllers/features.controller.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Controller, Get, Response, HttpStatus, Param, Body, Post, Request, Patch, Delete } from '@nestjs/common'; 4 | import { FeaturesSerice } from '../Services/features.service'; 5 | import { FeaturesDTO } from '../DTO/index'; 6 | import * as moment from 'moment'; 7 | 8 | @Controller('features') 9 | export class FeaturesController { 10 | 11 | constructor(private readonly featuresSerice: FeaturesSerice) { } 12 | 13 | @Get() 14 | public async getRoles( @Response() res) { 15 | const features = await this.featuresSerice.findAll(); 16 | return res.status(HttpStatus.OK).json(features); 17 | } 18 | 19 | @Get('/find') 20 | public async findRole( @Response() res) { 21 | //給定where條件 22 | let queryCondition = { where: { Name: 'VIP' } }; 23 | const features = await this.featuresSerice.findOne(queryCondition); 24 | return res.status(HttpStatus.OK).json(features); 25 | } 26 | 27 | @Get('/:ID') 28 | public async getRole( @Response() res, @Param() param) { 29 | 30 | const features = await this.featuresSerice.findById(param.ID); 31 | return res.status(HttpStatus.OK).json(features); 32 | } 33 | 34 | @Post() 35 | public async createRole( @Response() res, @Body() featuresDTO: FeaturesDTO) { 36 | featuresDTO.CreateTime = moment().toDate(); 37 | featuresDTO.CreateUser = 'sa'; 38 | const features = await this.featuresSerice.create(featuresDTO); 39 | return res.status(HttpStatus.OK).json(features); 40 | } 41 | 42 | @Patch('/:ID') 43 | public async updateRole( @Param() param, @Response() res, @Body() featuresDTO: FeaturesDTO) { 44 | featuresDTO.ModifiedTime = moment().toDate(); 45 | featuresDTO.ModifiedUser = 'sa'; 46 | const features = await this.featuresSerice.update(param.ID, featuresDTO); 47 | return res.status(HttpStatus.OK).json(features); 48 | } 49 | 50 | @Delete('/:ID') 51 | public async deleteRole( @Param() param, @Response() res) { 52 | 53 | const features = await this.featuresSerice.delete(param.ID); 54 | return res.status(HttpStatus.OK).json(features); 55 | } 56 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Controllers/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export * from './features.controller'; 4 | export * from './login.controller'; 5 | export * from './roles.controller'; 6 | export * from './users.controller'; 7 | export * from './loginHistory.controller'; 8 | -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Controllers/login.controller.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Controller, Get, Response, HttpStatus, Param, Body, Post, Request, Patch, Delete } from '@nestjs/common'; 4 | import { LoginsService } from '../Services/login.service'; 5 | import { LoginDTO } from '../DTO/index'; 6 | import * as moment from 'moment'; 7 | 8 | @Controller('login') 9 | export class LoginController { 10 | 11 | constructor(private readonly loginSerice: LoginsService) { } 12 | 13 | @Get() 14 | public async getRoles( @Response() res) { 15 | const login = await this.loginSerice.findAll(); 16 | return res.status(HttpStatus.OK).json(login); 17 | } 18 | 19 | @Get('/find') 20 | public async findRole( @Response() res) { 21 | //給定where條件 22 | let queryCondition = { where: { Account: 'test' } }; 23 | const login = await this.loginSerice.findOne(queryCondition); 24 | return res.status(HttpStatus.OK).json(login); 25 | } 26 | 27 | @Get('/:ID') 28 | public async getRole( @Response() res, @Param() param) { 29 | 30 | const login = await this.loginSerice.findById(param.ID); 31 | return res.status(HttpStatus.OK).json(login); 32 | } 33 | 34 | @Post() 35 | public async createRole( @Response() res, @Body() loginDTO: LoginDTO) { 36 | loginDTO.CreateTime = moment().toDate(); 37 | loginDTO.CreateUser = 'sa'; 38 | const login = await this.loginSerice.create(loginDTO); 39 | return res.status(HttpStatus.OK).json(login); 40 | } 41 | 42 | @Patch('/:ID') 43 | public async updateRole( @Param() param, @Response() res, @Body() loginDTO: LoginDTO) { 44 | loginDTO.ModifiedTime = moment().toDate(); 45 | loginDTO.ModifiedUser = 'sa'; 46 | const login = await this.loginSerice.update(param.ID, loginDTO); 47 | return res.status(HttpStatus.OK).json(login); 48 | } 49 | 50 | @Delete('/:ID') 51 | public async deleteRole( @Param() param, @Response() res) { 52 | 53 | const login = await this.loginSerice.delete(param.ID); 54 | return res.status(HttpStatus.OK).json(login); 55 | } 56 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Controllers/loginHistory.controller.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Controller, Get, Response, HttpStatus, Param, Body, Post, Request, Patch, Delete } from '@nestjs/common'; 4 | import { LoginsHistoryService } from '../Services/index'; 5 | import { LoginHistoryDTO } from '../DTO/index'; 6 | import * as moment from 'moment'; 7 | 8 | @Controller('loginHistory') 9 | export class LoginHistoryController { 10 | 11 | constructor(private readonly loginHistoryService: LoginsHistoryService) { } 12 | 13 | @Get() 14 | public async getRoles( @Response() res) { 15 | const loginHistory = await this.loginHistoryService.findAll(); 16 | return res.status(HttpStatus.OK).json(loginHistory); 17 | } 18 | 19 | @Get('/find') 20 | public async findRole( @Response() res) { 21 | //給定where條件 22 | let queryCondition = { where: { UserID: 1} }; 23 | const loginHistory = await this.loginHistoryService.findOne(queryCondition); 24 | return res.status(HttpStatus.OK).json(loginHistory); 25 | } 26 | 27 | @Get('/:ID') 28 | public async getRole( @Response() res, @Param() param) { 29 | 30 | const loginHistory = await this.loginHistoryService.findById(param.ID); 31 | return res.status(HttpStatus.OK).json(loginHistory); 32 | } 33 | 34 | @Post() 35 | public async createRole( @Response() res, @Body() LoginHistoryDTO: LoginHistoryDTO) { 36 | LoginHistoryDTO.CreateTime = moment().toDate(); 37 | LoginHistoryDTO.CreateUser = 'sa'; 38 | const loginHistory = await this.loginHistoryService.create(LoginHistoryDTO); 39 | return res.status(HttpStatus.OK).json(loginHistory); 40 | } 41 | 42 | @Patch('/:ID') 43 | public async updateRole( @Param() param, @Response() res, @Body() LoginHistoryDTO: LoginHistoryDTO) { 44 | LoginHistoryDTO.ModifiedTime = moment().toDate(); 45 | LoginHistoryDTO.ModifiedUser = 'sa'; 46 | const loginHistory = await this.loginHistoryService.update(param.ID, LoginHistoryDTO); 47 | return res.status(HttpStatus.OK).json(loginHistory); 48 | } 49 | 50 | @Delete('/:ID') 51 | public async deleteRole( @Param() param, @Response() res) { 52 | 53 | const loginHistory = await this.loginHistoryService.delete(param.ID); 54 | return res.status(HttpStatus.OK).json(loginHistory); 55 | } 56 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Controllers/roles.controller.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Controller, Get, Response, HttpStatus, Param, Body, Post, Request, Patch, Delete } from '@nestjs/common'; 4 | import { RolesService } from '../Services/roles.service'; 5 | import { RolesDTO } from '../DTO/index'; 6 | import * as moment from 'moment'; 7 | 8 | @Controller('roles') 9 | export class RolesController { 10 | 11 | constructor(private readonly rolesService: RolesService) { } 12 | 13 | @Get() 14 | public async getRoles( @Response() res) { 15 | const roles = await this.rolesService.findAll(); 16 | return res.status(HttpStatus.OK).json(roles); 17 | } 18 | 19 | @Get('/find') 20 | public async findRole( @Response() res) { 21 | //給定where條件 22 | let queryCondition = { where: { Name: 'VIP' } }; 23 | const roles = await this.rolesService.findOne(queryCondition); 24 | return res.status(HttpStatus.OK).json(roles); 25 | } 26 | 27 | @Get('/:ID') 28 | public async getRole( @Response() res, @Param() param) { 29 | 30 | const roles = await this.rolesService.findById(param.ID); 31 | return res.status(HttpStatus.OK).json(roles); 32 | } 33 | 34 | @Post() 35 | public async createRole( @Response() res, @Body() rolesDTO: RolesDTO) { 36 | rolesDTO.CreateTime = moment().toDate(); 37 | rolesDTO.CreateUser = 'sa'; 38 | const roles = await this.rolesService.create(rolesDTO); 39 | return res.status(HttpStatus.OK).json(roles); 40 | } 41 | 42 | @Patch('/:ID') 43 | public async updateRole( @Param() param, @Response() res, @Body() rolesDTO: RolesDTO) { 44 | rolesDTO.ModifiedTime = moment().toDate(); 45 | rolesDTO.ModifiedUser = 'sa'; 46 | const roles = await this.rolesService.update(param.ID, rolesDTO); 47 | return res.status(HttpStatus.OK).json(roles); 48 | } 49 | 50 | @Delete('/:ID') 51 | public async deleteRole( @Param() param, @Response() res) { 52 | 53 | const roles = await this.rolesService.delete(param.ID); 54 | return res.status(HttpStatus.OK).json(roles); 55 | } 56 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Controllers/users.controller.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Controller, Get, Response, HttpStatus, Param, Body, Post, Request, Patch, Delete } from '@nestjs/common'; 4 | import { UsersServices } from '../Services/users.service'; 5 | import { UsersDTO } from '../DTO/index'; 6 | import * as moment from 'moment'; 7 | 8 | @Controller('users') 9 | export class UsersController { 10 | 11 | constructor(private readonly usersServices: UsersServices) { } 12 | 13 | @Get() 14 | public async getUsers( @Response() res) { 15 | const users = await this.usersServices.findAll(); 16 | return res.status(HttpStatus.OK).json(users); 17 | } 18 | 19 | @Get('/find') 20 | public async findUser( @Response() res) { 21 | //給定where條件 22 | let queryCondition = { where: { Name: 'Mary' } }; 23 | const users = await this.usersServices.findOne(queryCondition); 24 | return res.status(HttpStatus.OK).json(users); 25 | } 26 | 27 | @Get('/:ID') 28 | public async getUser( @Response() res, @Param() param) { 29 | 30 | const users = await this.usersServices.findById(param.ID); 31 | return res.status(HttpStatus.OK).json(users); 32 | } 33 | 34 | @Post() 35 | public async createUser( @Response() res, @Body() usersDTO: UsersDTO) { 36 | usersDTO.CreateTime =moment().toDate(); 37 | usersDTO.CreateUser = 'sa'; 38 | const users = await this.usersServices.create(usersDTO); 39 | return res.status(HttpStatus.OK).json(users); 40 | } 41 | 42 | @Patch('/:ID') 43 | public async updateUser( @Param() param, @Response() res, @Body() usersDTO: UsersDTO) { 44 | usersDTO.ModifiedTime=moment().toDate(); 45 | usersDTO.CreateUser = 'sa'; 46 | const users = await this.usersServices.update(param.ID, usersDTO); 47 | return res.status(HttpStatus.OK).json(users); 48 | } 49 | 50 | @Delete('/:ID') 51 | public async deleteUser( @Param() param, @Response() res) { 52 | 53 | const users = await this.usersServices.delete(param.ID); 54 | return res.status(HttpStatus.OK).json(users); 55 | } 56 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/DTO/features.dto.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface FeaturesDTO { 4 | ID: number; 5 | RoleID: number; 6 | Status: number; 7 | CanGetQuoteProice: number; 8 | CanGetHistoryProice: number; 9 | CanGetNews: number; 10 | CanChat: number; 11 | CreateTime: Date; 12 | CreateUser: string; 13 | ModifiedTime: Date; 14 | ModifiedUser: string; 15 | Remark: string; 16 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/DTO/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export * from './features.dto'; 4 | export * from './roles.dto'; 5 | export * from './users.dto'; 6 | export * from './login.dto'; 7 | export * from './loginHistory.dto'; -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/DTO/login.dto.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface LoginDTO { 4 | ID: number; 5 | UserID:number; 6 | Account:string; 7 | Password:string; 8 | Status:number; 9 | LastLoginTime:Date; 10 | LastLogoutTime:Date; 11 | CreateTime: Date; 12 | CreateUser: string; 13 | ModifiedTime: Date; 14 | ModifiedUser: string; 15 | Remark: string; 16 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/DTO/loginhistory.dto.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface LoginHistoryDTO { 4 | ID: number; 5 | UserID:number; 6 | LoginTime:Date; 7 | LogoutTime:Date; 8 | CreateTime: Date; 9 | CreateUser: string; 10 | ModifiedTime: Date; 11 | ModifiedUser: string; 12 | Remark: string; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/DTO/roles.dto.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface RolesDTO { 4 | ID: number; 5 | Name: string; 6 | Status: number; 7 | CreateTime: Date; 8 | CreateUser: string; 9 | ModifiedTime: Date; 10 | ModifiedUser: string; 11 | Remark: string; 12 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/DTO/users.dto.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface UsersDTO { 4 | ID: number; 5 | RoleID: number; 6 | Name: string; 7 | Birthday: Date; 8 | Email: string; 9 | OtherEmail: string; 10 | Phone: string; 11 | CreateTime: Date; 12 | CreateUser: string; 13 | ModifiedTime: Date; 14 | ModifiedUser: string; 15 | Remark: string; 16 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Database/database.module.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Module } from '@nestjs/common'; 4 | import { databaseProviders } from './database.provider'; 5 | 6 | @Module({ 7 | components: [...databaseProviders], 8 | exports: [...databaseProviders] 9 | }) 10 | 11 | export class DatabaseModule { } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Database/database.provider.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { createConnection } from 'typeorm'; 4 | import { Features } from '../../Users-module/Entities/Features'; 5 | import { Login } from '../../Users-module/Entities/Login'; 6 | import { LoginHistory } from '../../Users-module/Entities/LoginHistory'; 7 | import { Roles } from '../../Users-module/Entities/Roles'; 8 | import { Users } from '../../Users-module/Entities/Users'; 9 | 10 | export const databaseProviders = [ 11 | { 12 | provide: 'TypeORMToken', 13 | useFactory: async () => await createConnection({ 14 | type: 'mssql', 15 | host: 'localhost', 16 | port: 1433, 17 | username: 'sa', 18 | password: 'Aa123456', 19 | database: 'BitCoin', 20 | entities: [ 21 | __dirname + '/../Entities/*{.ts,.js}' 22 | ] 23 | }) 24 | } 25 | ] -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Entities/Features.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; 4 | 5 | @Entity('Features') 6 | export class Features { 7 | 8 | 9 | @Column("int",{ 10 | generated:true, 11 | nullable:false, 12 | primary:true, 13 | }) 14 | ID:number; 15 | 16 | 17 | @Column("int",{ 18 | nullable:true, 19 | }) 20 | RoleID:number; 21 | 22 | 23 | @Column("smallint",{ 24 | nullable:false, 25 | default:"((1))", 26 | }) 27 | Status:number; 28 | 29 | 30 | @Column("smallint",{ 31 | nullable:false, 32 | default:"((1))", 33 | }) 34 | CanGetQuoteProice:number; 35 | 36 | 37 | @Column("smallint",{ 38 | nullable:false, 39 | default:"((1))", 40 | }) 41 | CanGetHistoryProice:number; 42 | 43 | 44 | @Column("smallint",{ 45 | nullable:false, 46 | default:"((1))", 47 | }) 48 | CanGetNews:number; 49 | 50 | 51 | @Column("smallint",{ 52 | nullable:false, 53 | default:"((1))", 54 | }) 55 | CanChat:number; 56 | 57 | 58 | @Column("datetime",{ 59 | nullable:false, 60 | }) 61 | CreateTime:Date; 62 | 63 | 64 | @Column("varchar",{ 65 | nullable:false, 66 | length:50, 67 | }) 68 | CreateUser:string; 69 | 70 | 71 | @Column("datetime",{ 72 | nullable:true, 73 | }) 74 | ModifiedTime:Date; 75 | 76 | 77 | @Column("varchar",{ 78 | nullable:true, 79 | length:50, 80 | }) 81 | ModifiedUser:string; 82 | 83 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Entities/Login.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; 4 | 5 | @Entity('Login') 6 | export class Login { 7 | 8 | 9 | @Column("int",{ 10 | generated:true, 11 | nullable:false, 12 | primary:true, 13 | }) 14 | ID:number; 15 | 16 | 17 | @Column("int",{ 18 | nullable:false, 19 | }) 20 | UserID:number; 21 | 22 | 23 | @Column("varchar",{ 24 | nullable:false, 25 | length:50, 26 | }) 27 | Account:string; 28 | 29 | 30 | @Column("varchar",{ 31 | nullable:false, 32 | length:100, 33 | }) 34 | Password:string; 35 | 36 | 37 | @Column("smallint",{ 38 | nullable:false, 39 | default:"((1))", 40 | }) 41 | Status:number; 42 | 43 | 44 | @Column("datetime",{ 45 | nullable:true, 46 | }) 47 | LastLoginTime:Date; 48 | 49 | 50 | @Column("datetime",{ 51 | nullable:true, 52 | }) 53 | LastLogoutTime:Date; 54 | 55 | 56 | @Column("datetime",{ 57 | nullable:false, 58 | }) 59 | CreateTime:Date; 60 | 61 | 62 | @Column("varchar",{ 63 | nullable:false, 64 | length:50, 65 | }) 66 | CreateUser:string; 67 | 68 | 69 | @Column("datetime",{ 70 | nullable:true, 71 | }) 72 | ModifiedTime:Date; 73 | 74 | 75 | @Column("varchar",{ 76 | nullable:true, 77 | length:50, 78 | }) 79 | ModifiedUser:string; 80 | 81 | 82 | @Column("varchar",{ 83 | nullable:true, 84 | length:100, 85 | }) 86 | Remark:string; 87 | 88 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Entities/LoginHistory.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; 4 | 5 | @Entity('LoginHistory') 6 | export class LoginHistory { 7 | 8 | 9 | @Column("int",{ 10 | generated:true, 11 | nullable:false, 12 | primary:true, 13 | }) 14 | ID:number; 15 | 16 | 17 | @Column("int",{ 18 | nullable:false, 19 | }) 20 | UserID:number; 21 | 22 | 23 | @Column("datetime",{ 24 | nullable:true, 25 | }) 26 | LoginTime:Date; 27 | 28 | 29 | @Column("datetime",{ 30 | nullable:true, 31 | }) 32 | LogoutTime:Date; 33 | 34 | 35 | @Column("datetime",{ 36 | nullable:true, 37 | }) 38 | CreateTime:Date; 39 | 40 | 41 | @Column("varchar",{ 42 | nullable:true, 43 | length:50, 44 | }) 45 | CreateUser:string; 46 | 47 | 48 | @Column("datetime",{ 49 | nullable:true, 50 | }) 51 | ModifiedTime:Date; 52 | 53 | 54 | @Column("varchar",{ 55 | nullable:true, 56 | length:50, 57 | }) 58 | ModifiedUser:string; 59 | 60 | 61 | @Column("varchar",{ 62 | nullable:true, 63 | length:100, 64 | }) 65 | Remark:string; 66 | 67 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Entities/Roles.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; 4 | 5 | @Entity('Roles') 6 | export class Roles { 7 | 8 | 9 | @Column("int",{ 10 | generated:true, 11 | nullable:false, 12 | primary:true, 13 | }) 14 | ID:number; 15 | 16 | 17 | @Column("varchar",{ 18 | nullable:false, 19 | length:20, 20 | }) 21 | Name:string; 22 | 23 | 24 | @Column("smallint",{ 25 | nullable:false, 26 | default:"((1))", 27 | }) 28 | Status:number; 29 | 30 | 31 | @Column("datetime",{ 32 | nullable:false, 33 | }) 34 | CreateTime:Date; 35 | 36 | 37 | @Column("varchar",{ 38 | nullable:false, 39 | length:50, 40 | }) 41 | CreateUser:string; 42 | 43 | 44 | @Column("datetime",{ 45 | nullable:true, 46 | }) 47 | ModifiedTime:Date; 48 | 49 | 50 | @Column("varchar",{ 51 | nullable:true, 52 | length:50, 53 | }) 54 | ModifiedUser:string; 55 | 56 | 57 | @Column("varchar",{ 58 | nullable:true, 59 | length:100, 60 | }) 61 | Remark:string; 62 | 63 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Entities/Users.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; 4 | 5 | @Entity('Users') 6 | export class Users { 7 | 8 | 9 | @Column("int",{ 10 | generated:true, 11 | nullable:false, 12 | primary:true, 13 | }) 14 | ID:number; 15 | 16 | 17 | @Column("int",{ 18 | nullable:false, 19 | }) 20 | RoleID:number; 21 | 22 | 23 | @Column("varchar",{ 24 | nullable:false, 25 | length:50, 26 | }) 27 | Name:string; 28 | 29 | 30 | @Column("datetime",{ 31 | nullable:true, 32 | }) 33 | Birthday:Date; 34 | 35 | 36 | @Column("varchar",{ 37 | nullable:false, 38 | length:100, 39 | }) 40 | Email:string; 41 | 42 | 43 | @Column("varchar",{ 44 | nullable:true, 45 | length:100, 46 | }) 47 | OtherEmail:string; 48 | 49 | 50 | @Column("varchar",{ 51 | nullable:true, 52 | length:30, 53 | }) 54 | Phone:string; 55 | 56 | 57 | @Column("datetime",{ 58 | nullable:false, 59 | }) 60 | CreateTime:Date; 61 | 62 | 63 | @Column("varchar",{ 64 | nullable:false, 65 | length:50, 66 | }) 67 | CreateUser:string; 68 | 69 | 70 | @Column("datetime",{ 71 | nullable:true, 72 | }) 73 | ModifiedTime:Date; 74 | 75 | 76 | @Column("varchar",{ 77 | nullable:true, 78 | length:50, 79 | }) 80 | ModifiedUser:string; 81 | 82 | 83 | @Column("varchar",{ 84 | nullable:true, 85 | length:100, 86 | }) 87 | Remark:string; 88 | 89 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/IFeatures.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Features } from '../Entities/Features'; 4 | import { IFeatures } from './IFeatures'; 5 | 6 | export interface IFeaturesService { 7 | findAll(): Promise>; 8 | findById(ID: number): Promise; 9 | findOne(options: Object): Promise; 10 | create(roles: IFeatures): Promise; 11 | update(ID: number, newValue: IFeatures): Promise; 12 | delete(ID: number): Promise; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/IFeatures.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface IFeatures { 4 | readonly ID: number; 5 | readonly RoleID:number; 6 | readonly Status:number; 7 | readonly CanGetQuoteProice:number; 8 | readonly CanGetHistoryProice:number; 9 | readonly CanGetNews:number; 10 | readonly CanChat:number; 11 | readonly CreateTime: Date 12 | readonly CreateUser: string 13 | readonly ModifiedTime: Date 14 | readonly ModifiedUser: string 15 | readonly Remark: string 16 | 17 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/ILogin.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Login } from '../Entities/Login'; 4 | import { ILogin } from './ILogin'; 5 | 6 | export interface ILoginService { 7 | findAll(): Promise>; 8 | findById(ID: number): Promise; 9 | findOne(options: Object): Promise; 10 | create(login: ILogin): Promise; 11 | update(ID: number, newValue: ILogin): Promise; 12 | delete(ID: number): Promise; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/ILogin.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface ILogin { 4 | readonly ID: number; 5 | readonly UserID:number; 6 | readonly Account:string; 7 | readonly Password:string; 8 | readonly Status:number; 9 | readonly LastLoginTime:Date; 10 | readonly LastLogoutTime:Date; 11 | readonly CreateTime: Date; 12 | readonly CreateUser: string; 13 | readonly ModifiedTime: Date; 14 | readonly ModifiedUser: string; 15 | readonly Remark: string; 16 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/ILoginHistory.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { LoginHistory } from '../Entities/LoginHistory'; 4 | import { ILoginHistory } from './ILoginHistory'; 5 | 6 | export interface ILoginHistoryService { 7 | findAll(): Promise>; 8 | findById(ID: number): Promise; 9 | findOne(options: Object): Promise; 10 | create(loginHistory: ILoginHistory): Promise; 11 | update(ID: number, newValue: ILoginHistory): Promise; 12 | delete(ID: number): Promise; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/ILoginHistory.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface ILoginHistory { 4 | readonly ID: number; 5 | readonly UserID:number; 6 | readonly LoginTime:Date; 7 | readonly LogoutTime:Date; 8 | readonly CreateTime: Date; 9 | readonly CreateUser: string; 10 | readonly ModifiedTime: Date; 11 | readonly ModifiedUser: string; 12 | readonly Remark: string; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/IRoles.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Roles } from '../Entities/Roles'; 4 | import { IRoles } from './IRoles'; 5 | 6 | export interface IRolesService { 7 | findAll(): Promise>; 8 | findById(ID: number): Promise; 9 | findOne(options: Object): Promise; 10 | create(roles: IRoles): Promise; 11 | update(ID: number, newValue: IRoles): Promise; 12 | delete(ID: number): Promise; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/IRoles.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface IRoles { 4 | readonly ID: number; 5 | readonly Name: string 6 | readonly Status: number 7 | readonly CreateTime: Date 8 | readonly CreateUser: string 9 | readonly ModifiedTime: Date 10 | readonly ModifiedUser: string 11 | readonly Remark: string 12 | 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/IUsers.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Users } from '../Entities/Users'; 4 | import { IUsers } from './IUsers'; 5 | 6 | export interface IUsersService{ 7 | findAll(): Promise>; 8 | findById(ID: number): Promise; 9 | findOne(options: Object): Promise; 10 | create(users: IUsers): Promise; 11 | update(ID: number, newValue: IUsers): Promise; 12 | delete(ID: number): Promise; 13 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/IUsers.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export interface IUsers { 4 | readonly ID: number; 5 | readonly RoleID: number; 6 | readonly Name: string 7 | readonly Birthday: Date 8 | readonly Email: string 9 | readonly OtherEmail: string 10 | readonly Phone: string 11 | readonly CreateTime: Date 12 | readonly CreateUser: string 13 | readonly ModifiedTime: Date 14 | readonly ModifiedUser: string 15 | readonly Remark: string 16 | 17 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Interfaces/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export * from './IUsers'; 4 | export * from './IUsers.service'; 5 | export * from './IRoles'; 6 | export * from './IRoles.service'; 7 | export * from './IFeatures'; 8 | export * from './IFeatures.service'; 9 | export * from './ILogin'; 10 | export * from './ILogin.service'; 11 | export * from './ILoginHistory'; 12 | export * from './ILoginHistory.service'; -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Providers/users.providers.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Connection, Repository } from 'typeorm'; 4 | import { Features } from '../Entities/Features'; 5 | import { Login } from '../Entities/Login'; 6 | import { LoginHistory } from '../Entities/LoginHistory'; 7 | import { Roles } from '../Entities/Roles'; 8 | import { Users } from '../Entities/Users'; 9 | 10 | export const UsersProviders = [ 11 | { 12 | provide: 'FeaturesRepository', 13 | useFactory: (connction: Connection) => connction.getRepository(Features), 14 | inject: ['TypeORMToken'] 15 | }, 16 | { 17 | provide: 'LoginRepository', 18 | useFactory: (connction: Connection) => connction.getRepository(Login), 19 | inject: ['TypeORMToken'] 20 | }, 21 | { 22 | provide: 'LoginHistoryRepository', 23 | useFactory: (connction: Connection) => connction.getRepository(LoginHistory), 24 | inject: ['TypeORMToken'] 25 | }, 26 | { 27 | provide: 'RolesRepository', 28 | useFactory: (connction: Connection) => connction.getRepository(Roles), 29 | inject: ['TypeORMToken'] 30 | }, 31 | { 32 | provide: 'UsersRepository', 33 | useFactory: (connction: Connection) => connction.getRepository(Users), 34 | inject: ['TypeORMToken'] 35 | } 36 | 37 | ] -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Services/features.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Component, Inject } from '@nestjs/common'; 4 | import { Features } from '../Entities/Features'; 5 | import { IFeatures, IFeaturesService } from '../Interfaces/index'; 6 | import { Repository } from 'typeorm'; 7 | import { InjectRepository } from '@nestjs/typeorm'; 8 | 9 | @Component() 10 | export class FeaturesSerice implements IFeaturesService { 11 | constructor( 12 | @InjectRepository(Features) 13 | private readonly featuresRepository: Repository) { } 14 | 15 | public async findAll(): Promise> { 16 | return await this.featuresRepository.find(); 17 | } 18 | 19 | //findOne()可以加入各種option,以下示範常見的where 20 | //注意findOne() 找到一筆就會立即return data,不會繼續往下找。 21 | public async findOne(options: Object): Promise { 22 | return await this.featuresRepository.findOne(options); 23 | } 24 | 25 | //restful API很常用。 26 | public async findById(ID): Promise { 27 | return await this.featuresRepository.findOneById(ID); 28 | } 29 | 30 | public async create(features: IFeatures): Promise { 31 | return await this.featuresRepository.save(features); 32 | } 33 | 34 | public async update(ID: number, newValue: IFeatures): Promise { 35 | //先找出單筆資料 36 | let feature = await this.featuresRepository.findOneById(ID); 37 | //該筆資料不存在 38 | if (!feature.ID) { 39 | console.error("features doesn't exist"); 40 | } 41 | //呼叫feature Model的方法 42 | await this.featuresRepository.updateById(ID, newValue); 43 | return await this.featuresRepository.findOneById(ID); 44 | } 45 | 46 | public async delete(ID: number): Promise { 47 | //成功會回傳1,失敗回傳0 48 | await this.featuresRepository.deleteById(ID); 49 | let feature = await this.featuresRepository.findOneById(ID); 50 | if (!feature) { 51 | //刪除成功 52 | return 1; 53 | } 54 | else { 55 | //刪除失敗 56 | return 0; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Services/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export * from './features.service'; 4 | export * from './roles.service'; 5 | export * from './users.service'; 6 | export * from './login.service'; 7 | export * from './loginHistory.service'; -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Services/login.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Component, Inject } from '@nestjs/common'; 4 | import { Login } from '../Entities/Login'; 5 | import { ILogin, ILoginService } from '../Interfaces/index'; 6 | import { Repository } from 'typeorm'; 7 | import { InjectRepository } from '@nestjs/typeorm'; 8 | 9 | @Component() 10 | export class LoginsService implements ILoginService { 11 | constructor( 12 | @InjectRepository(Login) 13 | private readonly loginRepository: Repository) { } 14 | 15 | public async findAll(): Promise> { 16 | return await this.loginRepository.find(); 17 | } 18 | 19 | //findOne()可以加入各種option,以下示範常見的where 20 | //注意findOne() 找到一筆就會立即return data,不會繼續往下找。 21 | public async findOne(options: Object): Promise { 22 | return await this.loginRepository.findOne(options); 23 | } 24 | 25 | //restful API很常用。 26 | public async findById(ID): Promise { 27 | return await this.loginRepository.findOneById(ID); 28 | } 29 | 30 | public async create(login: ILogin): Promise { 31 | return await this.loginRepository.save(login); 32 | } 33 | 34 | public async update(ID: number, newValue: ILogin): Promise { 35 | //先找出單筆資料 36 | let feature = await this.loginRepository.findOneById(ID); 37 | //該筆資料不存在 38 | if (!feature.ID) { 39 | console.error("login doesn't exist"); 40 | } 41 | //呼叫feature Model的方法 42 | await this.loginRepository.updateById(ID, newValue); 43 | return await this.loginRepository.findOneById(ID); 44 | } 45 | 46 | public async delete(ID: number): Promise { 47 | //成功會回傳1,失敗回傳0 48 | await this.loginRepository.deleteById(ID); 49 | let feature = await this.loginRepository.findOneById(ID); 50 | if (!feature) { 51 | //刪除成功 52 | return 1; 53 | } 54 | else { 55 | //刪除失敗 56 | return 0; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Services/loginHistory.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Component, Inject } from '@nestjs/common'; 4 | import { LoginHistory } from '../Entities/LoginHistory'; 5 | import { ILoginHistory,ILoginHistoryService } from '../Interfaces/index'; 6 | import { Repository } from 'typeorm'; 7 | import { InjectRepository } from '@nestjs/typeorm'; 8 | 9 | @Component() 10 | export class LoginsHistoryService implements ILoginHistoryService { 11 | constructor( 12 | @InjectRepository(LoginHistory) 13 | private readonly loginHistoryRepository: Repository) { } 14 | 15 | public async findAll(): Promise> { 16 | return await this.loginHistoryRepository.find(); 17 | } 18 | 19 | //findOne()可以加入各種option,以下示範常見的where 20 | //注意findOne() 找到一筆就會立即return data,不會繼續往下找。 21 | public async findOne(options: Object): Promise { 22 | return await this.loginHistoryRepository.findOne(options); 23 | } 24 | 25 | //restful API很常用。 26 | public async findById(ID): Promise { 27 | return await this.loginHistoryRepository.findOneById(ID); 28 | } 29 | 30 | public async create(loginHistory: ILoginHistory): Promise { 31 | return await this.loginHistoryRepository.save(loginHistory); 32 | } 33 | 34 | public async update(ID: number, newValue: ILoginHistory): Promise { 35 | //先找出單筆資料 36 | let loginHistory = await this.loginHistoryRepository.findOneById(ID); 37 | //該筆資料不存在 38 | if (!loginHistory.ID) { 39 | console.error("loginHistory doesn't exist"); 40 | } 41 | //呼叫feature Model的方法 42 | await this.loginHistoryRepository.updateById(ID, newValue); 43 | return await this.loginHistoryRepository.findOneById(ID); 44 | } 45 | 46 | public async delete(ID: number): Promise { 47 | //成功會回傳1,失敗回傳0 48 | await this.loginHistoryRepository.deleteById(ID); 49 | let loginHistory = await this.loginHistoryRepository.findOneById(ID); 50 | if (!loginHistory) { 51 | //刪除成功 52 | return 1; 53 | } 54 | else { 55 | //刪除失敗 56 | return 0; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Services/roles.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Component, Inject } from '@nestjs/common'; 4 | import { Roles } from '../Entities/Roles'; 5 | import { IRoles, IRolesService } from '../Interfaces/index'; 6 | import { Repository } from 'typeorm'; 7 | import { InjectRepository } from '@nestjs/typeorm'; 8 | 9 | @Component() 10 | export class RolesService implements IRolesService { 11 | constructor( 12 | @InjectRepository(Roles) 13 | private readonly rolesRepository: Repository) { } 14 | 15 | public async findAll(): Promise> { 16 | return await this.rolesRepository.find(); 17 | } 18 | 19 | //findOne()可以加入各種option,以下示範常見的where 20 | //注意findOne() 找到一筆就會立即return data,不會繼續往下找。 21 | public async findOne(options: Object): Promise { 22 | return await this.rolesRepository.findOne(options); 23 | } 24 | 25 | //restful API很常用。 26 | public async findById(ID): Promise { 27 | return await this.rolesRepository.findOneById(ID); 28 | } 29 | 30 | public async create(roles: IRoles): Promise { 31 | return await this.rolesRepository.save(roles); 32 | } 33 | 34 | public async update(ID: number, newValue: IRoles): Promise { 35 | //先找出單筆資料 36 | let role = await this.rolesRepository.findOneById(ID); 37 | //該筆資料不存在 38 | if (!role.ID) { 39 | console.error("roles doesn't exist"); 40 | } 41 | //呼叫role Model的方法 42 | await this.rolesRepository.updateById(ID, newValue); 43 | return await this.rolesRepository.findOneById(ID); 44 | } 45 | 46 | public async delete(ID: number): Promise { 47 | //成功會回傳1,失敗回傳0 48 | await this.rolesRepository.deleteById(ID); 49 | let role = await this.rolesRepository.findOneById(ID); 50 | if (!role) { 51 | //刪除成功 52 | return 1; 53 | } 54 | else { 55 | //刪除失敗 56 | return 0; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/Services/users.service.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Component, Inject } from '@nestjs/common'; 4 | import { Users } from '../Entities/Users'; 5 | import { IUsers, IUsersService } from '../Interfaces/index'; 6 | import { Repository } from 'typeorm'; 7 | import { InjectRepository } from '@nestjs/typeorm'; 8 | 9 | @Component() 10 | export class UsersServices implements IUsersService { 11 | constructor( 12 | @InjectRepository(Users) 13 | private readonly usersRepository: Repository) { } 14 | 15 | public async findAll(): Promise> { 16 | return await this.usersRepository.find(); 17 | } 18 | 19 | //findOne()可以加入各種option,以下示範常見的where 20 | //注意findOne() 找到一筆就會立即return data,不會繼續往下找。 21 | public async findOne(options: Object): Promise { 22 | return await this.usersRepository.findOne(options); 23 | } 24 | 25 | //restful API很常用。 26 | public async findById(ID): Promise { 27 | return await this.usersRepository.findOneById(ID); 28 | } 29 | 30 | public async create(users: IUsers): Promise { 31 | return await this.usersRepository.save(users); 32 | } 33 | 34 | public async update(ID: number, newValue: IUsers): Promise { 35 | //先找出單筆資料 36 | let user = await this.usersRepository.findOneById(ID); 37 | //該筆資料不存在 38 | if (!user.ID) { 39 | console.error("user doesn't exist"); 40 | } 41 | //呼叫user Model的方法 42 | await this.usersRepository.updateById(ID, newValue); 43 | return await this.usersRepository.findOneById(ID); 44 | } 45 | 46 | public async delete(ID: number): Promise { 47 | //成功會回傳1,失敗回傳0 48 | await this.usersRepository.deleteById(ID); 49 | let user = await this.usersRepository.findOneById(ID); 50 | if (!user) { 51 | //刪除成功 52 | return 1; 53 | } 54 | else { 55 | //刪除失敗 56 | return 0; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/Modules/Users-module/users.module.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { Module } from '@nestjs/common'; 4 | import { DatabaseModule } from '../../Modules/Users-module/Database/database.module'; 5 | import { UsersProviders } from '../Users-module/Providers/users.providers'; 6 | import { UsersController,RolesController,FeaturesController, LoginController,LoginHistoryController } from './Controllers/index'; 7 | import { RolesService,FeaturesSerice,UsersServices, LoginsService, LoginsHistoryService } from './Services/index'; 8 | 9 | 10 | @Module({ 11 | modules: [DatabaseModule], 12 | controllers: [UsersController, RolesController, FeaturesController,LoginController,LoginHistoryController], 13 | components: [ 14 | UsersServices, 15 | RolesService, 16 | FeaturesSerice, 17 | LoginsService, 18 | LoginsHistoryService, 19 | ...UsersProviders 20 | ] 21 | }) 22 | 23 | export class UsersModule { } -------------------------------------------------------------------------------- /BitCoin-Backend/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UsersModule } from './Modules/Users-module/users.module'; 3 | 4 | @Module({ 5 | modules: [UsersModule] 6 | }) 7 | export class ApplicationModule { } 8 | -------------------------------------------------------------------------------- /BitCoin-Backend/src/server.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import * as express from 'express'; 3 | import * as bodyParser from 'body-parser'; 4 | import { ApplicationModule } from './app/app.module'; 5 | import { INestApplication } from '@nestjs/common'; 6 | 7 | async function bootstrap() { 8 | //創建express 實例 9 | const instance = express(); 10 | //middleware 11 | instance.use(bodyParser.json()); 12 | instance.use(bodyParser.urlencoded({ extended: false })); 13 | //NestFactory.create()接受一個模組引數,和一個可選的express實例引數,並返回Promise。 14 | const app = await NestFactory.create(ApplicationModule, instance); 15 | await app.listen(3000); 16 | } 17 | bootstrap(); 18 | -------------------------------------------------------------------------------- /BitCoin-Backend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": false, 5 | "noImplicitAny": false, 6 | "removeComments": true, 7 | "noLib": false, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es6", 11 | "sourceMap": true, 12 | "allowJs": true, 13 | "outDir": "./dist" 14 | }, 15 | "include": [ 16 | "src/**/*" 17 | ], 18 | "exclude": [ 19 | "node_modules", 20 | "**/*.spec.ts" 21 | ] 22 | } -------------------------------------------------------------------------------- /BitCoin-Backend/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "jsRules": { 7 | "no-unused-expression": true 8 | }, 9 | "rules": { 10 | "eofline": false, 11 | "quotemark": [ 12 | true, 13 | "single" 14 | ], 15 | "member-access": [ 16 | false 17 | ], 18 | "ordered-imports": [ 19 | false 20 | ], 21 | "max-line-length": [ 22 | 150 23 | ], 24 | "member-ordering": [ 25 | false 26 | ], 27 | "curly": false, 28 | "interface-name": [ 29 | false 30 | ], 31 | "array-type": [ 32 | false 33 | ], 34 | "no-empty-interface": false, 35 | "no-empty": false, 36 | "arrow-parens": false, 37 | "object-literal-sort-keys": false, 38 | "no-unused-expression": false, 39 | "max-classes-per-file": [ 40 | false 41 | ], 42 | "variable-name": [ 43 | false 44 | ], 45 | "one-line": [ 46 | false 47 | ], 48 | "one-variable-per-declaration": [ 49 | false 50 | ] 51 | }, 52 | "rulesDirectory": [] 53 | } -------------------------------------------------------------------------------- /BitCoin-Frontend/.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "bit-coin-frontend" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": [ 11 | "assets", 12 | "favicon.ico" 13 | ], 14 | "index": "index.html", 15 | "main": "main.ts", 16 | "polyfills": "polyfills.ts", 17 | "test": "test.ts", 18 | "tsconfig": "tsconfig.app.json", 19 | "testTsconfig": "tsconfig.spec.json", 20 | "prefix": "app", 21 | "styles": [ 22 | "styles.css" 23 | ], 24 | "scripts": [], 25 | "environmentSource": "environments/environment.ts", 26 | "environments": { 27 | "dev": "environments/environment.ts", 28 | "prod": "environments/environment.prod.ts" 29 | } 30 | } 31 | ], 32 | "e2e": { 33 | "protractor": { 34 | "config": "./protractor.conf.js" 35 | } 36 | }, 37 | "lint": [ 38 | { 39 | "project": "src/tsconfig.app.json", 40 | "exclude": "**/node_modules/**" 41 | }, 42 | { 43 | "project": "src/tsconfig.spec.json", 44 | "exclude": "**/node_modules/**" 45 | }, 46 | { 47 | "project": "e2e/tsconfig.e2e.json", 48 | "exclude": "**/node_modules/**" 49 | } 50 | ], 51 | "test": { 52 | "karma": { 53 | "config": "./karma.conf.js" 54 | } 55 | }, 56 | "defaults": { 57 | "styleExt": "css", 58 | "component": {} 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BitCoin-Frontend/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /BitCoin-Frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | # System Files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /BitCoin-Frontend/README.md: -------------------------------------------------------------------------------- 1 | # BitCoinFrontend 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /BitCoin-Frontend/e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('bit-coin-frontend App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /BitCoin-Frontend/e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BitCoin-Frontend/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "jasminewd2", 11 | "node" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BitCoin-Frontend/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular/cli'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular/cli/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | reports: [ 'html', 'lcovonly' ], 20 | fixWebpackSourcePaths: true 21 | }, 22 | angularCli: { 23 | environment: 'dev' 24 | }, 25 | reporters: ['progress', 'kjhtml'], 26 | port: 9876, 27 | colors: true, 28 | logLevel: config.LOG_INFO, 29 | autoWatch: true, 30 | browsers: ['Chrome'], 31 | singleRun: false 32 | }); 33 | }; 34 | -------------------------------------------------------------------------------- /BitCoin-Frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bit-coin-frontend", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build --prod", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "^5.0.0", 16 | "@angular/common": "^5.0.0", 17 | "@angular/compiler": "^5.0.0", 18 | "@angular/core": "^5.0.0", 19 | "@angular/forms": "^5.0.0", 20 | "@angular/http": "^5.0.0", 21 | "@angular/platform-browser": "^5.0.0", 22 | "@angular/platform-browser-dynamic": "^5.0.0", 23 | "@angular/router": "^5.0.0", 24 | "angular2-moment": "^1.7.1", 25 | "core-js": "^2.4.1", 26 | "ng-zorro-antd": "^0.6.8", 27 | "ngx-cookie": "^2.0.1", 28 | "ramda": "^0.25.0", 29 | "rxjs": "^5.5.2", 30 | "zone.js": "^0.8.14" 31 | }, 32 | "devDependencies": { 33 | "@angular/cli": "1.6.3", 34 | "@angular/compiler-cli": "^5.0.0", 35 | "@angular/language-service": "^5.0.0", 36 | "@types/jasmine": "~2.5.53", 37 | "@types/jasminewd2": "~2.0.2", 38 | "@types/node": "~6.0.60", 39 | "codelyzer": "^4.0.1", 40 | "jasmine-core": "~2.6.2", 41 | "jasmine-spec-reporter": "~4.1.0", 42 | "karma": "~1.7.0", 43 | "karma-chrome-launcher": "~2.1.1", 44 | "karma-cli": "~1.0.1", 45 | "karma-coverage-istanbul-reporter": "^1.2.1", 46 | "karma-jasmine": "~1.1.0", 47 | "karma-jasmine-html-reporter": "^0.2.2", 48 | "protractor": "~5.1.2", 49 | "ts-node": "~3.2.0", 50 | "tslint": "~5.7.0", 51 | "typescript": "~2.4.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /BitCoin-Frontend/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './e2e/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/app.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'app'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('app'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'app'; 10 | } 11 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { SharedModule } from './shared/shared.modules'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { BrowserModule } from '@angular/platform-browser'; 5 | import { HttpModule, RequestOptions, XHRBackend } from '@angular/http'; 6 | import { CookieModule } from 'ngx-cookie'; 7 | import { NgZorroAntdModule } from 'ng-zorro-antd'; 8 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 9 | 10 | import { AppComponent } from './app.component'; 11 | import { CurrentPriceComponent, HistoryPriceComponent } from './modules/bitcoin-module/components/bitcoin.collection'; 12 | 13 | import { AppRoutingModule } from './app.routing'; 14 | //helper層 15 | import { 16 | CookieHelperService, 17 | HttpHelperService 18 | } from './shared/helpers/collection'; 19 | 20 | //services層 21 | import { DataAccessService } from './shared/services/collection'; 22 | 23 | 24 | @NgModule({ 25 | bootstrap: [ 26 | AppComponent 27 | ], 28 | declarations: [ 29 | AppComponent, 30 | ], 31 | imports: [ 32 | FormsModule, 33 | BrowserModule, 34 | BrowserAnimationsModule, 35 | AppRoutingModule, 36 | CookieModule.forRoot(), 37 | NgZorroAntdModule.forRoot(), 38 | SharedModule 39 | ], 40 | providers: [ 41 | ] 42 | }) 43 | export class AppModule { } 44 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/app.routing.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule, Route } from '@angular/router'; 3 | import { ModuleWithProviders } from '@angular/core'; 4 | 5 | import { CurrentPriceComponent, HistoryPriceComponent } from './modules/bitcoin-module/components/bitcoin.collection'; 6 | import { BitcoinRoutingModule } from './modules/bitcoin-module/bitcoin-routing'; 7 | import { AppComponent } from './app.component'; 8 | import { LoginComponent } from './shared/components/login/login.component'; 9 | import { LoginGuard } from './shared/guards/login.guard'; 10 | 11 | const routes: Routes = [ 12 | //{ path: 'login', component: LoginComponent }, 13 | { 14 | path: '', component: AppComponent, 15 | loadChildren: 'app/modules/page-module/page.module#PageModule', 16 | //canActivate: [LoginGuard] 17 | }, 18 | { path: '**', redirectTo: 'login' } 19 | ]; 20 | 21 | @NgModule({ 22 | imports: [RouterModule.forRoot(routes)], 23 | exports: [RouterModule] 24 | }) 25 | export class AppRoutingModule { } 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/bitcoin-module.ts: -------------------------------------------------------------------------------- 1 | import { NgZorroAntdModule } from 'ng-zorro-antd'; 2 | import { CurrentPriceComponent, HistoryPriceComponent } from './components/bitcoin.collection'; 3 | import { NgModule } from '@angular/core'; 4 | import { SharedModule } from '../../shared/shared.modules'; 5 | import { BitcoinRoutingModule } from './bitcoin-routing'; 6 | 7 | @NgModule({ 8 | imports: [BitcoinRoutingModule, SharedModule], 9 | exports: [], 10 | declarations: [CurrentPriceComponent, HistoryPriceComponent], 11 | }) 12 | export class BitcoinModule { } -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/bitcoin-routing.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { CurrentPriceComponent, HistoryPriceComponent } from './components/bitcoin.collection'; 4 | 5 | const routes: Routes = [ 6 | { path: 'currentPrice', component: CurrentPriceComponent }, 7 | { path: 'historyPrice', component: HistoryPriceComponent } 8 | ]; 9 | 10 | @NgModule({ 11 | imports: [RouterModule.forChild(routes)], 12 | exports: [RouterModule], 13 | }) 14 | export class BitcoinRoutingModule { } 15 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/bitcoin.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { BitcoinService } from './bitcoin.service'; 4 | 5 | describe('BitcoinService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [BitcoinService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([BitcoinService], (service: BitcoinService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/bitcoin.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class BitcoinService { 5 | 6 | constructor() { } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/bitcoin.collection.ts: -------------------------------------------------------------------------------- 1 | export * from './current-price/current-price.component'; 2 | export * from './history-price/history-price.component'; -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/current-price/current-price.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/modules/bitcoin-module/components/current-price/current-price.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/current-price/current-price.component.html: -------------------------------------------------------------------------------- 1 |

2 | current-price works! 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/current-price/current-price.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CurrentPriceComponent } from './current-price.component'; 4 | 5 | describe('CurrentPriceComponent', () => { 6 | let component: CurrentPriceComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ CurrentPriceComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CurrentPriceComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/current-price/current-price.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-current-price', 5 | templateUrl: './current-price.component.html', 6 | styleUrls: ['./current-price.component.css'] 7 | }) 8 | export class CurrentPriceComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/history-price/history-price.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/modules/bitcoin-module/components/history-price/history-price.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/history-price/history-price.component.html: -------------------------------------------------------------------------------- 1 |

2 | history-price works! 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/history-price/history-price.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HistoryPriceComponent } from './history-price.component'; 4 | 5 | describe('HistoryPriceComponent', () => { 6 | let component: HistoryPriceComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ HistoryPriceComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(HistoryPriceComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/bitcoin-module/components/history-price/history-price.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-history-price', 5 | templateUrl: './history-price.component.html', 6 | styleUrls: ['./history-price.component.css'] 7 | }) 8 | export class HistoryPriceComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/change-password/change-password.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/modules/manage-module/components/change-password/change-password.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/change-password/change-password.component.html: -------------------------------------------------------------------------------- 1 |

2 | change-password works! 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/change-password/change-password.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ChangePasswordComponent } from './change-password.component'; 4 | 5 | describe('ChangePasswordComponent', () => { 6 | let component: ChangePasswordComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ChangePasswordComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ChangePasswordComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/change-password/change-password.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-change-password', 5 | templateUrl: './change-password.component.html', 6 | styleUrls: ['./change-password.component.css'] 7 | }) 8 | export class ChangePasswordComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/manage.collection.ts: -------------------------------------------------------------------------------- 1 | export * from './person-detail/person-detail.component'; 2 | export * from './change-password/change-password.component'; -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/person-detail/person-detail.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/modules/manage-module/components/person-detail/person-detail.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/person-detail/person-detail.component.html: -------------------------------------------------------------------------------- 1 |

2 | person-detail works! 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/person-detail/person-detail.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { PersonDetailComponent } from './person-detail.component'; 4 | 5 | describe('PersonDetailComponent', () => { 6 | let component: PersonDetailComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ PersonDetailComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(PersonDetailComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/components/person-detail/person-detail.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-person-detail', 5 | templateUrl: './person-detail.component.html', 6 | styleUrls: ['./person-detail.component.css'] 7 | }) 8 | export class PersonDetailComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/manage-module.ts: -------------------------------------------------------------------------------- 1 | import { NgZorroAntdModule } from 'ng-zorro-antd'; 2 | import { PersonDetailComponent,ChangePasswordComponent } from './components/manage.collection'; 3 | import { NgModule } from '@angular/core'; 4 | import { SharedModule } from '../../shared/shared.modules'; 5 | import { ManageRoutingModule } from './manage-routing'; 6 | 7 | @NgModule({ 8 | imports: [ManageRoutingModule, SharedModule], 9 | exports: [], 10 | declarations: [PersonDetailComponent,ChangePasswordComponent], 11 | }) 12 | export class ManageModule { } -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/manage-routing.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { PersonDetailComponent,ChangePasswordComponent } from './components/manage.collection'; 4 | 5 | const routes: Routes = [ 6 | { path: 'personDetail', component: PersonDetailComponent }, 7 | { path: 'changePassword', component: ChangePasswordComponent } 8 | ]; 9 | 10 | @NgModule({ 11 | imports: [RouterModule.forChild(routes)], 12 | exports: [RouterModule], 13 | }) 14 | export class ManageRoutingModule { } 15 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/manage.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { ManageService } from './manage.service'; 4 | 5 | describe('ManageService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [ManageService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([ManageService], (service: ManageService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/manage-module/manage.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class ManageService { 5 | 6 | constructor() { } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/page-module/page.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/modules/page-module/page.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/page-module/page.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/page-module/page.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { PageComponent } from './page.component'; 4 | 5 | describe('PageComponent', () => { 6 | let component: PageComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ PageComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(PageComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/page-module/page.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-page', 5 | templateUrl: './page.component.html', 6 | styleUrls: ['./page.component.css'] 7 | }) 8 | export class PageComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/page-module/page.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { PageComponent } from './page.component'; 3 | import { PageRoutingModule } from './page.routing'; 4 | import { NgZorroAntdModule } from 'ng-zorro-antd'; 5 | import { CommonModule } from '@angular/common'; 6 | import { SideMenuComponent,HeaderComponent } from '../../shared/components/collection'; 7 | 8 | @NgModule({ 9 | imports: [ 10 | CommonModule, 11 | PageRoutingModule, 12 | NgZorroAntdModule 13 | ], 14 | declarations: [ 15 | PageComponent, 16 | SideMenuComponent, 17 | HeaderComponent 18 | ], 19 | providers: [], 20 | exports: [] 21 | }) 22 | export class PageModule { } -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/modules/page-module/page.routing.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { PageComponent } from './page.component'; 4 | import { NotFoundComponent } from '../../shared/components/collection'; 5 | 6 | const routes: Routes = [ 7 | { 8 | path: '', component: PageComponent 9 | }, 10 | { 11 | path: 'bitcoin', component: PageComponent, 12 | loadChildren: 'app/modules/bitcoin-module/bitcoin-module#BitcoinModule' 13 | }, 14 | { 15 | path: 'manage', component: PageComponent, 16 | loadChildren: 'app/modules/manage-module/manage-module#ManageModule' 17 | }, 18 | { path: '**', redirectTo: '' } 19 | ] 20 | 21 | @NgModule({ 22 | imports: [RouterModule.forChild(routes)], 23 | exports: [RouterModule] 24 | }) 25 | 26 | export class PageRoutingModule { } -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/collection.ts: -------------------------------------------------------------------------------- 1 | export * from './templates/not-found/not-found.component'; 2 | export * from './templates/side-menu/side-menu.component'; 3 | export * from './templates/header/header.component'; -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/login/login.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/components/login/login.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/login/login.component.html: -------------------------------------------------------------------------------- 1 |

2 | login works! 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ LoginComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(LoginComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/login/login.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-login', 5 | templateUrl: './login.component.html', 6 | styleUrls: ['./login.component.css'] 7 | }) 8 | export class LoginComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/header/header.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/components/templates/header/header.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/header/header.component.html: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/header/header.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HeaderComponent } from './header.component'; 4 | 5 | describe('HeaderComponent', () => { 6 | let component: HeaderComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ HeaderComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(HeaderComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/header/header.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-header', 5 | templateUrl: './header.component.html', 6 | styleUrls: ['./header.component.css'] 7 | }) 8 | export class HeaderComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/not-found/not-found.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/components/templates/not-found/not-found.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/not-found/not-found.component.html: -------------------------------------------------------------------------------- 1 |

2 | not-found works! 3 |

4 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/not-found/not-found.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NotFoundComponent } from './not-found.component'; 4 | 5 | describe('NotFoundComponent', () => { 6 | let component: NotFoundComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ NotFoundComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NotFoundComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/not-found/not-found.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-not-found', 5 | templateUrl: './not-found.component.html', 6 | styleUrls: ['./not-found.component.css'] 7 | }) 8 | export class NotFoundComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/side-menu/side-menu.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/components/templates/side-menu/side-menu.component.css -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/side-menu/side-menu.component.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 | 4 | 比特幣 5 |
      6 |
    • 即時報價
    • 7 |
    • 歷史報價
    • 8 |
    9 |
  • 10 |
  • 11 | 12 | 會員管理 13 |
      14 |
    • 修改個人資料
    • 15 |
    • 修改密碼
    • 16 |
    17 |
  • 18 |
  • 19 | 20 | 系統設定 21 |
      22 |
    • 登出
    • 23 |
    24 |
  • 25 |
26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/side-menu/side-menu.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { SideMenuComponent } from './side-menu.component'; 4 | 5 | describe('SideMenuComponent', () => { 6 | let component: SideMenuComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ SideMenuComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(SideMenuComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/components/templates/side-menu/side-menu.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { AuthService } from '../../../services/collection'; 3 | 4 | @Component({ 5 | selector: 'app-side-menu', 6 | templateUrl: './side-menu.component.html', 7 | styleUrls: ['./side-menu.component.css'] 8 | }) 9 | export class SideMenuComponent implements OnInit { 10 | 11 | public clientOnlineList = 'client/onlineList'; 12 | public clientAccountFeatures = 'client/accountFeatures'; 13 | public clientLoginRecord = 'client/loginRecord'; 14 | 15 | constructor(private auth: AuthService) { } 16 | 17 | ngOnInit() { 18 | } 19 | 20 | logout() { 21 | this.auth.logout(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/directives/collection.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/directives/collection.ts -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/guards/login.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router } from '@angular/router'; 3 | import { AuthService } from '../services/collection'; 4 | 5 | @Injectable() 6 | export class LoginGuard implements CanActivate { 7 | constructor(private auth: AuthService, private router: Router) { } 8 | 9 | canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { 10 | return this.auth.isAuth().do(result => { 11 | if (!result) { 12 | this.router.navigateByUrl('/login'); 13 | } 14 | }); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/helpers/collection.ts: -------------------------------------------------------------------------------- 1 | export * from './cookie-helper.service'; 2 | export * from './http-helper.service'; -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/helpers/cookie-helper.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { CookieHelperService } from './cookie-helper.service'; 4 | 5 | describe('CookieHelperService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [CookieHelperService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([CookieHelperService], (service: CookieHelperService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/helpers/cookie-helper.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { CookieService } from 'ngx-cookie'; 3 | 4 | @Injectable() 5 | export class CookieHelperService { 6 | 7 | constructor(private cookieService: CookieService) { } 8 | 9 | /**@function 取得cookie公用方法 10 | * @param key @type {string} cookie key 11 | * @returns return cookie 值 12 | */ 13 | getCookie(key: string): string { 14 | return this.cookieService.get(key); 15 | } 16 | /**@function 給定cookie公用方法 17 | * @param key @type {string} cookie key 18 | * @param value @type {string} cookie value 19 | * @returns return void 20 | */ 21 | setCookie(key: string, value: string): void { 22 | return this.cookieService.put(key, value); 23 | } 24 | /**@function 移除cookie公用方法 25 | * @param key @type {string} cookie key 26 | * @returns return void 27 | */ 28 | removeCookie(key: string): void { 29 | return this.cookieService.remove(key); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/helpers/http-helper.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { HttpHelperService } from './http-helper.service'; 4 | 5 | describe('HttpHelperService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [HttpHelperService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([HttpHelperService], (service: HttpHelperService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/helpers/http-helper.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Http, XHRBackend, RequestOptions, Request, RequestOptionsArgs, Response, Headers } from '@angular/http'; 3 | import { Observable } from 'rxjs/Observable'; 4 | import 'rxjs/add/operator/map'; 5 | import 'rxjs/add/operator/catch'; 6 | 7 | @Injectable() 8 | export class HttpHelperService extends Http { 9 | 10 | constructor(backend: XHRBackend, options: RequestOptions) { 11 | super(backend, options); 12 | } 13 | 14 | /**@function 取得cookie方法 15 | * @param key @type {string} cookie key 16 | * @returns return cookie 值 17 | */ 18 | private getCookie(key: string) { 19 | let ca: string[] = document.cookie.split(';'); 20 | let caLen: number = ca.length; 21 | let cookieName = `${key}=`; 22 | let c: string; 23 | 24 | for (let i: number = 0; i < caLen; i += 1) { 25 | c = ca[i].replace(/^\s+/g, ''); 26 | if (c.indexOf(cookieName) == 0) { 27 | return c.substring(cookieName.length, c.length); 28 | } 29 | } 30 | return ''; 31 | } 32 | 33 | /**@function http請求公用方法 34 | * @description 任何http請求的表頭都加上token 35 | * @param url @type {string} 請求路徑 36 | * @param options @type {RequestOptionsArgs} 可有可無http表頭參數 37 | * @returns return http request Observable物件 38 | */ 39 | 40 | request(url: string | Request, options?: RequestOptionsArgs): Observable { 41 | //任何http請求的表頭都加上token 42 | let token = this.getCookie('token'); 43 | if (typeof url === 'string') { // meaning we have to add the token to the options, not in url 44 | if (!options) { 45 | // let's make option object 46 | options = { headers: new Headers() }; 47 | } 48 | options.headers.set('Content-Type', 'application/json'); 49 | options.headers.set('token', `${token}`); 50 | } else { 51 | // we have to add the token to the url object 52 | url.headers.set('Content-Type', 'application/json'); 53 | url.headers.set('token', `${token}`); 54 | } 55 | return super.request(url, options).catch(this.catchAuthError(this)); 56 | } 57 | /**@function 捕捉驗證失敗公用方法 58 | * @param self @type {HttpService} 59 | * @return return 錯誤訊息 60 | */ 61 | private catchAuthError(self: HttpHelperService) { 62 | // we have to pass HttpService's own instance here as `self` 63 | return (res: Response) => { 64 | console.log(res); 65 | if (res.status === 401 || res.status === 403) { 66 | // if not authenticated 67 | console.log(res); 68 | } 69 | return Observable.throw(res); 70 | }; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/models/collection.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/models/collection.ts -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/models/login-result.ts: -------------------------------------------------------------------------------- 1 | export class LoginResult { 2 | title: string; 3 | result: boolean; 4 | message: string; 5 | role: string; 6 | token: string; 7 | } 8 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/services/auth.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { AuthService } from './auth.service'; 4 | 5 | describe('AuthService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [AuthService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([AuthService], (service: AuthService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/services/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Observable } from 'rxjs/Observable'; 3 | import 'rxjs/add/operator/do'; 4 | import 'rxjs/add/observable/of'; 5 | import 'rxjs/add/observable/throw'; 6 | import { HttpClient } from '@angular/common/http'; 7 | import { LoginResult } from '../models/login-result'; 8 | import { environment } from '../../../environments/environment'; 9 | import { DataAccessService } from './data-access.service'; 10 | import { CookieHelperService } from '../helpers/collection'; 11 | import { Router } from '@angular/router'; 12 | 13 | @Injectable() 14 | export class AuthService { 15 | constructor( 16 | private http: HttpClient, 17 | private dataAccess: DataAccessService, 18 | private cookie: CookieHelperService, 19 | private router: Router 20 | ) { } 21 | 22 | login(loginId: string, password: string): Observable { 23 | return this.http.post(`${environment.RestApiIP}/login`, { LoginID: loginId.trim(), Password: password.trim() }) 24 | .do(res => { 25 | this.cookie.setCookie('token', res.token); 26 | this.cookie.setCookie('role', res.role); 27 | }) 28 | .catch(this.dataAccess.handleError); 29 | } 30 | 31 | logout() { 32 | this.cookie.removeCookie('token'); 33 | this.cookie.removeCookie('role'); 34 | this.router.navigateByUrl('/login'); 35 | } 36 | 37 | isAuth(): Observable { 38 | // TODO: 驗證登入狀態 ( cookie 有值 && call api 驗證 token 有効) 39 | if (this.cookie.getCookie('token') && this.cookie.getCookie('role')) { 40 | return Observable.of(true); 41 | } else { 42 | return Observable.of(false); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/services/collection.ts: -------------------------------------------------------------------------------- 1 | export * from './data-access.service'; 2 | export * from './auth.service'; -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/services/data-access.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { DataAccessService } from './data-access.service'; 4 | 5 | describe('DataAccessService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [DataAccessService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([DataAccessService], (service: DataAccessService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/services/data-access.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Http, RequestOptions, Response, Headers, ResponseContentType } from '@angular/http'; 3 | import { Observable } from 'rxjs/Observable'; 4 | import 'rxjs/add/observable/throw'; 5 | import { CookieHelperService } from '../helpers/cookie-helper.service'; 6 | import { HttpHelperService } from '../helpers/http-helper.service'; 7 | import { environment } from '../../../environments/environment'; 8 | import * as contentDisposition from 'content-disposition'; 9 | import * as R from 'ramda'; 10 | 11 | @Injectable() 12 | export class DataAccessService { 13 | 14 | constructor(private http: HttpHelperService, private cookieMethodService: CookieHelperService) { } 15 | 16 | private resultData: any[];//結果陣列 17 | private ASID: string = this.cookieMethodService.getCookie('ASID');//重要且必帶回中間層的參數 18 | private headers: Headers = new Headers({ 19 | 'Content-Type': 'application/json;charset=utf-8', 20 | 'Pragma': 'no-cache', 21 | 'Cache-Control': 'no-cache' 22 | }); 23 | private options: RequestOptions = new RequestOptions({ headers: this.headers }); 24 | 25 | /**@function 捕捉錯誤方法 26 | * @param error @type {any} 錯誤 27 | * @returns @description return錯誤訊息 28 | */ 29 | handleError(errorResponse) { 30 | let errObj; 31 | try { 32 | let resObj = errorResponse.json(); 33 | errObj = resObj.error; 34 | } catch (ex1) { 35 | try { 36 | errObj = errorResponse.error.error; 37 | } catch (ex2) { 38 | let errMsg = `${errorResponse.status} - ${errorResponse.statusText}`; 39 | console.error(errMsg); // console show錯誤訊息 40 | return Observable.throw(errMsg); 41 | } 42 | } 43 | 44 | let errMsg = errObj && !R.isEmpty(errObj) 45 | ? `${errObj.CSmessage} (error: ${errObj.errCode})` 46 | : errorResponse.status 47 | ? `${errorResponse.status} - ${errorResponse.statusText}` 48 | : 'Server error'; 49 | console.error(errMsg); // console show錯誤訊息 50 | return Observable.throw(errMsg); 51 | } 52 | /**@function 呼叫中間層公用方法 53 | * @param input @type {object} 第一階段的input 54 | * @param url @type {string} 呼叫restful API的route 55 | * @returns @description return 來自中間層的json物件 56 | */ 57 | getData(url: string): Observable { 58 | // 呼叫restful API 59 | return this.http.get(`${environment.RestApiIP}${url}`, this.options) 60 | .map((response: Response) => { 61 | this.resultData = response.json(); 62 | return this.resultData; 63 | }) 64 | .catch(this.handleError); 65 | } 66 | postData(input: object, url: string): Observable { 67 | // 呼叫restful API 68 | return this.http.post(`${environment.RestApiIP}${url}`, input, this.options) 69 | .map((response: Response) => { 70 | this.resultData = response.json(); 71 | return this.resultData; 72 | }) 73 | .catch(this.handleError); 74 | } 75 | 76 | patchData(input: object, url: string): Observable { 77 | // 呼叫restful API 78 | return this.http.patch(`${environment.RestApiIP}${url}`, input, this.options) 79 | .map((response: Response) => { 80 | this.resultData = response.json(); 81 | return this.resultData; 82 | }) 83 | .catch(this.handleError); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/shared.modules.ts: -------------------------------------------------------------------------------- 1 | import { LoginComponent } from './components/login/login.component'; 2 | import { NgZorroAntdModule } from 'ng-zorro-antd'; 3 | import { NgModule } from '@angular/core'; 4 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 5 | import { HttpModule } from '@angular/http'; 6 | import { CommonModule } from '@angular/common'; 7 | import { MomentModule } from 'angular2-moment'; 8 | import { DataAccessService, AuthService } from './services/collection'; 9 | import { HttpHelperService, CookieHelperService } from './helpers/collection'; 10 | import { HttpClientModule } from '@angular/common/http'; 11 | import { LoginGuard } from './guards/login.guard'; 12 | import { NotFoundComponent } from './components/collection'; 13 | 14 | const modules = [ 15 | HttpModule, 16 | HttpClientModule, 17 | FormsModule, 18 | CommonModule, 19 | ReactiveFormsModule, 20 | NgZorroAntdModule, 21 | MomentModule 22 | ]; 23 | 24 | const components = [ 25 | LoginComponent, 26 | NotFoundComponent 27 | ]; 28 | 29 | 30 | const services = [ 31 | AuthService, 32 | DataAccessService, 33 | HttpHelperService, 34 | CookieHelperService 35 | ]; 36 | 37 | const guards = [ 38 | LoginGuard 39 | ]; 40 | 41 | @NgModule({ 42 | imports: [ 43 | ...modules 44 | ], 45 | declarations: [ 46 | ...components, 47 | ], 48 | providers: [ 49 | ...services, 50 | ...guards 51 | ], 52 | exports: [ 53 | ...components, 54 | ...modules 55 | ] 56 | }) 57 | export class SharedModule { } 58 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/app/shared/utils/collections: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/app/shared/utils/collections -------------------------------------------------------------------------------- /BitCoin-Frontend/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/assets/.gitkeep -------------------------------------------------------------------------------- /BitCoin-Frontend/src/environments/environment.UAT.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false, 8 | RestApiIP: 'http://localhost:3000', 9 | SocketServer: 'http://localhost:3000' 10 | }; 11 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | // 上線時請再改成正試機 4 | RestApiIP: 'http://localhost:3000', 5 | SocketServer: 'http://localhost:3000' 6 | }; 7 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false, 8 | RestApiIP: 'http://localhost:3000', 9 | SocketServer: 'http://localhost:3000' 10 | }; 11 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/BitCoin-Frontend/src/favicon.ico -------------------------------------------------------------------------------- /BitCoin-Frontend/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BitCoinFrontend 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Required to support Web Animations `@angular/platform-browser/animations`. 51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 52 | **/ 53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 54 | 55 | 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js/dist/zone'; // Included with Angular CLI. 61 | 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | import { getTestBed } from '@angular/core/testing'; 10 | import { 11 | BrowserDynamicTestingModule, 12 | platformBrowserDynamicTesting 13 | } from '@angular/platform-browser-dynamic/testing'; 14 | 15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 16 | declare const __karma__: any; 17 | declare const require: any; 18 | 19 | // Prevent Karma from running prematurely. 20 | __karma__.loaded = function () {}; 21 | 22 | // First, initialize the Angular testing environment. 23 | getTestBed().initTestEnvironment( 24 | BrowserDynamicTestingModule, 25 | platformBrowserDynamicTesting() 26 | ); 27 | // Then we find all the tests. 28 | const context = require.context('./', true, /\.spec\.ts$/); 29 | // And load the modules. 30 | context.keys().map(context); 31 | // Finally, start Karma to run the tests. 32 | __karma__.start(); 33 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | }, 13 | "files": [ 14 | "test.ts" 15 | ], 16 | "include": [ 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /BitCoin-Frontend/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /BitCoin-Frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ], 14 | "lib": [ 15 | "es2017", 16 | "dom" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BitCoin-Frontend/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs", 22 | "rxjs/Rx" 23 | ], 24 | "import-spacing": true, 25 | "indent": [ 26 | true, 27 | "spaces" 28 | ], 29 | "interface-over-type-literal": true, 30 | "label-position": true, 31 | "max-line-length": [ 32 | true, 33 | 140 34 | ], 35 | "member-access": false, 36 | "member-ordering": [ 37 | true, 38 | { 39 | "order": [ 40 | "static-field", 41 | "instance-field", 42 | "static-method", 43 | "instance-method" 44 | ] 45 | } 46 | ], 47 | "no-arg": true, 48 | "no-bitwise": true, 49 | "no-console": [ 50 | true, 51 | "debug", 52 | "info", 53 | "time", 54 | "timeEnd", 55 | "trace" 56 | ], 57 | "no-construct": true, 58 | "no-debugger": true, 59 | "no-duplicate-super": true, 60 | "no-empty": false, 61 | "no-empty-interface": true, 62 | "no-eval": true, 63 | "no-inferrable-types": [ 64 | true, 65 | "ignore-params" 66 | ], 67 | "no-misused-new": true, 68 | "no-non-null-assertion": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "typeof-compare": true, 111 | "unified-signatures": true, 112 | "variable-name": false, 113 | "whitespace": [ 114 | true, 115 | "check-branch", 116 | "check-decl", 117 | "check-operator", 118 | "check-separator", 119 | "check-type" 120 | ], 121 | "directive-selector": [ 122 | true, 123 | "attribute", 124 | "app", 125 | "camelCase" 126 | ], 127 | "component-selector": [ 128 | true, 129 | "element", 130 | "app", 131 | "kebab-case" 132 | ], 133 | "no-output-on-prefix": true, 134 | "use-input-property-decorator": true, 135 | "use-output-property-decorator": true, 136 | "use-host-property-decorator": true, 137 | "no-input-rename": true, 138 | "no-output-rename": true, 139 | "use-life-cycle-interface": true, 140 | "use-pipe-transform-interface": true, 141 | "component-class-suffix": true, 142 | "directive-class-suffix": true 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /ReadME.md: -------------------------------------------------------------------------------- 1 | ## 比特幣即時看盤網站 2 | > 距離鐵人比賽結束剩下5天,不過這次要實作的網站會花超過5天才能完成,而且程式碼應該不少,比賽結束後就請轉看我[github上的專案](https://github.com/m24927605/Nest-Virtual-Currency),這次點的科技樹是整合之前所學,做一個功能完整的網站。 3 | 4 | ## 需求規劃 5 | 1. 比特幣Realtime報價 6 | 2. 比特幣歷史報價 7 | 3. 比特幣走勢線圖 8 | 4. 會員管理 9 | 5. 比特幣新聞 10 | 6. 聊天室 11 | 12 | ## 資料表規劃 13 | **MSSQL** 14 | 1. Features Table 15 | 2. Login Table 16 | 3. LoginHistory Table 17 | 4. Roles Table 18 | 5. Users Table 19 | ## 系統功能分析 20 | 21 | * 比特幣Realtime報價: 22 | 1. 正式資源:https://www.coindesk.com/api/ 23 | 2. 備用資源:https://www.bitstamp.net/api/ 24 | 3. 實作方式:[Nestjs](https://nestjs.com/)後端固定頻率請求資源,存入[MongoDB](https://www.mongodb.com/),並透過[Socket.IO](https://socket.io/)與[Angular](https://angular.io/)前端建立Realtime連線提供資料。 25 | 26 | * 比特幣歷史報價 27 | 1. 正式資源:https://api.coindesk.com/v1/bpi/historical/close.json 28 | 2. 備用資源:https://github.com/f1lt3r/bitcoin-scraper 29 | 3. 實作方式:[Nestjs](https://nestjs.com/)後端先寫入所有歷史資料到[MongoDB](https://www.mongodb.com/),然後每天將新的歷史報價寫入[MongoDB](https://www.mongodb.com/),並透過[Socket.IO](https://socket.io/)與[Angular](https://angular.io/)前端建立Realtime連線提供資料。 30 | 31 | * 會員管理 32 | 1. 功能:註冊帳號、第三方登錄、修改個人基本資料、權限區分 33 | 2. 實作方式:[Nestjs](https://nestjs.com/)後端產Restful API給[Angular](https://angular.io/)前端串接,前後端皆要做好Route與權限保護,使用[JWT Token](https://jwt.io/)做網站驗證保護。 34 | * 比特幣新聞 35 | 1. 正式資源: 36 | 37 | * [https://chroniclingamerica.loc.gov/about/api/](https://chroniclingamerica.loc.gov/about/api/) 38 | * [https://github.com/feedbin/feedbin-api](https://github.com/feedbin/feedbin-api) 39 | * [https://developer.nytimes.com/](https://developer.nytimes.com/ ) 40 | * [https://newsapi.org/](https://newsapi.org/) 41 | * [https://dev.npr.org/api/](https://dev.npr.org/api/) 42 | * [http://open-platform.theguardian.com/](http://open-platform.theguardian.com/) 43 | 2. 備用資源:正式資源即備用資源。 44 | * 聊天室 45 | 1. 功能:登入後提供聊天室功能,聊天紀錄寫入[Redis](https://redis.io/)。 46 | 2. 實作方式:使用[Socket.IO](https://socket.io/)。 47 | 48 | ## 使用到的框架、資料庫、模組 49 | 1. 框架: 50 | * 後端框架:[Nestjs](https://nestjs.com/)(含[Express](http://expressjs.com/zh-tw/)) 51 | * 前端框架:[Angular](https://angular.io/) 52 | * UI框架:[NG-ZORRO](https://ng.ant.design/#/docs/angular/introduce) 53 | 2. 資料庫: 54 | * MSSQL 55 | * MongoDB 56 | * Redis(不是資料庫,但作用類似故分類在此) 57 | 3. 模組: 58 | * [Socket.IO](https://www.npmjs.com/package/socket.io)(Realtime) 59 | * [TypeORM](https://www.npmjs.com/package/typeorm)(串MSSQL) 60 | * [Swagger](https://www.npmjs.com/package/swagger)(產生Restful API文檔) 61 | * [Mongoose](https://www.npmjs.com/package/mongoose)(串MongoDB) 62 | * [Redis](https://www.npmjs.com/package/redis)(串Redis) 63 | * [Cors](https://www.npmjs.com/package/cors)(處理跨站問題) 64 | * [Helmet](https://www.npmjs.com/package/helmet)(基本資安模組) 65 | * [G2](https://github.com/antvis/g2)/[D3.js](https://www.npmjs.com/package/d3)(資料視覺化) 66 | * [Moment](https://www.npmjs.com/package/moment)(時間格式處理) 67 | * [passport](https://www.npmjs.com/package/passport)、[passport-jwt](https://www.npmjs.com/package/passport-jwt)、[jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)(三個都要用於JWT token驗證)。 68 | 4. 測試工具: 69 | * [Postman](https://www.getpostman.com/apps)或[Nestjs](https://nestjs.com/)內建(E2E測試) 70 | * [Test404漏洞掃描器](http://www.test404.com/) 71 | 72 | ## 任務流程規劃 73 | **後端** 74 | 75 | 1. 完成後端對於會員的CRUD Restful API。 76 | 2. 串接比特幣報價API(寫入MongoDB),準備好供前端串接Socket.IO的API。 77 | 3. 建立聊天室服務,聊天內容寫入redis。 78 | 4. 建立登入驗證機制(含第三方登錄),權限區分。 79 | (以上開發API時,一併做E2E測試) 80 | 81 | **前端** 82 | 83 | 5. NG-ZORRO刻畫面 84 | 6. 串接註冊帳號 85 | 7. 串接登入機制 86 | 8. 串接個人資料管理 87 | 9. 串接報價服務 88 | 10. 串接聊天室 89 | 11. 滲透測試 90 | 12. 自動化測試 91 | 92 | 93 | > 題目本身很小不複雜,但藉由做好一個完整網站,對於學習應該蠻有幫助,而且特地找一個最近很夯的題目-比特幣,我本身對比特幣也不懂,順便借這命題了解一下比特幣,等比特幣網站完成後,後面的規劃是朝著**加密貨幣報價平台**邁進。 94 | > 程式生涯本身就是鐵人賽了,只能不斷實作學習,尤其筆者還是小嫩嫩,持續20幾天傷害大家眼睛XD,後面的PO文我會選擇性PO程式碼,保護大家眼睛,我要將心力放在實作上,這點對大家抱歉了~ -------------------------------------------------------------------------------- /SQL/CreateTable.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/SQL/CreateTable.sql -------------------------------------------------------------------------------- /ScreenShot/bitcoin_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/ScreenShot/bitcoin_1.png -------------------------------------------------------------------------------- /ScreenShot/bitcoin_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/ScreenShot/bitcoin_2.png -------------------------------------------------------------------------------- /ScreenShot/bitcoin_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m24927605/Nest-CryptoCurrency/d523782e49dde59ed369ec6a26b13b5a92026fc2/ScreenShot/bitcoin_3.png --------------------------------------------------------------------------------