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

scheduleonce/express-sheets

Repository files navigation

express-sheets

Read sheets dynamically from google spreadsheet.

styled with prettier

Background

This is an api that is backed by a Google Spreadsheet as a "database".

We need to be able to get data dynamically from a Google spreadsheet. Multiple sheets can be added to the spreadsheet and data will be returned from them without having to add a new route for the newly added sheet.

For example, this function turns this spreadsheet into this json response:

[
  {
    "ID": "1",
    "Name": "Classic",
    "Time to read": "5 mins"
  }
]

Usage

The route for the sheet will be the same as the sheet name.

Consider a Google spreadsheet with multiple sheets:

| events | articles | blogs |

Route to retrieve data from events sheet:

/events

Local Development

  1. Edit the .env file with your spreadsheet's configuration.
  2. The private_key in the config should be base64 encoded.
  3. Run the server in local mode, this would start server and read configurations from .env file.
    npm run start:local