update docs and scripts

This commit is contained in:
DavidWells 2018-06-29 16:31:24 -07:00
parent 2aeba61e73
commit a06ffff107
8 changed files with 20 additions and 8 deletions

View file

@ -252,15 +252,15 @@ Lets rock and roll.
{ {
"name": "netlify-fauna", "name": "netlify-fauna",
"scripts": { "scripts": {
"ABOUT-bootstrap-command": "#👇 scaffold and setup FaunaDB #", "👇 ABOUT-bootstrap-command": "💡 scaffold and setup FaunaDB #",
"bootstrap": "node ./scripts/bootstrap-fauna-database.js", "bootstrap": "node ./scripts/bootstrap-fauna-database.js",
"ABOUT-start-command": "#👇 start the app and server #", "👇 ABOUT-start-command": "💡 start the app and server #",
"start": "npm-run-all --parallel start:app start:server", "start": "npm-run-all --parallel start:app start:server",
"start:app": "react-scripts start", "start:app": "react-scripts start",
"start:server": "netlify-lambda serve functions -c ./webpack.config.js", "start:server": "netlify-lambda serve functions -c ./webpack.config.js",
"ABOUT-prebuild-command": "#👇 before 'build' runs, run the 'bootstrap' command #", "👇 ABOUT-prebuild-command": "💡 before 'build' runs, run the 'bootstrap' command #",
"prebuild": "echo 'setup faunaDB' && npm run bootstrap", "prebuild": "echo 'setup faunaDB' && npm run bootstrap",
"ABOUT-build-command": "#👇 build the react app and the serverless functions #", "👇 ABOUT-build-command": "💡 build the react app and the serverless functions #",
"build": "npm-run-all --parallel build:**", "build": "npm-run-all --parallel build:**",
"build:app": "react-scripts build", "build:app": "react-scripts build",
"build:functions": "netlify-lambda build functions -c ./webpack.config.js", "build:functions": "netlify-lambda build functions -c ./webpack.config.js",

View file

@ -1,3 +1,4 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb' import faunadb from 'faunadb'
const q = faunadb.query const q = faunadb.query
@ -8,7 +9,11 @@ const client = new faunadb.Client({
exports.handler = (event, context, callback) => { exports.handler = (event, context, callback) => {
const data = JSON.parse(event.body) const data = JSON.parse(event.body)
console.log("Function `todo-create` invoked", data) console.log("Function `todo-create` invoked", data)
return client.query(q.Create(q.Ref("classes/todos"), {data})) const todoItem = {
data: data
}
/* construct the fauna query */
return client.query(q.Create(q.Ref("classes/todos"), todoItem))
.then((response) => { .then((response) => {
console.log("success", response) console.log("success", response)
return callback(null, { return callback(null, {

View file

@ -1,3 +1,4 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb' import faunadb from 'faunadb'
import getId from './utils/getId' import getId from './utils/getId'

View file

@ -1,3 +1,4 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb' import faunadb from 'faunadb'
import getId from './utils/getId' import getId from './utils/getId'

View file

@ -1,3 +1,4 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb' import faunadb from 'faunadb'
const q = faunadb.query const q = faunadb.query

View file

@ -1,3 +1,4 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb' import faunadb from 'faunadb'
import getId from './utils/getId' import getId from './utils/getId'

View file

@ -1,3 +1,4 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb' import faunadb from 'faunadb'
import getId from './utils/getId' import getId from './utils/getId'

View file

@ -10,10 +10,11 @@
}, },
"scripts": { "scripts": {
"bootstrap": "node ./scripts/bootstrap-fauna-database.js", "bootstrap": "node ./scripts/bootstrap-fauna-database.js",
"docs": "md-magic --path '**/*.md' --ignore 'node_modules'",
"checkForFaunaKey": "node ./scripts/check-for-fauna-key.js", "checkForFaunaKey": "node ./scripts/check-for-fauna-key.js",
"start": "npm-run-all --parallel checkForFaunaKey startApp startServer", "start": "npm-run-all --parallel checkForFaunaKey start:app start:server",
"startApp": "react-scripts start", "start:app": "react-scripts start",
"startServer": "netlify-lambda serve functions -c ./webpack.config.js", "start:server": "netlify-lambda serve functions -c ./webpack.config.js",
"prebuild": "echo 'setup faunaDB' && npm run bootstrap", "prebuild": "echo 'setup faunaDB' && npm run bootstrap",
"build": "npm-run-all --parallel build:**", "build": "npm-run-all --parallel build:**",
"build:app": "react-scripts build", "build:app": "react-scripts build",
@ -21,6 +22,7 @@
"test": "react-scripts test --env=jsdom" "test": "react-scripts test --env=jsdom"
}, },
"devDependencies": { "devDependencies": {
"markdown-magic": "^0.1.22",
"netlify-lambda": "^0.4.0", "netlify-lambda": "^0.4.0",
"npm-run-all": "^4.1.3" "npm-run-all": "^4.1.3"
}, },