Skip to content

Instantly share code, notes, and snippets.

@stephenplusplus
Created August 26, 2019 15:33
Show Gist options
  • Save stephenplusplus/c697271308d779390a221be91c60cb18 to your computer and use it in GitHub Desktop.
Save stephenplusplus/c697271308d779390a221be91c60cb18 to your computer and use it in GitHub Desktop.
'use strict'
const express = require('express')
const {Storage} = require('@google-cloud/storage')
const app = express()
app.get('*', async (req, res) => {
const gcs = new Storage()
try {
const [objects] = await gcs.bucket('gcp-public-data-landsat').getFiles({maxResults: 10})
res.end(objects.map(o => o.name).join('\n'))
} catch (e) {
res.end(e.message)
}
})
module.exports = app
{
"name": "gissue-828",
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@now/node"
}
],
"routes": [
{
"src": "/",
"dest": "index.js"
}
]
}
{
"name": "gissue-828",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@google-cloud/storage": "^3.2.0",
"express": "^4.17.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment