Giter Club home page Giter Club logo

whjvenyl / angularnest-fullstack-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shyam-chen/angular-starter

0.0 1.0 0.0 2.4 MB

:tiger: A boilerplate for Angular, Nest, Material, Express, TypeScript, and ReactiveX. Angular 6 | Nest 5 | Webpack 4 | Gulp 3 | Firebase | Hosting | Functions | PostCSS | TSLint | Jest | Puppeteer | Supertest | Headless Chrome | Testing | Unit | E2E | REST | GraphQL | Apollo | Lazy Loading | AoT Compilation | Modular

License: MIT License

Dockerfile 1.44% JavaScript 17.65% TypeScript 68.35% CSS 1.66% HTML 10.29% Shell 0.61%

angularnest-fullstack-starter's Introduction

AngularNest Fullstack Starter

๐Ÿฏ A boilerplate for Angular, Nest, Material, Express, TypeScript, and ReactiveX.

Build Status Coverage Status // dependencies Status devDependencies Status

๐ŸŒˆ Live Demo: Develop | Master

Table of Contents

Getting Started

Follow steps to execute this boilerplate.

  1. Clone this boilerplate
$ git clone --depth 1 https://github.com/Shyam-Chen/AngularNest-Fullstack-Starter <PROJECT_NAME>
$ cd <PROJECT_NAME>
  1. Install dependencies
$ yarn install
  1. Set an active project for working direct
$ yarn firebase use development
  1. Start a local server
# front-end
$ yarn start:app

# back-end
$ yarn start:api
  1. Compile and bundle code
# front-end
$ yarn build:app

# back-end
$ yarn build:api
  1. Check the code quality
# front-end
$ yarn lint:app

# back-end
$ yarn lint:api
  1. Run the unit tests
# front-end
$ yarn test:app

# back-end
$ yarn test:api
  1. Run the end-to-end tests
# front-end
$ yarn e2e:app

# back-end
$ yarn e2e:api

Key Features

This seed repository provides the following features:

Dockerization

Dockerize an application.

  1. Build and run the container in the background
$ docker-compose up -d <SERVICE>
  1. Run a command in a running container
$ docker-compose exec <SERVICE> <COMMAND>
  1. Remove the old container before creating the new one
$ docker-compose rm -fs
  1. Restart up the container in the background
$ docker-compose up -d --build <SERVICE>
  1. Push images to Docker Cloud
# .gitignore

  .DS_Store
  node_modules
  npm
  public
  functions
  coverage
+ Dockerfile.dev
+ Dockerfile.prod
  *.log
$ docker login
$ docker build -f tools/Dockerfile.<dev|prod> -t <IMAGE_NAME>:<IMAGE_TAG> .

# checkout
$ docker images

$ docker tag <IMAGE_NAME>:<IMAGE_TAG> <DOCKER_ID_USER>/<IMAGE_NAME>:<IMAGE_TAG>
$ docker push <DOCKER_ID_USER>/<IMAGE_NAME>:<IMAGE_TAG>

# remove
$ docker rmi <REPOSITORY>:<TAG>
# or
$ docker rmi <IMAGE_ID>
  1. Pull images from Docker Cloud
# docker-compose.yml

  <dev|prod>:
-   image: <dev|prod>
-   build:
-     context: .
-     dockerfile: tools/Dockerfile.<dev|prod>
+   image: <DOCKER_ID_USER>/<IMAGE_NAME>:<IMAGE_TAG>
    volumes:
      - yarn:/home/node/.cache/yarn
    tty: true

Configuration

Project environments

Change to your project.

// .firebaserc
{
  "projects": {
    "development": "<PROJECT_NAME>",
    "production": "<PROJECT_NAME>"
  }
}

Default environments

Set your local environment variables. (use this.<ENV_NAME> = process.env.<ENV_NAME> || <LOCAL_ENV>;)

// env.js
function Environments() {
  this.NODE_ENV = process.env.NODE_ENV || 'development';

  this.PROJECT_NAME = process.env.PROJECT_NAME || '<PROJECT_NAME>';

  this.HOST_NAME = process.env.HOST_NAME || '0.0.0.0';

  this.SITE_PORT = process.env.SITE_PORT || 8000;
  this.SITE_URL = process.env.SITE_URL || `http://${this.HOST_NAME}:${this.SITE_PORT}`;

  this.FUNC_PORT = process.env.FUNC_PORT || 5000;
  this.FUNC_URL = process.env.FUNC_URL || `http://${this.HOST_NAME}:${this.FUNC_PORT}/${this.PROJECT_NAME}/us-central1`;

  this.APP_BASE = process.env.APP_BASE || '/';

  this.FIREBASE_CONFIG = process.env.FIREBASE_CONFIG || {
    apiKey: process.env.FIREBASE_API_KEY || '<API_KEY>',
    authDomain: process.env.FIREBASE_AUTH_DOMAIN || '<FIREBASE_AUTH_DOMAIN>',
    databaseURL: process.env.FIREBASE_DATABASE_URL || '<FIREBASE_DATABASE_URL>',
    projectId: process.env.FIREBASE_PROJECT_ID || '<FIREBASE_PROJECT_ID>',
    storageBucket: process.env.FIREBASE_STORAGE_BUCKET || '<FIREBASE_STORAGE_BUCKET>',
    messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID || '<FIREBASE_MESSAGING_SENDER_ID>',
  };

  this.GOOGLE_ANALYTICS = process.env.GOOGLE_ANALYTICS || '<GOOGLE_ANALYTICS>';

  this.SENTRY_DSN = process.env.SENTRY_DSN || null;
  this.RENDERTRON_URL = process.env.RENDERTRON_URL || null;
}

Deployment environment

Set your deployment environment variables.

# tools/Dockerfile.<dev|prod>

# envs --
ENV SITE_URL <SITE_URL>
ENV FUNC_URL <FUNC_URL>
# -- envs

CI environment

Add environment variables to the CircleCI build.

CODECOV_TOKEN
DOCKER_PASSWORD
DOCKER_USERNAME
FIREBASE_TOKEN

SEO friendly

Enable billing on your Firebase Platform and Google Cloud the project by switching to the Blaze plan.

Serve dynamic content for bots.

// firebase.json
    "rewrites": [
      {
        "source": "**",
-       "destination": "/index.html"
+       "function": "app"
      }
    ],

Deploy rendertron instance to Google App Engine.

$ git clone https://github.com/GoogleChrome/rendertron
$ cd rendertron
$ gcloud auth login
$ gcloud app deploy app.yaml --project <RENDERTRON_NAME>

Set your rendertron instance in deployment environment.

# tools/Dockerfile.<dev|prod>

# envs --
ENV RENDERTRON_URL <RENDERTRON_URL>
# -- envs

Directory Structure

The structure follows the LIFT Guidelines.

.
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ api
โ”‚   โ”‚   โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ _<THING>  -> api of private things
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ core  -> core feature module
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>  -> feature modules
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.controller.spec.ts
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <FEATURE>.e2e-spec.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ _<THING>  -> feature of private things
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.controller.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.module.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <FEATURE>.service.ts
โ”‚   โ”‚   โ”œโ”€โ”€ <GROUP>  -> module group
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <FEATURE>  -> feature modules
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ <FEATURE>.controller.spec.ts
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ <FEATURE>.e2e-spec.ts
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ _<THING>  -> feature of private things
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ <FEATURE>.controller.ts
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ <FEATURE>.module.ts
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ <FEATURE>.service.ts
โ”‚   โ”‚   โ”œโ”€โ”€ graphql
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>  -> feature modules
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ _<THING>  -> feature of private things
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <GROUP>  -> module group
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ <FEATURE>  -> feature modules
โ”‚   โ”‚   โ”‚           โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚           โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚           โ”œโ”€โ”€ _<THING>  -> feature of private things
โ”‚   โ”‚   โ”‚           โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚           โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ shared  -> shared feature module
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ api.controller.ts
โ”‚   โ”‚   โ”œโ”€โ”€ api.module.ts
โ”‚   โ”‚   โ””โ”€โ”€ api.service.ts
โ”‚   โ”œโ”€โ”€ app
โ”‚   โ”‚   โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ _<THING>  -> app of private things
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ core  -> core feature module
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>  -> feature modules
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.component.spec.js
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <FEATURE>.e2e-spec.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ _<THING>  -> feature of private things
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.component.css
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.component.html
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ <FEATURE>.component.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <FEATURE>.module.ts
โ”‚   โ”‚   โ”œโ”€โ”€ <GROUP>  -> module group
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ <FEATURE>  -> feature modules
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ <FEATURE>.component.spec.js
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ <FEATURE>.e2e-spec.js
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ _<THING>  -> feature of private things
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ <FEATURE>.component.css
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ <FEATURE>.component.html
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ <FEATURE>.component.ts
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ <FEATURE>.module.ts
โ”‚   โ”‚   โ”œโ”€โ”€ shared  -> shared feature module
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.css
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.html
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.ts
โ”‚   โ”‚   โ””โ”€โ”€ app.module.ts
โ”‚   โ”œโ”€โ”€ assets  -> datas, fonts, images, medias, styles
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ client.ts
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ server.ts
โ”œโ”€โ”€ tools
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ .editorconfig
โ”œโ”€โ”€ .firebaserc
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .postcssrc
โ”œโ”€โ”€ .stylelintrc
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ circle.yml
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ env.js
โ”œโ”€โ”€ firebase.json
โ”œโ”€โ”€ gulpfile.js
โ”œโ”€โ”€ jest.config.js
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.api.json
โ”œโ”€โ”€ tsconfig.app.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ tsconfig.test.json
โ”œโ”€โ”€ tslint.json
โ”œโ”€โ”€ webpack.config.js
โ””โ”€โ”€ yarn.lock

angularnest-fullstack-starter's People

Contributors

shyam-chen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.