James Sherry PRO
Web Development Tutor and Co-Founder of { The Jump } Digital School
Once your file and directory structure are complete, it's time to initialise it as a node project, using npm
const Twitter = require('twitter');
const { consumer_key, consumer_secret, access_token_key, access_token_secret } = process.env;
const client = new Twitter({
consumer_key,
consumer_secret,
access_token_key,
access_token_secret, // es6 trailing comma
});
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
// Put at top of file to put the variables in the process
require('dotenv').config();
// Use them...
const db = require('db')
db.connect({
host: process.env.DB_HOST,
username: process.env.DB_USER,
password: process.env.DB_PASS
})
{
"scripts": {
"dev": "nuxt && functions:build && functions:serve",
"build": "nuxt build",
"start": "MY_VAR=2 nuxt start",
"start:production": "nuxt build && nuxt start",
"generate": "nuxt generate && npm run functions:build",
"functions:serve": "netlify-lambda serve lambda",
"functions:build": "netlify-lambda build lambda"
}
}
By James Sherry