项目作者: ketangit

项目描述 :
Sample Angular Web application
高级语言: TypeScript
项目地址: git://github.com/ketangit/sample-app.git
创建时间: 2017-11-18T07:23:32Z
项目社区:https://github.com/ketangit/sample-app

开源协议:

下载


Sample Angular Web application

  • This project was generated with Angular CLI version 1.7.3
  • Firebase function project was generated with Firebase CLI
  • It uses Angular javascript framework version 5.x
  • It uses Angular Material 2 components, styles, fonts and icons
  • It uses Angular Flex Layout for Responsive layout
  • Node 8.10.0 or higher and NPM 5.6.0 or higher dependencies are required

Run locally

  1. Angular App
  2. npm install
  3. npm start
  4. npm run api
  5. Firebase function
  6. npm run compile-functions (compile only)
  7. npm run deploy-functions (compile and deploy)

Tested with

  1. Node: 8.10.0
  2. NPM: 6.0.0
  3. Angular CLI: 1.7.4
  4. Angular: 5.2.4
  5. OS: win32 x64

Quick Installation Instructions

  1. npm install -g @angular/cli@latest

uninstall and re-install Angular CLI to the latest version

  1. npm uninstall -g angular-cli
  2. npm cache clean
  3. npm install -g @angular/cli@latest

Depending on your system, you may need to prefix the above commands with sudo.

Update Angular CLI for local project

  1. rm -rf node_modules
  2. npm uninstall --save-dev angular-cli
  3. npm install --save-dev @angular/cli@latest
  4. npm install

Steps for creating this application

  1. Create new application using ng-cli
  2. ng new sample-app --prefix sample --style scss --routing
  3. Installing npm package dependencies
  4. cd sample-app
  5. npm install --save @angular/material @angular/animations @angular/cdk
  6. npm install --save @angular/flex-layout
  7. npm install --save material-design-icons
  8. npm install --save typeface-roboto
  9. npm install --save material-design-iconic-font
  10. npm install --save hammerjs
  11. npm install --save vis
  12. npm install --save-dev json-server
  13. Creating new components
  14. ng generate component components/navbar --module app
  15. ng generate component components/home --module app
  16. ng generate component components/about --module app
  17. ng generate component components/tags --module app
  18. ng generate component components/networkgraph --module app
  19. ng generate component components/product --module app
  20. Creating new services
  21. ng generate service services/category --module app --spec false
  22. ng generate service services/question --module app --spec false
  23. ng generate service services/tag --module app --spec false
  24. ng generate service services/product --module app --spec false
  25. ng generate class model/category --spec false
  26. ng generate class model/department --spec false

Add Apollo/GraphQL to the Application

  1. Installing npm package dependencies
  2. cd sample-app
  3. npm install apollo-angular apollo-angular-link-http apollo-client apollo-cache-inmemory --save
  4. npm install graphql-tag graphql --save
  5. Apollo codegen
  6. npm install -g apollo-codegen
  7. npm install -g graphql-code-generator
  8. apollo-codegen introspect-schema http://localhost:8080/graphql --output schema.json
  9. gql-gen --file schema.json --template typescript

Create Docker image for static site

  1. Build Docker image
  2. docker build -t sample-app .
  3. Run Docker Image
  4. docker run --name sample-app -p 80:80 -d sample-app
  5. Run Bash Shell
  6. docker exec -it sample-app bash

VSCode hot keys

  1. Windows:
  2. (Ctrl+Shift+P) Open Command Palette
  3. (Ctrl+K Ctrl+S) Keyboard Shortcuts
  4. (Ctrl+K V) Markdown: Open Preview to the Side
  5. Mac:

VSCode Extensions

  1. code --list-extensions
  2. ajhyndman.jslint
  3. dbaeumer.vscode-eslint
  4. eamodio.gitlens
  5. esbenp.prettier-vscode
  6. PeterJausovec.vscode-docker
  7. PKief.material-icon-theme
  8. wesbos.theme-cobalt2

Adding project to Github

  1. git init
  2. git add .
  3. git commit -m "initial commit"
  4. git remote add origin git@github.com:ketangit/sample-app.git
  5. git push -u origin master

Add below in package.json for firebase functions and express

  1. npm install -g firebase-tools
  2. npm install --save firebase-admin firebase-functions
  3. npm install --save express fs-extra @types/express
  4. "compile-functions": "rmdir /s/q functions\\lib & tsc --project functions"
  5. "dependencies": {
  6. "express": "^4.16.2",
  7. "firebase-admin": "^5.8.2",
  8. "firebase-functions": "^0.8.1",
  9. "fs-extra": "^5.0.0"
  10. },
  11. "devDependencies": {
  12. "@types/express": "^4.11.1",
  13. "tslint": "^5.8.0",
  14. "typescript": "^2.6.1"
  15. }

API Endpoints (sample data)

Credit / Prior Art