Angular / Firebase / Node.js

This guide will walk you through the setup, configuration, and usage of Angular / Firebase / Node.js, a robust SaaS boilerplate designed to accelerate your SAAS

Download repositories

Once you've purchased Nzoni, your github email account will be added to the related projects. Make sure you're already connected to github on your cli terminal or use Github Personal access token.

Download Angular repository

git clone https://github.com/nzoni-app/nz-angular-firebase.git

Download Node.js repository

git clone https://github.com/nzoni-app/nz-nodejs-firebase.git

Firebase Configuration

Create a Firebase account if you don't have one already, by visiting firebase.google.com.

  • Create a new project

  • Download the service key JSON file and place it at the root of your Node.js project with the name serviceAccountKey.json.

  • Enable Email/Password, Google, and passwordless email authentication.

  • Enable Firebase and create two indexes:

    • Collection ID: users

      • createdAt = Ascending

      • id = Ascending

    • Collection ID: plans

      • active = Ascending

      • position = Ascending

  • Activate Firebase storage

    • Set rules:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read;
      allow write: if request.auth != null;
    }
  }
}
  • Set FIREBASE_PROJECT_ID in the .env file.

Installation

Install Node.js (if you haven't already)

If you haven't installed Node.js yet, you can follow the instructions here.

Install Node Modules for Angular project

Navigate to the downloaded Angular project repostiory:

cd nz-angular-firebase
npm install

Install Node Modules for Node.js project

Navigate to the downloaded Node.js project repostiory:

cd nz-nodejs-firebase
npm install

Configure Environment Variables

Node.js environnement

Node.js supports environment variables out of the box. You can set defaults in .env (for all environments), .env.development (for development), and .env.production (for production).

By default, there is the .env.example file. Rename it to .env modify variables

ENV=developpement
PORT=3000

# DB configuration
DB_HOST=
DB_PORT=
DB_USERNAME=
DB_PASSWORD=
DB_NAME=
DB_LOCAL=true

# Mailing
SMTP_HOST=
SMTP_PORT=
SMTP_SECURE=false
SMTP_AUTH=
SMTP_PASSWORD=
SMTP_FROM='"Support name" <support@domain.name>'

# Logs
APP_DEBUG=true
JOB_ERROR_LOG_PATH='./'
DEFAULT_LOG_PATH='./logs'

# FONT_END_URL
FRONT_END_URL=

# Mail for moderation
MODERATION_MAIL=

STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=

TRIAL_DAYS=
DEFAULT_PLAN_ID=

FIREBASE_PROJECT_ID=

Angular Environnement

Edit src/environments/environnement.ts

export const environment = {
  production: false,
  api: '', // backend-url
  domain: '', // frontend-url
  google_tag_id: '', // for google analytics
  firebase: {
    apiKey: "",
    authDomain: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: "",
    measurementId: ""
  }
}

Run

Angular

To start Angular project, simply run:

ng serve

Angular instance is now running at http://localhost:4200/.

Node.js

Run the following command to start the server:

npm run start

Node.js instance is now running at http://localhost:3000/.

Congratulations! Your Nzoni project is now running!

Last updated