Skip to content

Latest commit

 

History

History
123 lines (99 loc) · 5.37 KB

README.md

File metadata and controls

123 lines (99 loc) · 5.37 KB

NETLIFY SERVERLESS

A serverless Backend application developed with Express.js and deployed 🚀 in Netlify functions.

Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors License Badge

Interested in the project? Please visit my website


It is a good software engineering practice to separate portions of your code function to work independently of other parts. Since your codes are made up of functions basically, serverless functions allow you to deploy those functions without the complexity of managing a server to run them (Olutunmbi Banto, 2020). This repository was created as part of a Big Data project in which services must be consumed from a database made in MondoDB with the historical information of the flights of US airlines. The APIs will be consumed by a SimpleMongoCRUD Frontend developed in Angular.

Logo


If you like this Repo, Please click the ⭐

Contents

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps. Also, you can check this tutorial.

Prerequisites

List of things you need to use this project and how to install them.

  • netlify CLI
    npm install -g netlify-cli

Installation

  1. Clone the repo
    git clone https://github.com/TheWorstOne/netlify-serverless.git
  2. Install NPM packages
    npm install
  3. Enter your MONGO URI in .env in the root directory for local deployment
    MONGO_DB_CONNECTION="mongodb+srv://<username>:<password>@<database>.n5qog.mongodb.net/<collection>?retryWrites=true&w=majority"

Usage

To use this project in your local environment, follow the steps below.

For a more detailed explanation you can check this guide

  1. To initialize the root folder with netlify
    netlify init
  2. For local deployment you can use both commands
    npm start
    netlify dev
  3. To access serverless functions in the browser, use the URL
    http:localhost:PORT/.netlify/functions/app/
  4. You can check all the functions in the src/routes/flights.js
     router.post("/new", FlightController.createFlight);
     router.get("/number/:FlightNum", FlightController.getFlightByNumber);
     router.get("/search/:flightId", FlightController.getFlightById);
     router.get("/numbers", FlightController.getFlightNumbers);
     router.put("/update/:_id", FlightController.updateFlight);
     router.delete("/delete/:flightId", FlightController.deleteFlight);
    To access these services you must use the following URI http:localhost:PORT/.netlify/functions/app/flights/<serverless function>

Deployment

If you want to deploy your own serverless on netlify, follow the next steps. Make sure your github repository is linked to your project on the netlify website

  1. Deploy to production
    netlify deploy --prod
  2. If you have problems with environment variables at deployment time, you can use the interface provided by the netlify website. In your site overview go to Site settings > Build & deploy > Environment > Edit variables

Logo

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Miguel Ángel Macías - 👨‍💻Linkedin

My Personal Website: ✨mangelladev.com