0.0.4 • Published 7 years ago

gcframe-env v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

GCFrame

GCFrame helps serve HTTP endpoints with Google Cloud Functions.

There's a bunch of common things you probably want to do when serving HTTP endpoints via Google Cloud Functions. These micro libraries help out with that. The hope is that they become obsolete once Google implement further features into the Cloud Functions product.

Functions

Router

npm install -s gcframe-router
function helloWorld (req, res) {
  return res.send(`Hello ${req.params.name});
}

module.exports = {
  helloWorld: router('GET', '/:name', helloWorld);
}

View Router docs

Environment Variables

npm install -s gcframe-env
function helloWorld (req, res) {
  return res.send(`Hello ${req.params.name});
}

module.exports = {
  helloWorld: env.remoteConfig('remote-config', callback, helloWorld);
}

View Environment Variables docs

Cors

npm install -s gcframe-cors
function helloWorld (req, res) {
  return res.send('Hello World');
}

module.exports = {
  helloWorld: cors({ allowOrigin: '*', allowMethods: 'POST' }, helloWorld)
}

View Cors docs

Auth

npm install -s gcframe-auth
function helloWorld (req, res) {
  return res.send(`Hello ${req.params.name});
}

module.exports = {
  helloWorld: auth({ authBucket: 'gcs-bucket-proxying-auth' }, helloWorld);
}

View Auth docs

Composition

These functions are auto-curried handler-last functions, so they can be composed in a functional style.

function helloWorld (req, res) {
  return res.send(`Hello ${req.params.name});
}

const handle = compose(
  auth({ authBucket: 'my-auth-bucket' }),
  cors({ allowOrigin: '*' }),
  router('GET', '/:name'),
)

module.exports = {
  helloWorld: handle(helloWorld),
}
0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago