A serverless Backend application developed with Express.js and deployed π in Netlify functions.
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.
If you like this Repo, Please click the β
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.
List of things you need to use this project and how to install them.
- netlify CLI
npm install -g netlify-cli
- Clone the repo
git clone https://github.com/TheWorstOne/netlify-serverless.git
- Install NPM packages
npm install
- Enter your MONGO URI in
.env
in the root directory for local deploymentMONGO_DB_CONNECTION="mongodb+srv://<username>:<password>@<database>.n5qog.mongodb.net/<collection>?retryWrites=true&w=majority"
To use this project in your local environment, follow the steps below.
For a more detailed explanation you can check this guide
- To initialize the root folder with netlify
netlify init
- For local deployment you can use both commands
npm start netlify dev
- To access serverless functions in the browser, use the URL
http:localhost:PORT/.netlify/functions/app/
- You can check all the functions in the
src/routes/flights.js
To access these services you must use the following URIrouter.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);
http:localhost:PORT/.netlify/functions/app/flights/<serverless function>
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
- Deploy to production
netlify deploy --prod
- 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
Distributed under the MIT License. See LICENSE
for more information.
Miguel Γngel MacΓas - π¨βπ»Linkedin
My Personal Website: β¨mangelladev.com