From b8b1ea81aa1e82439c2012169321397912d845d7 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Sun, 29 Jun 2025 14:21:30 +0530 Subject: [PATCH 1/8] Clean up or save local changes --- db.json | 6 ++++ package-lock.json | 76 ++++++++++++++++++++++++++++++++--------------- package.json | 3 +- 3 files changed, 60 insertions(+), 25 deletions(-) create mode 100644 db.json diff --git a/db.json b/db.json new file mode 100644 index 000000000..82b82dda6 --- /dev/null +++ b/db.json @@ -0,0 +1,6 @@ +{ + "posts": [ + { "id": 1, "title": "Hello World" }, + { "id": 2, "title": "GitOps is cool!" } + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 60d0c463e..f98d3246b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0-beta.3", "license": "SEE LICENSE IN ./LICENSE", "dependencies": { - "@tinyhttp/app": "^2.4.0", + "@tinyhttp/app": "^2.5.2", "@tinyhttp/cors": "^2.0.1", "@tinyhttp/logger": "^2.0.0", "chalk": "^5.3.0", @@ -17,6 +17,7 @@ "dot-prop": "^9.0.0", "eta": "^3.5.0", "inflection": "^3.0.0", + "json-server": "^1.0.0-beta.3", "json5": "^2.2.3", "lowdb": "^7.0.1", "milliparsec": "^4.0.0", @@ -786,15 +787,15 @@ } }, "node_modules/@tinyhttp/app": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-2.4.0.tgz", - "integrity": "sha512-vOPiCemQRJq5twnl06dde6XnWiNbVMdVRFJWW/yC/9G0qgvV2TvzNNTxrdlz6YmyB7vIC7Fg3qS6m6gx8RbBNQ==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-2.5.2.tgz", + "integrity": "sha512-DcB3Y8GQppLQlO2VxRYF7LzTEAoZb+VRQXuIsErcu2fNaM1xdx6NQZDso5rlZUiaeg6KYYRfU34N4XkZbv6jSA==", "license": "MIT", "dependencies": { "@tinyhttp/cookie": "2.1.1", - "@tinyhttp/proxy-addr": "2.2.0", - "@tinyhttp/req": "2.2.4", - "@tinyhttp/res": "2.2.4", + "@tinyhttp/proxy-addr": "2.2.1", + "@tinyhttp/req": "2.2.5", + "@tinyhttp/res": "2.2.5", "@tinyhttp/router": "2.2.3", "header-range-parser": "1.1.3", "regexparam": "^2.0.2" @@ -882,9 +883,9 @@ } }, "node_modules/@tinyhttp/forwarded": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/forwarded/-/forwarded-2.1.1.tgz", - "integrity": "sha512-nO3kq0R1LRl2+CAMlnggm22zE6sT8gfvGbNvSitV6F9eaUSurHP0A8YZFMihSkugHxK+uIegh1TKrqgD8+lyGQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@tinyhttp/forwarded/-/forwarded-2.1.2.tgz", + "integrity": "sha512-9H/eulJ68ElY/+zYpTpNhZ7vxGV+cnwaR6+oQSm7bVgZMyuQfgROW/qvZuhmgDTIxnGMXst+Ba4ij6w6Krcs3w==", "license": "MIT", "engines": { "node": ">=12.20.0" @@ -905,12 +906,12 @@ } }, "node_modules/@tinyhttp/proxy-addr": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-2.2.0.tgz", - "integrity": "sha512-WM/PPL9xNvrs7/8Om5nhKbke5FHrP3EfjOOR+wBnjgESfibqn0K7wdUTnzSLp1lBmemr88os1XvzwymSgaibyA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-2.2.1.tgz", + "integrity": "sha512-BicqMqVI91hHq2BQmnqJUh0FQUnx7DncwSGgu2ghlh+JZG2rHK2ZN/rXkfhrx1rrUw6hnd0L36O8GPMh01+dDQ==", "license": "MIT", "dependencies": { - "@tinyhttp/forwarded": "2.1.1", + "@tinyhttp/forwarded": "2.1.2", "ipaddr.js": "^2.2.0" }, "engines": { @@ -918,9 +919,9 @@ } }, "node_modules/@tinyhttp/req": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/req/-/req-2.2.4.tgz", - "integrity": "sha512-lQAZIAo0NOeghxFOZS57tQzxpHSPPLs9T68Krq2BncEBImKwqaDKUt7M9Y5Kb+rvC/GwIL3LeErhkg7f5iG4IQ==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tinyhttp/req/-/req-2.2.5.tgz", + "integrity": "sha512-trfsXwtmsNjMcGKcLJ+45h912kLRqBQCQD06ams3Tq0kf4gHLxjHjoYOC1Z9yGjOn81XllRx8wqvnvr+Kbe3gw==", "license": "MIT", "dependencies": { "@tinyhttp/accepts": "2.2.3", @@ -933,16 +934,16 @@ } }, "node_modules/@tinyhttp/res": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/res/-/res-2.2.4.tgz", - "integrity": "sha512-ETBRShnO19oJyIg2XQHQoofXPWeTXPAuwnIVYkU8WaftvXd/Vz4y5+WFQDHUzKlmdGOw5fAFnrEU7pIVMeFeVA==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tinyhttp/res/-/res-2.2.5.tgz", + "integrity": "sha512-yBsqjWygpuKAVz4moWlP4hqzwiDDqfrn2mA0wviJAcgvGiyOErtlQwXY7aj3aPiCpURvxvEFO//Gdy6yV+xEpA==", "license": "MIT", "dependencies": { "@tinyhttp/content-disposition": "2.2.2", "@tinyhttp/cookie": "2.1.1", "@tinyhttp/cookie-signature": "2.1.1", "@tinyhttp/encode-url": "2.1.1", - "@tinyhttp/req": "2.2.4", + "@tinyhttp/req": "2.2.5", "@tinyhttp/send": "2.2.3", "@tinyhttp/vary": "^0.1.3", "es-escape-html": "^0.1.1", @@ -2458,6 +2459,33 @@ "dev": true, "license": "MIT" }, + "node_modules/json-server": { + "version": "1.0.0-beta.3", + "resolved": "https://registry.npmjs.org/json-server/-/json-server-1.0.0-beta.3.tgz", + "integrity": "sha512-DwE69Ep5ccwIJZBUIWEENC30Yj8bwr4Ax9W9VoIWAYnB8Sj4ReptscO8/DRHv/nXwVlmb3Bk73Ls86+VZdYkkA==", + "license": "SEE LICENSE IN ./LICENSE", + "dependencies": { + "@tinyhttp/app": "^2.4.0", + "@tinyhttp/cors": "^2.0.1", + "@tinyhttp/logger": "^2.0.0", + "chalk": "^5.3.0", + "chokidar": "^4.0.1", + "dot-prop": "^9.0.0", + "eta": "^3.5.0", + "inflection": "^3.0.0", + "json5": "^2.2.3", + "lowdb": "^7.0.1", + "milliparsec": "^4.0.0", + "sirv": "^2.0.4", + "sort-on": "^6.1.0" + }, + "bin": { + "json-server": "lib/bin.js" + }, + "engines": { + "node": ">=18.3" + } + }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -2691,9 +2719,9 @@ "license": "MIT" }, "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", + "integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==", "license": "MIT", "engines": { "node": ">= 0.6" diff --git a/package.json b/package.json index a0cfb2993..2182e37c3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "typescript-eslint": "^8.6.0" }, "dependencies": { - "@tinyhttp/app": "^2.4.0", + "@tinyhttp/app": "^2.5.2", "@tinyhttp/cors": "^2.0.1", "@tinyhttp/logger": "^2.0.0", "chalk": "^5.3.0", @@ -54,6 +54,7 @@ "dot-prop": "^9.0.0", "eta": "^3.5.0", "inflection": "^3.0.0", + "json-server": "^1.0.0-beta.3", "json5": "^2.2.3", "lowdb": "^7.0.1", "milliparsec": "^4.0.0", From 554f40fadfdbb96117cdfcff4777694b76cb23f3 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Sun, 29 Jun 2025 14:39:20 +0530 Subject: [PATCH 2/8] dockerfile added --- dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 000000000..80a66e6e8 --- /dev/null +++ b/dockerfile @@ -0,0 +1,13 @@ + +FROM node:18 + +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . . + +EXPOSE 3000 + +CMD ["npx", "json-server", "db.json", "--host", "0.0.0.0", "--port", "3000"] From 5e27eab3966e7abd60d3a628f6345ae82f772fd4 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Mon, 30 Jun 2025 12:11:50 +0530 Subject: [PATCH 3/8] manifest added --- manifests/deployment.yml | 19 +++++++++++++++++++ manifests/service.yml | 12 ++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 manifests/deployment.yml create mode 100644 manifests/service.yml diff --git a/manifests/deployment.yml b/manifests/deployment.yml new file mode 100644 index 000000000..7d66c0c8c --- /dev/null +++ b/manifests/deployment.yml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: json-server +spec: + replicas: 1 + selector: + matchLabels: + app: json-server + template: + metadata: + labels: + app: json-server + spec: + containers: + - name: json-server + image: shtita09/json-server-demo:latest + ports: + - containerPort: 3000 diff --git a/manifests/service.yml b/manifests/service.yml new file mode 100644 index 000000000..4ff0e08fa --- /dev/null +++ b/manifests/service.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: json-server-service +spec: + selector: + app: json-server + ports: + - protocol: TCP + port: 80 + targetPort: 3000 + type: NodePort From eb1aeb9f1fbe46f97a81e2ba0c701ef898d48b10 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Mon, 30 Jun 2025 13:06:40 +0530 Subject: [PATCH 4/8] manifest add --- manifests/deployment.yml | 1 + manifests/service.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index 7d66c0c8c..c953679be 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: json-server + namespace: json-server spec: replicas: 1 selector: diff --git a/manifests/service.yml b/manifests/service.yml index 4ff0e08fa..2a8217c4a 100644 --- a/manifests/service.yml +++ b/manifests/service.yml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: json-server-service + namespace: json-server spec: selector: app: json-server @@ -9,4 +10,4 @@ spec: - protocol: TCP port: 80 targetPort: 3000 - type: NodePort + type: NodePort From 80933dd49face87da42ff65231009238efb14465 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Mon, 30 Jun 2025 18:50:28 +0530 Subject: [PATCH 5/8] added readme --- README.md | 220 ++++++------------------------------------------------ setup.md | 13 ++++ 2 files changed, 37 insertions(+), 196 deletions(-) create mode 100644 setup.md diff --git a/README.md b/README.md index a325ced08..516cf87fa 100644 --- a/README.md +++ b/README.md @@ -1,209 +1,37 @@ -# json-server +# βš™οΈ GitOps with ArgoCD – JSON Server Demo -[![Node.js CI](https://github.com/typicode/json-server/actions/workflows/node.js.yml/badge.svg)](https://github.com/typicode/json-server/actions/workflows/node.js.yml) +This project demonstrates a **GitOps workflow using ArgoCD** to automatically deploy a simple `json-server` application to a Kubernetes cluster. -> [!IMPORTANT] -> Viewing beta v1 documentation – usable but expect breaking changes. For stable version, see [here](https://github.com/typicode/json-server/tree/v0) +πŸ“Œ **Showcase Ready** β€” You can include this in your resume or portfolio to demonstrate your understanding of: +- Kubernetes deployment workflows +- GitOps principles +- ArgoCD for continuous delivery +- Docker-based microservices -πŸ‘‹ _Hey! Using React, Vue or Astro? Check my new project [MistCSS](https://github.com/typicode/mistcss) to write 50% less code._ +--- -## Install +## πŸ” What This Project Demonstrates -```shell -npm install json-server -``` +- 🎯 Deploying a demo app (`json-server`) using ArgoCD +- πŸ“‚ Managing Kubernetes manifests declaratively from Git +- πŸ”„ Continuous sync between Git and the cluster +- πŸ›  Rollbacks, health checks, and namespace scoping +- πŸ”§ Manual + automatic deployment syncing -## Usage +--- -Create a `db.json` or `db.json5` file +## πŸ—‚ Project Structure -```json -{ - "posts": [ - { "id": "1", "title": "a title", "views": 100 }, - { "id": "2", "title": "another title", "views": 200 } - ], - "comments": [ - { "id": "1", "text": "a comment about post 1", "postId": "1" }, - { "id": "2", "text": "another comment about post 1", "postId": "1" } - ], - "profile": { - "name": "typicode" - } -} -``` +- β”œβ”€β”€ manifests/ +- β”‚ β”œβ”€β”€ deployment.yaml +- β”‚ └── service.yaml +- └── Dockerfile -
-View db.json5 example +--- -```json5 -{ - posts: [ - { id: '1', title: 'a title', views: 100 }, - { id: '2', title: 'another title', views: 200 }, - ], - comments: [ - { id: '1', text: 'a comment about post 1', postId: '1' }, - { id: '2', text: 'another comment about post 1', postId: '1' }, - ], - profile: { - name: 'typicode', - }, -} -``` +## πŸš€ Quick Start Instructions -You can read more about JSON5 format [here](https://github.com/json5/json5). +### 🧩 ArgoCD Setup -
- -Pass it to JSON Server CLI - -```shell -$ npx json-server db.json -``` - -Get a REST API - -```shell -$ curl http://localhost:3000/posts/1 -{ - "id": "1", - "title": "a title", - "views": 100 -} -``` - -Run `json-server --help` for a list of options - -## Sponsors ✨ - -| Sponsors | -| :---: | -| | -| | - -| Sponsors | -| :---: | -| | - -| Sponsors | | -| :---: | :---: | -| | | -| Delivery Routing Software and Route Optimization Software | | - - -[Become a sponsor and have your company logo here](https://github.com/users/typicode/sponsorship) - -## Sponsorware - -> [!NOTE] -> This project uses the [Fair Source License](https://fair.io/). Only organizations with 3+ users are kindly asked to contribute a small amount through sponsorship [sponsor](https://github.com/sponsors/typicode) for usage. __This license helps keep the project sustainable and healthy, benefiting everyone.__ -> -> For more information, FAQs, and the rationale behind this, visit [https://fair.io/](https://fair.io/). - -## Routes - -Based on the example `db.json`, you'll get the following routes: - -``` -GET /posts -GET /posts/:id -POST /posts -PUT /posts/:id -PATCH /posts/:id -DELETE /posts/:id - -# Same for comments -``` - -``` -GET /profile -PUT /profile -PATCH /profile -``` - -## Params - -### Conditions - -- ` ` β†’ `==` -- `lt` β†’ `<` -- `lte` β†’ `<=` -- `gt` β†’ `>` -- `gte` β†’ `>=` -- `ne` β†’ `!=` - -``` -GET /posts?views_gt=9000 -``` - -### Range - -- `start` -- `end` -- `limit` - -``` -GET /posts?_start=10&_end=20 -GET /posts?_start=10&_limit=10 -``` - -### Paginate - -- `page` -- `per_page` (default = 10) - -``` -GET /posts?_page=1&_per_page=25 -``` - -### Sort - -- `_sort=f1,f2` - -``` -GET /posts?_sort=id,-views -``` - -### Nested and array fields - -- `x.y.z...` -- `x.y.z[i]...` - -``` -GET /foo?a.b=bar -GET /foo?x.y_lt=100 -GET /foo?arr[0]=bar -``` - -### Embed - -``` -GET /posts?_embed=comments -GET /comments?_embed=post -``` - -## Delete - -``` -DELETE /posts/1 -DELETE /posts/1?_dependent=comments -``` - -## Serving static files - -If you create a `./public` directory, JSON Server will serve its content in addition to the REST API. - -You can also add custom directories using `-s/--static` option. - -```sh -json-server -s ./static -json-server -s ./static -s ./node_modules -``` - -## Notable differences with v0.17 - -- `id` is always a string and will be generated for you if missing -- use `_per_page` with `_page` instead of `_limit`for pagination -- use Chrome's `Network tab > throtling` to delay requests instead of `--delay` CLI option +If you haven’t installed ArgoCD yet, follow the [Setup Guide](./SETUP.md). diff --git a/setup.md b/setup.md new file mode 100644 index 000000000..0dc41c1a4 --- /dev/null +++ b/setup.md @@ -0,0 +1,13 @@ +# Install ArgoCD on Kubernetes + +# 1. Create ArgoCD namespace +kubectl create namespace argocd + +# 2. Install ArgoCD +kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml + +# 3. Expose ArgoCD UI (optional, for local testing) +kubectl port-forward svc/argocd-server -n argocd 8080:443 + +# 4. Get the initial admin password +kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d From e3ebac46f04a62049680f2bdd6a3a856e4cf194f Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Mon, 30 Jun 2025 18:53:05 +0530 Subject: [PATCH 6/8] linked setup --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 516cf87fa..e8d913584 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,4 @@ This project demonstrates a **GitOps workflow using ArgoCD** to automatically de ### 🧩 ArgoCD Setup -If you haven’t installed ArgoCD yet, follow the [Setup Guide](./SETUP.md). +If you haven’t installed ArgoCD yet, follow the [Setup Guide](./setup.md). From d64383f10283ce852e43185557a0bb6df53e9a05 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Tue, 1 Jul 2025 11:40:42 +0530 Subject: [PATCH 7/8] readme --- README.md | 220 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 196 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e8d913584..a325ced08 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,209 @@ -# βš™οΈ GitOps with ArgoCD – JSON Server Demo +# json-server -This project demonstrates a **GitOps workflow using ArgoCD** to automatically deploy a simple `json-server` application to a Kubernetes cluster. +[![Node.js CI](https://github.com/typicode/json-server/actions/workflows/node.js.yml/badge.svg)](https://github.com/typicode/json-server/actions/workflows/node.js.yml) -πŸ“Œ **Showcase Ready** β€” You can include this in your resume or portfolio to demonstrate your understanding of: -- Kubernetes deployment workflows -- GitOps principles -- ArgoCD for continuous delivery -- Docker-based microservices +> [!IMPORTANT] +> Viewing beta v1 documentation – usable but expect breaking changes. For stable version, see [here](https://github.com/typicode/json-server/tree/v0) ---- +πŸ‘‹ _Hey! Using React, Vue or Astro? Check my new project [MistCSS](https://github.com/typicode/mistcss) to write 50% less code._ -## πŸ” What This Project Demonstrates +## Install -- 🎯 Deploying a demo app (`json-server`) using ArgoCD -- πŸ“‚ Managing Kubernetes manifests declaratively from Git -- πŸ”„ Continuous sync between Git and the cluster -- πŸ›  Rollbacks, health checks, and namespace scoping -- πŸ”§ Manual + automatic deployment syncing +```shell +npm install json-server +``` ---- +## Usage -## πŸ—‚ Project Structure +Create a `db.json` or `db.json5` file -- β”œβ”€β”€ manifests/ -- β”‚ β”œβ”€β”€ deployment.yaml -- β”‚ └── service.yaml -- └── Dockerfile +```json +{ + "posts": [ + { "id": "1", "title": "a title", "views": 100 }, + { "id": "2", "title": "another title", "views": 200 } + ], + "comments": [ + { "id": "1", "text": "a comment about post 1", "postId": "1" }, + { "id": "2", "text": "another comment about post 1", "postId": "1" } + ], + "profile": { + "name": "typicode" + } +} +``` +
---- +View db.json5 example -## πŸš€ Quick Start Instructions +```json5 +{ + posts: [ + { id: '1', title: 'a title', views: 100 }, + { id: '2', title: 'another title', views: 200 }, + ], + comments: [ + { id: '1', text: 'a comment about post 1', postId: '1' }, + { id: '2', text: 'another comment about post 1', postId: '1' }, + ], + profile: { + name: 'typicode', + }, +} +``` -### 🧩 ArgoCD Setup +You can read more about JSON5 format [here](https://github.com/json5/json5). -If you haven’t installed ArgoCD yet, follow the [Setup Guide](./setup.md). +
+ +Pass it to JSON Server CLI + +```shell +$ npx json-server db.json +``` + +Get a REST API + +```shell +$ curl http://localhost:3000/posts/1 +{ + "id": "1", + "title": "a title", + "views": 100 +} +``` + +Run `json-server --help` for a list of options + +## Sponsors ✨ + +| Sponsors | +| :---: | +| | +| | + +| Sponsors | +| :---: | +| | + +| Sponsors | | +| :---: | :---: | +| | | +| Delivery Routing Software and Route Optimization Software | | + + +[Become a sponsor and have your company logo here](https://github.com/users/typicode/sponsorship) + +## Sponsorware + +> [!NOTE] +> This project uses the [Fair Source License](https://fair.io/). Only organizations with 3+ users are kindly asked to contribute a small amount through sponsorship [sponsor](https://github.com/sponsors/typicode) for usage. __This license helps keep the project sustainable and healthy, benefiting everyone.__ +> +> For more information, FAQs, and the rationale behind this, visit [https://fair.io/](https://fair.io/). + +## Routes + +Based on the example `db.json`, you'll get the following routes: + +``` +GET /posts +GET /posts/:id +POST /posts +PUT /posts/:id +PATCH /posts/:id +DELETE /posts/:id + +# Same for comments +``` + +``` +GET /profile +PUT /profile +PATCH /profile +``` + +## Params + +### Conditions + +- ` ` β†’ `==` +- `lt` β†’ `<` +- `lte` β†’ `<=` +- `gt` β†’ `>` +- `gte` β†’ `>=` +- `ne` β†’ `!=` + +``` +GET /posts?views_gt=9000 +``` + +### Range + +- `start` +- `end` +- `limit` + +``` +GET /posts?_start=10&_end=20 +GET /posts?_start=10&_limit=10 +``` + +### Paginate + +- `page` +- `per_page` (default = 10) + +``` +GET /posts?_page=1&_per_page=25 +``` + +### Sort + +- `_sort=f1,f2` + +``` +GET /posts?_sort=id,-views +``` + +### Nested and array fields + +- `x.y.z...` +- `x.y.z[i]...` + +``` +GET /foo?a.b=bar +GET /foo?x.y_lt=100 +GET /foo?arr[0]=bar +``` + +### Embed + +``` +GET /posts?_embed=comments +GET /comments?_embed=post +``` + +## Delete + +``` +DELETE /posts/1 +DELETE /posts/1?_dependent=comments +``` + +## Serving static files + +If you create a `./public` directory, JSON Server will serve its content in addition to the REST API. + +You can also add custom directories using `-s/--static` option. + +```sh +json-server -s ./static +json-server -s ./static -s ./node_modules +``` + +## Notable differences with v0.17 + +- `id` is always a string and will be generated for you if missing +- use `_per_page` with `_page` instead of `_limit`for pagination +- use Chrome's `Network tab > throtling` to delay requests instead of `--delay` CLI option From cd39177ae11c2b679b346e7fcf5cc98d127fc079 Mon Sep 17 00:00:00 2001 From: Sthit <22btcse81@suiit.ac.in> Date: Tue, 1 Jul 2025 12:01:37 +0530 Subject: [PATCH 8/8] k8s --- k8s/manifests/README.md | 37 +++++++++++++++++++ k8s/manifests/argocd-app.yml | 20 ++++++++++ {manifests => k8s/manifests}/deployment.yml | 2 +- .../service.yml => k8s/manifests/services.yml | 2 +- 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 k8s/manifests/README.md create mode 100644 k8s/manifests/argocd-app.yml rename {manifests => k8s/manifests}/deployment.yml (91%) rename manifests/service.yml => k8s/manifests/services.yml (92%) diff --git a/k8s/manifests/README.md b/k8s/manifests/README.md new file mode 100644 index 000000000..e8d913584 --- /dev/null +++ b/k8s/manifests/README.md @@ -0,0 +1,37 @@ +# βš™οΈ GitOps with ArgoCD – JSON Server Demo + +This project demonstrates a **GitOps workflow using ArgoCD** to automatically deploy a simple `json-server` application to a Kubernetes cluster. + +πŸ“Œ **Showcase Ready** β€” You can include this in your resume or portfolio to demonstrate your understanding of: +- Kubernetes deployment workflows +- GitOps principles +- ArgoCD for continuous delivery +- Docker-based microservices + +--- + +## πŸ” What This Project Demonstrates + +- 🎯 Deploying a demo app (`json-server`) using ArgoCD +- πŸ“‚ Managing Kubernetes manifests declaratively from Git +- πŸ”„ Continuous sync between Git and the cluster +- πŸ›  Rollbacks, health checks, and namespace scoping +- πŸ”§ Manual + automatic deployment syncing + +--- + +## πŸ—‚ Project Structure + +- β”œβ”€β”€ manifests/ +- β”‚ β”œβ”€β”€ deployment.yaml +- β”‚ └── service.yaml +- └── Dockerfile + + +--- + +## πŸš€ Quick Start Instructions + +### 🧩 ArgoCD Setup + +If you haven’t installed ArgoCD yet, follow the [Setup Guide](./setup.md). diff --git a/k8s/manifests/argocd-app.yml b/k8s/manifests/argocd-app.yml new file mode 100644 index 000000000..55e662451 --- /dev/null +++ b/k8s/manifests/argocd-app.yml @@ -0,0 +1,20 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: json-server-app + namespace: argocd +spec: + project: default + source: + repoURL: 'https://github.com/sthitajoshi/json-server' + targetRevision: HEAD + path: k8s/manifests + destination: + server: 'https://kubernetes.default.svc' + namespace: default + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/manifests/deployment.yml b/k8s/manifests/deployment.yml similarity index 91% rename from manifests/deployment.yml rename to k8s/manifests/deployment.yml index c953679be..b344d5a68 100644 --- a/manifests/deployment.yml +++ b/k8s/manifests/deployment.yml @@ -17,4 +17,4 @@ spec: - name: json-server image: shtita09/json-server-demo:latest ports: - - containerPort: 3000 + - containerPort: 3000 \ No newline at end of file diff --git a/manifests/service.yml b/k8s/manifests/services.yml similarity index 92% rename from manifests/service.yml rename to k8s/manifests/services.yml index 2a8217c4a..9d24dab6b 100644 --- a/manifests/service.yml +++ b/k8s/manifests/services.yml @@ -10,4 +10,4 @@ spec: - protocol: TCP port: 80 targetPort: 3000 - type: NodePort + type: NodePort \ No newline at end of file