diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f2aafc5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # yarn + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" diff --git a/LICENSE b/LICENSE index 5befa41..1a8565f 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 825151d..1fe343f 100644 --- a/README.md +++ b/README.md @@ -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 ! @@ -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 @@ -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 :-) ``` @@ -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//databases + +# And the collection is a directory +# curl http://127.0.0.1:3030/api/v1///collections ``` ### For dev diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..03c08d4 --- /dev/null +++ b/TODO.md @@ -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 diff --git a/digest.json b/digest.json deleted file mode 100644 index 19a7fe8..0000000 --- a/digest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "0.0.1": { - "hash": "sha256:72dbcfa96ca59ad684c62dfe3e72b2d35e6c5a7e0024c5331b005f36be122d72" - }, - "0.0.2": { - "hash": "sha256:4ed56ddb5b942c1ea110059f4838ef8e1250644ae2e6966ae72370b6ae2364aa" - }, - "0.0.3":{ - "hash": "sha256:84131fe8db95550a3a94b95308a1b6cfb85fc44aca6c40c22f56e585d77d45a5" - }, - "latest": { - "hash": "sha256:8bc6603d93a4b6bf00b006a1440a8d589329b49f370949f25ed9035045b8e5ba" - } -} diff --git a/index.js b/index.js index feb194d..2fe3406 100644 --- a/index.js +++ b/index.js @@ -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') @@ -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, @@ -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, diff --git a/gitrows.js b/lib/gitrows.js similarity index 99% rename from gitrows.js rename to lib/gitrows.js index 9c5afce..974b8bc 100644 --- a/gitrows.js +++ b/lib/gitrows.js @@ -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){ diff --git a/package.json b/package.json index e320d10..68d4189 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } }