A simple Node.js library to read/write JSON files on GitHub and serve as a lightweight GitDB.
- Read JSON file from a GitHub repository
- Write (create/update) JSON file to a GitHub repository
npm install gitdb
or
npm install git+https://github.com/manishkumar1601/gitdb.git
const { createDriver, fetchFile, saveFile } = require('gitdb');
const driver = createDriver({
username: 'your-github-username',
repository: 'your-repo-name',
token: 'your-github-personal-access-token',
path: 'data.json', // path in repo
});
fetchFile(driver).then(console.log);
saveFile(driver, { foo: 'bar' }).then(console.log);
import { createDriver, fetchFile, saveFile } from 'gitdb';
const driver = createDriver({
username: 'your-github-username',
repository: 'your-repo-name',
token: 'your-github-personal-access-token',
path: 'data.json',
});
fetchFile(driver).then(console.log);
saveFile(driver, { foo: 'bar' }).then(console.log);
import { createDriver, fetchFile, saveFile } from 'gitdb';
const driver = createDriver({
username: 'your-github-username',
repository: 'your-repo-name',
token: 'your-github-personal-access-token',
path: 'data.json',
});
fetchFile(driver).then(console.log);
saveFile(driver, { foo: 'bar' }).then(console.log);
username
(string): GitHub usernamerepository
(string): Repository nametoken
(string): GitHub personal access tokenpath
(string): File path in the repository (default:file.json
)message
(string): Commit message (optional)
Fetch the JSON file from the repository.
Save (create/update) the JSON file in the repository.
MIT