91 | ```
92 |
93 | If you have any questions or encounter issues, please don't hesitate to open an issue or reach out to the community for assistance.
94 |
95 | Happy learning! 🚀
96 |
--------------------------------------------------------------------------------
/kustomize/base/app-1/app-1.yml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | labels:
5 | app: app-1
6 | name: app-1-deployment
7 | namespace: default
8 | spec:
9 | replicas: 1
10 | selector:
11 | matchLabels:
12 | app: app-1
13 | template:
14 | metadata:
15 | labels:
16 | app: app-1
17 | spec:
18 | containers:
19 | - name: app-1-containter
20 | image: trainwithshubham/node-app-test-new:latest
21 | imagePullPolicy: Always
22 | ---
23 | apiVersion: v1
24 | kind: Service
25 | metadata:
26 | labels:
27 | app: app-1
28 | name: app-1-service
29 | namespace: default
30 | spec:
31 | type: NodePort
32 | ports:
33 | - name: webport
34 | port: 8000
35 | targetPort: 8000
36 | selector:
37 | app: app-1
38 |
--------------------------------------------------------------------------------
/kustomize/base/app-1/kustomization.yml:
--------------------------------------------------------------------------------
1 | apiVersion: kustomize.config.k8s.io/v1beta1
2 | kind: Kustomization
3 | metadata:
4 | name: app-1-mapping
5 |
6 | resources:
7 | - app-1.yml
8 |
--------------------------------------------------------------------------------
/kustomize/base/ingress/ingress.yml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.k8s.io/v1
2 | kind: Ingress
3 | metadata:
4 | name: app-ingress
5 | namespace: default
6 | spec:
7 | ingressClassName: "nginx"
8 | rules:
9 | - host: invalid.demo.trainwithshubham.com
10 | http:
11 | paths:
12 | - path: /
13 | pathType: Prefix
14 | backend:
15 | service:
16 | name: app-1-service
17 | port:
18 | number: 8000
19 |
--------------------------------------------------------------------------------
/kustomize/base/ingress/kustomization.yml:
--------------------------------------------------------------------------------
1 | apiVersion: kustomize.config.k8s.io/v1beta1
2 | kind: Kustomization
3 | metadata:
4 | name: ingress-mapping
5 |
6 | resources:
7 | - ingress.yml
8 |
--------------------------------------------------------------------------------
/kustomize/overlays/dev/dev-ingress-patch.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "op": "replace",
4 | "path": "/spec/rules/0/host",
5 | "value": "dev.demo.trainwithshubham.com"
6 | }
7 | ]
8 |
--------------------------------------------------------------------------------
/kustomize/overlays/dev/kustomization.yml:
--------------------------------------------------------------------------------
1 | apiVersion: kustomize.config.k8s.io/v1beta1
2 | kind: Kustomization
3 | metadata:
4 | name: dev-mapping
5 |
6 | namespace: dev
7 | namePrefix: dev-
8 | replicas:
9 | - name: app-1-deployment
10 | count: 1
11 |
12 | resources:
13 | - ../../base/app-1/
14 | - ../../base/ingress/
15 |
16 | patches:
17 | - target:
18 | kind: Ingress
19 | name: app-ingress
20 | path: dev-ingress-patch.json
21 |
--------------------------------------------------------------------------------
/kustomize/overlays/prd/kustomization.yml:
--------------------------------------------------------------------------------
1 | apiVersion: kustomize.config.k8s.io/v1beta1
2 | kind: Kustomization
3 | metadata:
4 | name: prd-mapping
5 |
6 | namespace: prd
7 | namePrefix: prd-
8 |
9 | replicas:
10 | - name: app-1-deployment
11 | count: 2
12 |
13 | resources:
14 | - ../../base/app-1/
15 | - ../../base/ingress/
16 |
17 |
18 | patches:
19 | - target:
20 | kind: Ingress
21 | name: app-ingress
22 | path: prd-ingress-patch.json
23 |
--------------------------------------------------------------------------------
/kustomize/overlays/prd/prd-ingress-patch.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "op": "replace",
4 | "path": "/spec/rules/0/host",
5 | "value": "prd.demo.trainwithshubham.com"
6 | }
7 | ]
8 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "my-todolist",
3 | "version": "0.1.0",
4 | "dependencies": {
5 | "body-parser": "^1.16.0",
6 | "ejs": "^2.5.5",
7 | "express": "^4.14.0",
8 | "method-override": "^3.0.0",
9 | "sanitizer": "^0.1.3"
10 | },
11 | "scripts": {
12 | "start": "node app.js",
13 | "test": "mocha --recursive --exit",
14 | "sonar": "sonar-scanner"
15 | },
16 | "author": "riaan@entersekt.com",
17 | "description": "Basic to do list exercise",
18 | "devDependencies": {
19 | "chai": "^4.2.0",
20 | "mocha": "^6.2.1",
21 | "nyc": "^14.1.1",
22 | "supertest": "^4.0.2"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sonar-project.properties:
--------------------------------------------------------------------------------
1 | # required metadata
2 | sonar.projectKey=node-todo-app
3 | sonar.projectName=Node application
4 | sonar.projectVersion=1.0.0
5 |
6 | # optional description
7 | sonar.projectDescription=This project demonstrates a simple node js.
8 |
9 | # path to source directories
10 | sonar.sources=./
11 |
12 | # The value of the property must be the key of the language.
13 | sonar.language=js
14 |
15 | # Encoding of the source code
16 | sonar.sourceEncoding=UTF-8
17 |
--------------------------------------------------------------------------------
/terraform/main.tf:
--------------------------------------------------------------------------------
1 | resource "docker_image" "todo_image" {
2 | name = "trainwithshubham/todo-app-node:latest"
3 | keep_locally = false
4 | }
5 |
6 | resource "docker_container" "todo_container" {
7 | image = docker_image.todo_image.name
8 | name = "todoapp-container"
9 | ports {
10 | internal = 8000
11 | external = 8000
12 | }
13 |
14 | depends_on = [
15 | docker_image.todo_image
16 | ]
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/terraform/terraform.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_providers {
3 | docker = {
4 | source = "kreuzwerker/docker"
5 | version = "3.0.2"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test.js:
--------------------------------------------------------------------------------
1 | // Requiring module
2 | const assert = require('assert');
3 |
4 | // We can group similar tests inside a describe block
5 | describe("Simple Calculations", () => {
6 | before(() => {
7 | console.log( "This part executes once before all tests" );
8 | });
9 |
10 | after(() => {
11 | console.log( "This part executes once after all tests" );
12 | });
13 |
14 | // We can add nested blocks for different tests
15 | describe( "Test1", () => {
16 | beforeEach(() => {
17 | console.log( "executes before every test" );
18 | });
19 |
20 | it("Is returning 5 when adding 2 + 3", () => {
21 | assert.equal(2 + 3, 5);
22 | });
23 |
24 | it("Is returning 6 when multiplying 2 * 3", () => {
25 | assert.equal(2*3, 6);
26 | });
27 | });
28 |
29 | describe("Test2", () => {
30 | beforeEach(() => {
31 | console.log( "executes before every test" );
32 | });
33 |
34 | it("Is returning 4 when adding 2 + 3", () => {
35 | assert.equal(2 + 3, 5);
36 | });
37 |
38 | it("Is returning 8 when multiplying 2 * 4", () => {
39 | assert.equal(2*4, 8);
40 | });
41 | });
42 | });
43 |
--------------------------------------------------------------------------------
/views/edititem.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Edit <%- todo %>
7 |
14 |
15 |
16 |
17 | Edit <%- todo %>:
18 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/views/todo.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Todo List APP test
5 |
89 |
90 |
91 |
92 | Hello Junoon Batch 8 (Jenkins), Write your plan on Learning Jenkins
93 |
94 | <% todolist.forEach(function(todo, index) { %>
95 | -
96 | ✘
97 | ✎
98 | <%- todo %>
99 |
100 | <% }); %>
101 |
102 |
103 |
110 |
111 |
112 |
--------------------------------------------------------------------------------