Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apps-script-backend

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apps-script-backend

Google Apps Script as a Backend. ----

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Google Apps Script as a Backend.

First iteration of the library.

Features:

  • Google Spreadsheet ORM
  • Google Web App HTTP Router
  • Google Mocks

Google Spreadsheet ORM

Annotate your models and tables with the information about the spreadsheet information, and save/load your entities with one line of code.

import StorageService from 'apps-script-backend/src/storage/StorageService'
import Entity from 'apps-script-backend/src/storage/Entity'
import Table from 'apps-script-backend/src/storage/Table'
import { tableColumns, tableName, tableType } from 'apps-script-backend/src/storage/decorators'

@tableColumns([
    ['name'], 
    ['age', { type: Number }]
])
class CatEntity extends Entity {
    name: string
    age: number
}

@tableName('Cats')
@tableType(CatEntity)
class CatsTable extends Table<CatEntity> {
    
}

let cat = new CatEntity();
cat.name = 'Barsik';
cat.age = 10;

let storage = new StorageService('my_spreadsheet_id');
let table = new CatsTable(storage);
table.upsert(cat);

You can implement your own IStorageService to support storage other then google spreadsheets

Google Web App HTTP Router

For now, there is an action based routing

// actions/GetEchoAction.ts
import Application from 'apps-script-backend/src/Application';
import { IAction } from 'apps-script-backend/src/Router';
import { sendJson } from 'apps-script-backend/src/helpers/http';

export default <IAction> {
    process (request, app: Application) {
        const foo = request.parameter.foo;
        return { echoFoo: foo };
    }
};
// main.ts
import options from './options';
import GetEchoAction from './actions/GetEchoAction';
import Application from 'apps-script-backend/src/Application';
import Router from 'apps-script-backend/src/Router';

let app = new Application({
	secure: options.secure,
	routes: {
		'$get /echo': GetEchoAction
	},
	spreadsheetId: options.spreadsheetId,
	shouldMeaserTimings: options.shouldMeaserTimings,
	logLevel: 'warn'
});

function doPost(request) {
	return app.process('post', request);
}
function doGet(request) {
	return app.process('get', request);
}

Google Mocks

We have created some Google apps script API mocks, so that you can create and test your application even without uploading it to google scripts. See the test folder.


:copyright: 2017 MIT

FAQs

Package last updated on 10 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc