From 7ba38899ae561b79a00d04b2eb27df28ed2e5437 Mon Sep 17 00:00:00 2001 From: deprov447 <57551996+deprov447@users.noreply.github.com> Date: Tue, 26 Mar 2024 22:33:43 +0530 Subject: [PATCH] Update readme: `docker-compose` and `mongorestore` --- README.md | 52 +++++++++++++------------ src/frontend/content/_index.md | 7 ++++ src/frontend/content/docs/v1/env_var.md | 6 ++- src/frontend/content/docs/v1/setup.md | 26 +++++-------- 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 995b57a..c040969 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,25 @@ -![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/deprov447/median-api/Node.js%20CI/master?style=for-the-badge) -![GitHub deployments](https://img.shields.io/github/deployments/deprov447/median-api/server-median?label=Deployment%20state&style=for-the-badge) - ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/deprov447/median-api?style=for-the-badge) ![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/deprov447/median-api?style=for-the-badge) ![GitHub](https://img.shields.io/github/license/deprov447/median-server?style=for-the-badge) A GraphQL based feature rich blogging API. -See full documentation [HERE](https://median-api.deprov447.me) for API docs, configuration and deployment options. +See full documentation [HERE](https://median-api-docs.netlify.app/) for API docs, configuration and deployment options. --- -# Features - -## Lightweight - -Median API is very lightweight as compared to other REST based API. And the main reason is that you get only the content you request for, which is not possible (or atleast cumbersome) in REST architecture. - -For example if you only want titles of top 3 blogs, you can just pass a query like this and in response you only get those 5 respective titles: - -[![recording89f7c02ede6efed0.gif](https://s9.gifyu.com/images/recording89f7c02ede6efed0.gif)](https://gifyu.com/image/J5h1) - -## Platform Agnostic +## Local Setup -The API is fully platform agnostic, ie any client on any platform can use this API. These include React application, Angular, Electron, Flutter, Native desktop apps on Qt etc. The possibilities are endless. +> Optional: import demo data in your mongo instance `mongorestore --verbose ./db-demo` -> Even if your platform doesnt have a library to make graphQL based request, you can use Median. See: (a blog reg this) +### Docker -## Open Source +- `docker compose up` +> Make changes in `docker-compose.yml` if required -The API is fully open source, you can freely host it on your own server with all the customizations you want. - ---- - -## Local Setup +### Local machine - Clone this repo: `git clone https://github.com/deprov447/median-server` - Run `npm install` @@ -46,9 +30,27 @@ The API is fully open source, you can freely host it on your own server with all - **DB_ADDR** : _< Mongo database connection URI >_ - **SECRET** : _< Secret key for signing auth tokens >_ - Start the server: `npm start` -- Start requesting from a client (eg: [playground](https://median-api.deprov447.me/client)) +- Start requesting from a client (eg: `http://localhost:/client`) -> Or the same can be done using [docker](https://hub.docker.com/r/deprov447/median-api) also: `docker pull deprov447/median-api` +[Dockerhub](https://hub.docker.com/r/deprov447/median-api):`docker pull deprov447/median-api` + +--- + +# Features + +## Lightweight + +Median API is very lightweight as compared to other REST based API. And the main reason is that you get only the content you request for, which is not possible (or atleast cumbersome) in REST architecture. + +## Platform Agnostic + +The API is fully platform agnostic, ie any client on any platform can use this API. These include React application, Angular, Electron, Flutter, Native desktop apps on Qt etc. The possibilities are endless. + +> Even if your platform doesnt have a library to make graphQL based request, you can use Median. See: (a blog reg this) + +## Open Source + +The API is fully open source, you can freely host it on your own server with all the customizations you want. --- diff --git a/src/frontend/content/_index.md b/src/frontend/content/_index.md index 56a857e..a55b87e 100644 --- a/src/frontend/content/_index.md +++ b/src/frontend/content/_index.md @@ -7,6 +7,13 @@ type: docs A GraphQL based feature rich blogging API. +# Quick try + +- Clone the source code `git clone https://github.com/deprov447/Median-API.git` +- Run docker containers `docker compose up` +- Open [http://localhost:8000/client](http://localhost:8000/client) in a browser and enter `http://localhost:8000/gql` in request url +- Play around + ## Lightweight Median API is very lightweight as compared to other REST based API. And the main reason is that you get only the content you request for, which is not possible (or atleast cumbersome) in REST architecture. diff --git a/src/frontend/content/docs/v1/env_var.md b/src/frontend/content/docs/v1/env_var.md index 6d8f6ad..8c192ef 100644 --- a/src/frontend/content/docs/v1/env_var.md +++ b/src/frontend/content/docs/v1/env_var.md @@ -33,6 +33,10 @@ weight: 20 The method to set environment variables depends mostly on what system you are using / where the server is deployed. But here are a few ways to set env variables: +### Docker Compose + +Make required changes in `docker-compose.yml` + ### Local System #### CLI @@ -61,4 +65,4 @@ DEPTH_LIMIT = 3 The method to set environment variables differs for every hosting provider, but most probably you can set variables from the dashboard of your hosting provider. -For example, in Heroku you can do [this](https://devcenter.heroku.com/articles/config-vars#using-the-heroku-dashboard). \ No newline at end of file +For example, in Heroku you can do [this](https://devcenter.heroku.com/articles/config-vars#using-the-heroku-dashboard). diff --git a/src/frontend/content/docs/v1/setup.md b/src/frontend/content/docs/v1/setup.md index afef102..f480362 100644 --- a/src/frontend/content/docs/v1/setup.md +++ b/src/frontend/content/docs/v1/setup.md @@ -7,6 +7,16 @@ weight: 10 # Setup +## Docker Compose + +**Prerequisites** +- [Docker](https://docs.docker.com/get-docker/) + +**Steps to Setup** +- Clone the repo +- Make required changes to `docker-compose.yml` +- Run `docker compose up` + ## Local server **Prerequisites :** @@ -20,19 +30,3 @@ weight: 10 - `npm install` : Install all the required node dependencies - `(cd src/frontend && hugo)` : Generate static front pages - `npm start` - -## Docker - -**Prerequisites** -- [Docker](https://docs.docker.com/get-docker/) - -**Steps to setup** - -You can pull the latest version of Median from [Docker Hub](https://hub.docker.com/r/deprov447/median-api). -Use `docker pull deprov447/median-api` - -**or else build your own image**: -- `git clone https://github.com/deprov447/median-api` : Clone the repo to your machine -- `cd median-api` -- `docker build --network=host -t median-api .` : Build the image -- `docker run --net=host median-api` : Start image \ No newline at end of file