Skip to content

Commit

Permalink
f/improvements (#3)
Browse files Browse the repository at this point in the history
* feat: added a dependabot

* feat: moved gitrows to ./lib

* feat(doc): just more curl explicit command for apis

* feat: add a check for the env before running anything

* chore(doc): updated the README

* feat: add a small TODO.md

* feat: i really don't know why this was needed in the first place lol

* chore(doc): just more cleaning and upates
  • Loading branch information
Sanix-Darker authored Apr 29, 2024
1 parent 0ccf73b commit 870fdce
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# yarn
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2010-2021 sanix-darker, Inc. https://github.com/Sanix-Darker
Copyright (c) 2024 sanix-darker, Inc. https://github.com/Sanix-Darker

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

Soooo, what's is gitrowspack-api in a simple sentence, it's a service interface for your (github/gitlab) repository oriented for Database !

It support json, csv and yaml file, but as default, we will be using the json.
It support *json*, *csv* and *yaml* file, but as default, we will be using the json.

The purpose of this project is to have a full quick running gitrows's api instance if we have our own private repos that we want to transform as storage !

![screen](./screen.gif)


## Disclaimers
This project is for certain usecases... the github API cache is HUGE, like 4/5mins, so this is not a realtime stuff, you can used in your project... but it does the job... and well !

Expand All @@ -25,7 +24,7 @@ This project is for certain usecases... the github API cache is HUGE, like 4/5mi
- Docker (optionnal)

## Features
Transform your github repo into a NoSQl database
Transform your github repo into a NoSQl database


## How to set up
Expand All @@ -44,7 +43,7 @@ https://raw.githubusercontent.com/Sanix-Darker/gitrowspack-api/master/.env.examp

# and provide valids parameters inside
# GITHUB_OWNER is your github username
# GITHUB_TOKEN is a github access token you can create from your settings easily: https://github.com/settings/tokens
# GITHUB_TOKEN is a github access token you can create from your settings easily: https://github.com/settings/tokens

# And you're all set :-)
```
Expand All @@ -65,16 +64,21 @@ sanixdarker/gitrowspack-api:latest
# expected output
# Unable to find image 'sanixdarker/gitrowspack-api:0.0.1' locally
# 0.0.1: Pulling from sanixdarker/gitrowspack-api
# 482c96fb3fd1: Already exists
# 8a46b85b8b61: Pull complete
# 1a99571c09c9: Pull complete
# e7276d16c1c3: Pull complete
# 1d5b7776a505: Pull complete
# 482c96fb3fd1: Already exists
# 8a46b85b8b61: Pull complete
# 1a99571c09c9: Pull complete
# e7276d16c1c3: Pull complete
# 1d5b7776a505: Pull complete
# Digest: sha256:72dbcfa96ca59ad684c62dfe3e72b2d35e6c5a7e0024c5331b005f36be122d72
# Status: Downloaded newer image for sanixdarker/gitrowspack-api:0.0.1
# GitRowsPack-Api started at http://localhost:3030

# For security, make sure the Digest hash you got match the version from the 'digest.json' file or from [dockerhub](https://hub.docker.com/repository/docker/sanixdarker/gitrowspack-api/general)
# Now you can test it out
# To list available databases (note that the repo needed to be created first)
# curl http://127.0.0.1:3030/api/v1/<repo-name>/databases

# And the collection is a directory
# curl http://127.0.0.1:3030/api/v1/<repo-name>/<database-name>/collections
```

### For dev
Expand Down
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## TODO

- [ ] Add a REAL CI pipeline to check for any github breaking changes on their API
- [ ] Optimize and Update the gitrows code from lib
14 changes: 0 additions & 14 deletions digest.json

This file was deleted.

7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// The entrypoint is here !
// gitrows support .json|.csv|.yaml
// For refs, check the repo https://github.com/Sanix-Darker/data

// We set the dotenv
const dotenv = require('dotenv');
// We instantiate our gitrows
const Gitrows = require('./gitrows');
const Gitrows = require('./lib/gitrows');
// We call express
const express = require('express')

Expand Down Expand Up @@ -137,7 +138,7 @@ app.get(`${BASE_ROUTE}/ping`, async (req, res) => {
});

// A simple endpoint to get the list of databases
// curl /api/v1/databases
// curl http://127.0.0.1:3030/api/v1/data/databases # data is the repository
app.get(`${BASE_ROUTE}/:project/databases`, async (req, res) => {
const data = {
"project": req.params.project,
Expand All @@ -147,7 +148,7 @@ app.get(`${BASE_ROUTE}/:project/databases`, async (req, res) => {
});

// A simple endpoint to get the list of databases
// curl /api/v1/collections
// curl http://127.0.0.1:3030/api/v1/data/dx/collections # 'data' is a repo and 'dx' is a directory
app.get(`${BASE_ROUTE}/:project/:database/collections`, async (req, res) => {
const data = {
"project": req.params.project,
Expand Down
8 changes: 3 additions & 5 deletions gitrows.js → lib/gitrows.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const fetch=require('node-fetch');

const CSV = {
parse:require('csv-parse/lib/sync'),
stringify: require('csv-stringify/lib/sync')
};
const YAML = require('yamljs');

const Response=require('./lib/response.js');
const Util=require('./lib/util.js');
const GitPath=require('./lib/gitpath.js');
const Response=require('./response.js');
const Util=require('./util.js');
const GitPath=require('./gitpath.js');

module.exports=class Gitrows{
constructor(options){
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "0.0.1",
"description": "A node-api for the gitrows npm package",
"scripts": {
"dev": "nodemon index.js",
"start": "node index.js",
"docker-build": "docker build -t sanixdarker/gitrowspack-api:latest -f Dockerfile .",
"docker-run": "docker run --env-file .env -it --rm -p 3030:3030 sanixdarker/gitrowspack-api:latest"
"dev": "test -f .env && nodemon index.js || echo 'Error, No .env found !'",
"start": "test -f .env && node index.js || echo 'Error, No .env found !'",
"docker-build": "test -f .env && docker build -t sanixdarker/gitrowspack-api:latest -f Dockerfile . || echo 'Error, No .env found !'",
"docker-run": "test -f .env && docker run --env-file .env -it --rm -p 3030:3030 sanixdarker/gitrowspack-api:latest || echo 'Error, No .env found !'"
},
"repository": {
"type": "git",
Expand All @@ -33,11 +33,11 @@
"nodemon": "^2.0.15"
},
"dependencies": {
"csv-parse": "4.12.0",
"csv-stringify": "5.5.1",
"csv-parse": "^4.12.0",
"csv-stringify": "^5.5.1",
"dotenv": "^10.0.0",
"express": "^4.17.2",
"node-fetch": "2.6.0",
"yamljs": "0.3.0"
"node-fetch": "^2.6.0",
"yamljs": "^0.3.0"
}
}

0 comments on commit 870fdce

Please sign in to comment.