Skip to content

Instantly share code, notes, and snippets.

# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
{
"name": "serverless",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"dependencies": {
"cloudinary": "^1.11.0"
},
"devDependencies": {},
"scripts": {
'use strict';
function _getImage(term) {
const url = `https://api.unsplash.com/photos/random?query=${term}&client_id=${process.env.UNSPLASH_API_KEY}`;
return new Promise((resolve, reject) => {
const https = require('https');
const request = https.get(url, response => {
if (response.statusCode < 200 || response.statusCode > 299) {
reject(new Error('Failed to load page, status code: ' + response.statusCode));
}