- Clone
npm installnpm install -g now
now dev- open http://localhost:3000
This step requires creating an account with now: https://zeit.co
now deploy
npm installnpm install -g nownow devThis step requires creating an account with now: https://zeit.co
now deploy| '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" | |
| } | |
| } |