Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

IBM/serverless-functions-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IBM Cloud

IBM Cloud platform Apache 2

Create a serverless Node.js application

We have similar applications available for Swift and Python.

This repository has code to create a serverless Backend for Frontend (BFF) using Node.js and IBM Cloud Functions to communicate with a NoSQL database. Cloud Functions supplies basic Create, Read, Update, and Delete operations in a serverless environment. These functions can be mapped to an API gateway, then integrated into an iOS app for example, to enable persistence of data into a Cloudant NoSQL Database.

Cloudant NoSQL DB provides access to a fully managed NoSQL JSON data layer that's always-on. This service is compatible with CouchDB, and accessible through a simple to use HTTP interface for mobile and web application models.

Included Components

  • Cloudant NoSQL DB: A fully managed data layer designed for modern web and mobile applications that leverages a flexible JSON schema.
  • Continuous Delivery: Enable tool integrations that support your development, deployment, and operation tasks.
  • GitLab: GitLab unifies issues, code review, CI, and CD into a single UI.

Featured Technologies

  • IBM Cloud Functions: An event-action platform that allows you to execute code in response to an event.
  • Node: An open-source JavaScript run-time environment for executing server-side JavaScript code.

Steps

While you can use the individual actions locally, this collection of endpoints is meant to be deployed to IBM Cloud Functions. You can deploy this application to IBM Cloud or deploy it manually by cloning this repo first.

You can then review the Actions in the IBM Cloud Console interface, along with your Cloud Functions APIs.

Method HTTP request Description
Create POST /database Inserts an object
Read GET /database/objectId Retrieves an object
ReadAll GET /database Retrieves all objects
Delete DELETE /database/objectId Deletes an object
DeleteAll DELETE /database Deletes all objects
update PUT /database/objectId Updates content of an object

Deploying to IBM Cloud

Deploy to IBM Cloud

Use the button above to deploy this same application to IBM Cloud. This option will create a deployment pipeline, complete with a hosted Git lab project and DevOps toolchain. IBM Cloud DevOps services provides toolchains as a set of tool integrations that support development and deployment to IBM Cloud Functions.

Deploying Manually

To deploy this application to IBM Cloud using the command line, you can leverage the IBM Cloud Developer Tools. You will need to have the credentials for a Cloudant or CouchDB service, and need to update the feilds in the localdev-config.json file

  • Install IBM Cloud Developer Tools on your machine by running the following command:

    curl -sL https://ibm.biz/idt-installer | bash
    
  • Install the Whisk Deploy CLI.

    For macOS and Linux, ensure that the deploy.sh script is executable and run it:

    chmod +x deploy.sh
    ./deploy.sh
    

    Alternatively, you can run the wskdeploy command directly, you use the --param command line flags to provide values for the services.cloudant.database and services.cloudant.url values.

    /wskdeploy -m "manifest.yml" --param "services.cloudant.url" "<url>" --param "services.cloudant.database" "products"

    Where <url> is the URL value from your Cloudant service credentials.

Next Steps

License

Apache 2.0