update scripts to validate for fauna key locally
This commit is contained in:
parent
ccdaf7ba31
commit
18d03002cb
2 changed files with 9 additions and 56 deletions
|
|
@ -1,51 +0,0 @@
|
|||
/* bootstrap database in your FaunaDB account */
|
||||
const readline = require('readline');
|
||||
const faunadb = require('faunadb');
|
||||
const q = faunadb.query;
|
||||
|
||||
ask('Enter your faunaDB server key', function(err, answer) {
|
||||
const key = answer || process.env.FAUNADB_SECRET
|
||||
if (!key) {
|
||||
console.log('Please set supply a faunaDB server key')
|
||||
process.exit()
|
||||
}
|
||||
|
||||
const client = new faunadb.Client({
|
||||
secret: answer
|
||||
});
|
||||
|
||||
createFaunaDB(key).then(() => {
|
||||
console.log('Database created')
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
function createFaunaDB(key) {
|
||||
const client = new faunadb.Client({
|
||||
secret: key
|
||||
});
|
||||
|
||||
/* Based on your requirements, change the schema here */
|
||||
return client.query(q.Create(q.Ref("classes"), { name: "todos" }))
|
||||
.then(()=>{
|
||||
return client.query(
|
||||
q.Create(q.Ref("indexes"), {
|
||||
name: "all_todos",
|
||||
source: q.Ref("classes/todos")
|
||||
}))
|
||||
})
|
||||
.then(console.log.bind(console))
|
||||
.catch(console.error.bind(console))
|
||||
}
|
||||
|
||||
// Readline util
|
||||
function ask(question, callback) {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
rl.question(question + '\n', function(answer) {
|
||||
rl.close();
|
||||
callback(null, answer);
|
||||
});
|
||||
}
|
||||
14
package.json
14
package.json
|
|
@ -9,16 +9,20 @@
|
|||
"react-scripts": "1.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"bootstrap": "node ./init-faunadb.js",
|
||||
"start": "concurrently \"react-scripts start\" \"npm run startServer\"",
|
||||
"bootstrap": "node ./_init-fauna-database.js",
|
||||
"checkForFaunaKey": "node ./_check-for-fauna-key.js",
|
||||
"start": "npm-run-all --parallel checkForFaunaKey startApp startServer",
|
||||
"startApp": "react-scripts start",
|
||||
"startServer": "netlify-lambda serve functions -c ./webpack.config.js",
|
||||
"build": "npm run buildFunctions && react-scripts build",
|
||||
"buildFunctions": "netlify-lambda build functions -c ./webpack.config.js",
|
||||
"build": "npm-run-all --parallel build:**",
|
||||
"build:app": "react-scripts build",
|
||||
"build:functions": "netlify-lambda build functions -c ./webpack.config.js",
|
||||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"devDependencies": {
|
||||
"netlify-lambda": "^0.4.0"
|
||||
"netlify-lambda": "^0.4.0",
|
||||
"npm-run-all": "^4.1.3"
|
||||
},
|
||||
"proxy": {
|
||||
"/.netlify/functions": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue