GithubHelp home page GithubHelp logo

mrarvind90 / fcc-backend-api-projects Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 5.0 80 KB

A backend API microservice built as a project for freeCodeCamps' Backend Development and API course certification

License: MIT License

JavaScript 100.00%
cors dotenv eslint express-validator expressjs fcc-api fcc-backend fcc-certification freecodecamp freecodecamp-project javascript mongodb mongoose multer nodejs prettier winston-logger

fcc-backend-api-projects's Introduction

freeCodeCamp Social Banner

Javascript NodeJS NPM ExpressJS MongoDB Babel ESLint Prettier

code style: prettier

Microservices with Express Application

This project is an integral component of the 'Backend Development and API' certification program offered by freeCodeCamp. For comprehensive details on each project requirement, please refer to the following links:

Timestamp Microservice
Request Header Parser Microservice
URL Shortener Microservice
Exercise Tracker Microservice
File Metadata Microservice

Design Patterns

In this project, I have chosen to implement the Model-Service-Controller (MSC) design pattern. While the project requirements do not mandate a complex design pattern, I have opted for this approach to familiarize myself with industry-standard practices and to challenge myself to grow as a developer. I acknowledge that there may be opportunities for improvement in this project, and I wholeheartedly welcome any feedback or suggestions you may have. Your input is invaluable not only for the project but also for my personal growth and development as a developer.

Setup

This project relies on MongoDB Atlas cloud instances for managing resources such as /shorturl and /users. If you intend to clone this repository and run it locally, please follow these steps:

  1. Create a MongoDB Atlas Account: To get started, you'll need to create an account on MongoDB Atlas, and the good news is, it's absolutely free! You can follow the step-by-step instructions in the MongoDB Atlas Tutorial โ€“ How to Get Started provided by freeCodeCamp to set up your own cluster.
  2. Configure Your Environment Variables: After setting up your MongoDB Atlas cluster, you'll need to configure your environment variables. To do this, rename the .env.sample file in your project directory to .env. Then, open the .env file and insert the MongoDB URI from your Atlas cluster.

Here's what it should look like:

# Database variables
MONGODB_ATLAS_URI=mongodb+srv://<MONGODB_USER>:<MONGODB_PASSWORD>@<MONGODB_CLUSTER_HOST>/<MONGODB_DB_NAME>?retryWrites=true&w=majority

Note: In the example snippet above, you'll notice that the URI includes a database name. While this field is technically optional, it's highly recommended that you create your own database instance on your MongoDB Atlas cluster. This practice helps maintain organization and clarity in your project.

Running the application

To run the express application, do follow the following steps

  1. Clone the repo:
    git clone [email protected]:mrarvind90/fcc-backend-api-projects.git
    
  2. Navigate to the repository:
    cd <repository_directory>
    Change <repository_directory> to the name of the cloned directory.
  3. Install Dependencies:
    npm install
    This command will install all the necessary dependencies for the application.
  4. Configure Environment Variables: Rename the .env.sample file in your project directory to .env and update it with the relevant credentials:
     cp .env.example .env
  5. Choose Your Run Mode:
    • Development Mode (with automatic code reload):
      To run the application in watch mode, enabling seamless source code changes without manual server restarts, use the following command:
     npm run dev
    • Standard Server Mode:
      If you prefer to simply run the server without automatic code reloading, you can use the following command:
     npm run start

Future Improvements

While developing this project, there are several areas I plan to focus on for enhancements and refinements which can be found on GitHub.

fcc-backend-api-projects's People

Contributors

mrarvind90 avatar

Stargazers

 avatar

Watchers

 avatar

fcc-backend-api-projects's Issues

Standardise logging across projects

Description

Enhancing the logging mechanism used in the project to align with industry-standard logging practices for better traceability and debugging.

Acceptance Criteria

  • Research into industry best practises for logging
  • Implement standardised logging across project especially on error handling

API Documentation

Description

Explore the implementation of Swagger or any other alternative documentation standards to provide comprehensive and user-friendly documentation for the project's APIs

Acceptance Criteria

  • Integrate API documentation

Introduce Code Coverage, Unit and Functional Testing

Description

Implement comprehensive tests using either the Mocha, Chai, and Supertest stack or exploring the use of Playwright.

Acceptance Criteria

  • Create runnable unit and functional tests on local environment
  • Utilise industry standards tooling for code coverage

Automated Checks and Workflows

Description

Incorporate pre-commit hooks and GitHub workflows to automate essential tasks:

Acceptance Criteria

  • Configuring the project with tools like husky and lint-staged for enforcing linting and code formatting checks.
  • Implementing GitHub workflows to perform linting, code formatting, and test execution upon the creation of pull
    requests.

Custom Middleware Validators and Sanitisers

Description

Craft a tailored suite of validators and sanitizers by extending the functionality of express-validator to precisely align with the unique needs of the project.

Acceptance Criteria

  • Create a custom validator with the requirements of the project
  • Create a custom sanitiser with the requirements of the project

Deprecate the use of Babel and Nodemon after freeCodeCamp certification

Description

As part of freeCodeCamps' Back End Development and APIs certification, it has to be run on a browser. This has resulted in creating a Babel transpiler that will convert the code to CommonJS. After I pass the certification, I would like to remove these along with Nodemon to keep the project configuration and dependency structure simple.

Acceptance Criteria

  • Deprecate Babel
  • Deprecate Nodemon
  • Deprecate rimraf
  • Update to type="module" in package.json
  • Update npm run dev and npm run start scripts in package.json
  • Update imports across whole project

Environment Configuration Management

Description

Look into implementing multiple environment configuration

Acceptance Criteria

  • Establishing distinct environment configurations, such as local and production settings.
  • Considering the use of json-server for local environment testing as an alternative to a MongoDB Atlas instance.

Research and Implement Appropriate Project Structure

Description

Delve deeper into industry best practices for creating highly maintainable code, with a particular emphasis on optimizing the structure of middleware, services, and controllers.

Acceptance Criteria

  • Research into idiomatic NodeJS project structure for simple API projects
  • Create a fully compliant backend API project structure

Standardized Error Handling

Description

Research into ways to improve error handling and implement them across the project

Acceptance Criteria

  • Standardise error handling on middleware handlers
  • Standardise error handling on validator handlers
  • Standardise error handling on controller / service levels
  • Standardise error handling on server initialisation and unexpected failures

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.