Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cake Zone - #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HOST='http://localhost'
PORT=3000
51 changes: 1 addition & 50 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,50 +1 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

node_modules
11 changes: 11 additions & 0 deletions .microtica/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM public.ecr.aws/docker/library/node:16.16.0-slim

WORKDIR /app

COPY . .

RUN npm install

EXPOSE 3000

CMD ["node", "index.js"]
115 changes: 115 additions & 0 deletions .microtica/kube.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: "{{MIC_NAMESPACE}}"
name: "{{MIC_NAME}}"
labels:
app: "{{MIC_NAME}}"
microticaService: "{{MIC_NAME}}"
spec:
replicas: 1
selector:
matchLabels:
app: "{{MIC_NAME}}"
template:
metadata:
labels:
app: "{{MIC_NAME}}"
spec:
imagePullSecrets:
- name: {{MIC_REGISTRY}}
containers:
- name: "{{MIC_NAME}}"
image: "{{MIC_IMAGE}}"
env:
- name: MIC_EXECUTION_ID
value: "{{MIC_EXECUTION_ID}}"
- name: "PORT"
value: "{{MIC_CONTAINER_PORT}}"
ports:
- name: http
containerPort: {{MIC_CONTAINER_PORT}}
---
apiVersion: v1
kind: Service
metadata:
namespace: "{{MIC_NAMESPACE}}"
name: "{{MIC_NAME}}"
labels:
microticaService: "{{MIC_NAME}}"
annotations:
app: "{{MIC_NAME}}"
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
type: NodePort
selector:
app: "{{MIC_NAME}}"
---
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta2
metadata:
namespace: "{{MIC_NAMESPACE}}"
name: "{{MIC_NAME}}"
labels:
microticaService: "{{MIC_NAME}}"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: "{{MIC_NAME}}"
minReplicas: {{MIC_AS_MIN_REPLICAS}}
maxReplicas: {{MIC_AS_MAX_REPLICAS}}
metrics:
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{MIC_AS_MEMORY_UTILIZATION}}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{MIC_AS_CPU_UTILIZATION}}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: "{{MIC_DOMAIN_NAME}}"
namespace: "{{MIC_NAMESPACE}}"
labels:
microticaService: "{{MIC_NAME}}"
spec:
secretName: "{{MIC_DOMAIN_TLS}}"
dnsNames:
- "{{MIC_DOMAIN_NAME}}"
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "{{MIC_NAME}}"
namespace: "{{MIC_NAMESPACE}}"
spec:
ingressClassName: nginx
rules:
- host: "{{MIC_DOMAIN_NAME}}"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: "{{MIC_NAME}}"
port:
number: 80
tls:
- hosts:
- "{{MIC_DOMAIN_NAME}}"
secretName: "{{MIC_DOMAIN_TLS}}"
22 changes: 22 additions & 0 deletions .microtica/microtica.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
steps:
BuildApplication:
type: build
commands:
- echo "No command to execute"

docker:
image_name: "{{MIC_PIPELINE_NAME}}"
registry: "{{CONTAINER_REGISTRY_ID}}"
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
dockerfile: ./.microtica/Dockerfile

cache: false

DeployApplication:
type: deploy
target: kubernetes
cluster: "{{CLUSTER_ID}}"
service: "{{SERVICE_NAME}}"
namespace: "{{CLUSTER_NAMESPACE}}"
branch_filter: "{{MIC_BRANCH_FILTER}}"
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
14 changes: 14 additions & 0 deletions .microtica/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "schema://microtica/nodejs.json",
"title": "Node.js service schema",
"type": "object",
"properties": {
"inputs": {
"type": "object",
"properties": {},
"required": []
}
},
"additionalProperties": false
}
23 changes: 23 additions & 0 deletions .microtica/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Node.js
description: Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on a JavaScript engine.
logo: https://microtica.s3.eu-central-1.amazonaws.com/assets/templates/logos/nodejs.png
repo: https://github.com/microtica/templates/tree/master/nodejs

inputs:
properties:
AppName:
type: string
description: The name of the application. The name will be shown in the portal.
maxLength: 23
pattern: ^[a-z]*$
patternErrorMessage: "The app name can contain only lowercase letters."
required:
- AppName

service:
"{{AppName}}":
source: git
containerPort: "{{CONTAINER_PORT}}"
autoScaling:
minReplicas: 1
maxReplicas: 1
58 changes: 58 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import express from 'express';
import * as path from 'path';
import * as url from 'url';
import bodyParser from 'body-parser';
import fileUpload from 'express-fileupload';
//import Stripe from 'stripe';
import cookie from 'cookie-parser';
import Paytm from 'paytm-pg-node-sdk';
import session from 'express-session';
import IndexModel from './models/IndexModel.js';
import dotenv from 'dotenv';
const port = process.env.PORT || 3000;


const app = express();
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
import IndexRouter from './routes/IndexRouter.js';
import AdminRouter from './routes/AdminRouter.js';
import UserRouter from './routes/UserRouter.js';
import SellerRouter from './routes/SellerRouter.js';
//============================Middleware Section ==================================
app.use(express.json());
app.use(cookie());
app.use(Paytm());

app.use(bodyParser());
//app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));


app.use(bodyParser.json());

app.use(session({"secret":"kilvish"}));
app.use(fileUpload());

app.use("/admin",AdminRouter);
app.use("/user",UserRouter);
app.use("/seller",SellerRouter);
app.use("/",IndexRouter);

app.use(express.static(path.join(__dirname, 'public')));
//===============================================================================

app.set("view engine","ejs");
app.set("views", [
path.join(__dirname,"./views"),
path.join(__dirname,"./views/admin/"),
path.join(__dirname,"./views/web/"),

] );





app.listen(port, () => console.log(`Listening on port ${port}...`));
//app.listen(3000);
console.log("Admin Security Panel Started at local host");
Loading