Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .env support #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# add your endpoint
YOUR_ENDPOINT=''

# add your project ID
YOUR_PROJECT_ID=''

# add your API Key
YOUR_API_KEY=''


# Use this to authenticate with JWT generated from Client SDK
# jwt=''
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
**.DS_Store
.env
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ This playground doesn't include any NodeJS best practices but rather intended to

1. Clone this repository.
2. `cd` into the repository.
3. Open the `app.js` file found in the root of the cloned repository.
4. Copy Project ID, endpoint and API key from Appwrite console into `app.js`
3. Reanme `.env.example` to `.env`.
4. Copy Project ID, endpoint and API key from Appwrite console into `.env`.
5. Run the playground:
NodeJS:
- NodeJS:
- Install dependencies `npm install`
- Execute the command `node app.js`
Docker:
- Docker:
- Execute the command `docker compose up`
6. You will see the JSON response in the console.

Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"chalk": "^4.1.0",
"dot-env": "^0.0.1",
"node-appwrite": "^8.0.0"
}
}
9 changes: 5 additions & 4 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ const { Client, Databases, Functions, Account, Users, Storage, InputFile, Query,
const chalk = require('chalk');
const fs = require('fs');
const path = require('path');
require('dotenv').config();

// Config
const client = new Client()
.setEndpoint('YOUR_ENDPOINT') // Replace with your endpoint
.setProject('YOUR_PROJECT_ID') // Replace with your project ID
.setKey('YOUR_API_KEY'); // Replace with your API Key
//.setJWT('jwt'); // Use this to authenticate with JWT generated from Client SDK
.setEndpoint(process.env.YOUR_ENDPOINT) // Replace with your endpoint
.setProject(process.env.YOUR_PROJECT_ID) // Replace with your project ID
.setKey(process.env.YOUR_API_KEY); // Replace with your API Key
//.setJWT(process.env.jwt); // Use this to authenticate with JWT generated from Client SDK

const databases = new Databases(client);
const functions = new Functions(client);
Expand Down