@rexfng/google-sheet-db
v1.8.0
Published
Convert Google Sheet into restful api and functions
Downloads
16
Readme
Google Sheet DB
Description
Google Sheet DB is a library that provides helpers to convert google sheet csv into json, with express routers that serves the data and creates a RESTful api.
Define Environment Variables
Define the follow environment variable. They are all required. | Variable Name | Description | |---------------|-------------| | REDIS_HOST | // sample values: 19324 | | REDIS_PORT | // sample values: redis-19324.c1.us-west-2-2.ec2.cloud.redislabs.com | | REDIS_AUTH_PASS | // sample values: 6X2MOasdfasdfamSY5WCo0 |
Initialize Module
const googleSheetDb = require('@rexfng/google-sheet-db')
Get Sheet Data Helper
const googleSheetDb = require('@rexfng/google-sheet-db')
let googleSheetDbInstance = await googleSheetDb.helpers.getSheetData({sheet, id})
Router Helper
const googleSheetDb = require('@rexfng/google-sheet-db')
let GoogleSheetAPI = googleSheetDb.api
app.use('/', GoogleSheetAPI.getSheetData) // GET
Get Sheet Data Endpoint
The endpoint takes in JSON Body in the following format http://localhost:3000/{:google-sheet-id} GET
Optional Query
| Key| Example | Description | |-----|----------------------| -----------| | sheet | ?sheet=dish_concept | Specifying which sheet to retrieve data from with in spreadsheet file | | unique | ?unique=dish_concept | List out unique values of a given field |
Response Code | CODE| MESSAGE | Details | |-----|----------------------|---| | 200 | SUCCESS | Successfully retrieved data | | 500 | INTERNAL_ERROR | Server side error |
Response
{
//[JSON]
}
Search Sheet Data Endpoint
The endpoint takes in JSON Body in the following format http://localhost:3000/{:google-sheet-id} GET
Optional Query
| Key| Example | Description | |-----|----------------------| -----------| | sheet | ?sheet=dish_concept | Specifying which sheet to retrieve data from with in spreadsheet file | | limit | ?limit=20 | pagination size | | page | ?page=1 | pagination page | | q | ?q=something | query for fuzzy search | | cached | ?cached=false | false will fetch new data, true or empty will serve from redis | | search_terms | ?search_terms=title | the title column used for searches, deliminated by "commas" for additional terms |
Response Code | CODE| MESSAGE | Details | |-----|----------------------|---| | 200 | SUCCESS | Successfully retrieved data | | 500 | INTERNAL_ERROR | Server side error |
Response
{
//[JSON]
}