Skip to content

ImtiazScript/fn-automation

Repository files navigation

fn-automation

Node.js Express JWT

This repository contains a production-ready the backend server and frontend application for a basic MERN Stack user management application.

Back-end is built with Node.js and Express and MongoDB for Database.

Front-end is built with Reactjs using Vitejs.

It leverages two custom npm modules, base-auth-handler for authentication handling and @emtiaj/custom-errors for error management.

Features

  • Authentication Handling: Uses base-auth-handler for robust authentication with JWT sent in cookies.
  • Error Management: Utilizes @emtiaj/custom-errors for effective error handling.
  • Logger: Implements a production-level logger created with Winston and Morgan, saving logs into a remote MongoDB instance.

API Documentation

Note: The detailed Backend API documentation is available on Postman. Please refer to API Documentation on Postman.

Additionally, Swagger is integrated for convenient exploration of the API:

You can also access the API documentation in JSON format:

Backend Server

Frontend Server

Prerequisites

  • Node.js
  • Express
  • React.js
  • JSON Web Token (JWT)
  • MongoDB

Environment Variables

Create a .env file in the project root with following environment variables

APPLICATION_NAME = fn-automation
PORT = 5000

# Use development for dev environment and production for prod environment
NODE_ENV = development
# NODE_ENV = production

# your JWT Secrets
JWT_KEY = jwt_secret
JWT_TOKEN_DURATION = 30d

# your mongodb uri
MONGO_DB_URI = mongodb://localhost:27017/fn_automation

ADMIN_REGISTRATION_KEY = your_secret

# your targeted fn server
FN_BASE_URL = https://mono-sandbox.fndev.net

# your fn api access
FN_AUTHENTICATE_CLIENT_ID = your_client_id
FN_AUTHENTICATE_CLIENT_SECRET = your_client_pass

WORKORDERS_PER_PAGE = 100

DISABLED_CRONS = true
DISABLED_AUTHENTICATION_CRONS = true

LOG_RETENTION_DAYS = 7

# Mail sending credentials
# Email you would like to use to send emails to users
EMAIL_USER = emtiaj2011@gmail.com
EMAIL_PASS = your_email_app_password

COMPANY_NAME = Fn-Automation

# your support email
SUPPORT_MAIL = support@fn-automation.com
LOGIN_URL = http://localhost:3000

# Email where you would like to get the system notifications
ADMIN_EMAIL = admin_email

Getting Started

  1. Clone the repository:

    git clone https://github.com/imtiazuap/fn-automation.git
  2. Install dependencies:

    cd fn-automation
    npm install

    Install Front-end dependencies.

    cd frontend
    npm install
  3. Set up environment variables:

    Create a .env file in the root of the project and add the environment variables listed above.

  4. Run the server:

    Execute following command in the root directory of the project.

    npm run app

    The back-end server will be running at http://localhost:5000 or the specified port in your .env file.

    The front-end server will be running at http://localhost:3000.

Dependencies

  • See back-end package.json for a detailed list of dependencies.

Contributing

Feel free to contribute and provide feedback!

Create issues for bug reports or feature requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages