Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalalhneidi committed Jan 27, 2025
1 parent 96c9fa1 commit 42e2a6f
Show file tree
Hide file tree
Showing 19 changed files with 3,055 additions and 7,465 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# ticketing
# Ticketing

![alt text](ss.gif)

A demo microservices project using docker, kubernetes and skaffold consisting of several different services.

- **Auth Service**: Responsible for authentication and authorization usnig JWTs.
- **Client Service**: The Next.js app .
- **Expiration Service**: Responsible for notifying other services that the lock on a ticket being purchased has expired. When a user proceeds to payment, the ticket gets locked for a short amount of time to prevent it from being purchased by several users at the same time.
- **Orders Service**: Responsible for managing users' orders.
- **Payments Service**: Responsible for handling payment requests with stripe.
- **Tickets Service**: Responsible for managing tickets.

## Built with:

- Next.js
- Express.js
- MongoDB
- Redis
- Stripe
- Nats
- Ingress Nginx
2 changes: 1 addition & 1 deletion auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:16-alpine
WORKDIR /app

COPY package.json .
RUN npm i --only=prod
RUN npm i
COPY . .

CMD ["npm","start"]
10,372 changes: 2,959 additions & 7,413 deletions auth/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"joi": "^17.5.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.1.8",
"ts-node-dev": "^1.1.8",
"ts-node-dev": "^2.0.0",
"typescript": "^4.5.5"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions auth/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { globalErrorHandler } from '@jagittix/common';
import cookieSession from 'cookie-session';
import express from 'express';
import 'express-async-errors';
import router from './router';
import { globalErrorHandler } from '@jagittix/common';
import cookieSession from 'cookie-session';

const app = express();
app.set('trust proxy', true);
app.use(express.json());
app.use(
cookieSession({
signed: false,
secure: process.env.NODE_ENV !== 'test',
secure: false,
})
);
app.use(router);
Expand Down
4 changes: 2 additions & 2 deletions auth/src/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import User from './models/User';
import { Exception } from '@jagittix/common';
import { Request, Response } from 'express';
import jwt from 'jsonwebtoken';
import User from './models/User';

export const currentUser = async (req: Request, res: Response) => {
res.status(200).send({ user: req.user });
Expand Down
1 change: 1 addition & 0 deletions auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const start = async () => {
console.log('Starting up');
const { JWT_KEY, MONGO_URI } = process.env;
if (!JWT_KEY || !MONGO_URI) throw new Error('ENV VARS missing');
console.log(JWT_KEY);
await mongoose.connect(MONGO_URI);
console.log(
`Connected to ${MONGO_URI.substring(
Expand Down
4 changes: 2 additions & 2 deletions client/components/header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link';
import axios from 'axios';
import Link from 'next/link';
import { useRouter } from 'next/router';

const Header = ({ user }) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ const Header = ({ user }) => {
return (
<nav className="navbar navbar-light bg-light">
<Link href="/">
<a className="navbar-brand">GitTix</a>
<a className="navbar-brand">Ticketing</a>
</Link>
<div className="d-flex justify-content-end">
<ul className="nav d-flex align-items-center">{links}</ul>
Expand Down
3 changes: 2 additions & 1 deletion client/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Link from 'next/link';

const index = ({ user, tickets }) => {
const ticketList = tickets.map((ticket) => {
console.log(user);
const ticketList = tickets?.map((ticket) => {
return (
<tr key={ticket.id}>
<td>
Expand Down
2 changes: 1 addition & 1 deletion expiration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"bull": "^4.5.0",
"moment": "^2.29.1",
"node-nats-streaming": "^0.3.2",
"ts-node-dev": "^1.1.8",
"ts-node-dev": "^2.0.0",
"typescript": "^4.5.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion expiration/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import nats from './nats-client';
import OrderCreatedListener from './events/listeners/order-created-listener';
import nats from './nats-client';

const start = async () => {
const { NATS_CLIENT_ID, NATS_URL, NATS_CLUSTER_ID } = process.env;
Expand Down
2 changes: 1 addition & 1 deletion infra/k8s/ingress/ingress-external-name-srv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ metadata:
namespace: ingress-nginx
spec:
type: ExternalName
externalName: ingress-nginx-srv
externalName: ingress-nginx-service
36 changes: 28 additions & 8 deletions infra/k8s/ingress/ingress-srv.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,65 @@
# apiVersion: networking.k8s.io/v1
# kind: Ingress
# metadata:
# name: ingress-service
# annotations:
# nginx.ingress.kubernetes.io/use-regex: 'true'
# spec:
# ingressClassName: nginx
# rules:
# - host: ticketing.dev
# http:
# paths:
# - path: /api/users/?(.*)
# pathType: ImplementationSpecific
# backend:
# service:
# name: auth-srv
# port:
# number: 3000

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-srv
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
ingressClassName: nginx
rules:
- host: ticketing.dev
- host: ticketing.test
http:
paths:
- path: /api/users/?(.*)
pathType: Prefix
pathType: ImplementationSpecific
backend:
service:
name: auth-srv
port:
number: 3000
- path: /api/tickets/?(.*)
pathType: Prefix
pathType: ImplementationSpecific
backend:
service:
name: tickets-srv
port:
number: 3000
- path: /api/orders/?(.*)
pathType: Prefix
pathType: ImplementationSpecific
backend:
service:
name: orders-srv
port:
number: 3000
- path: /api/payments/?(.*)
pathType: Prefix
pathType: ImplementationSpecific
backend:
service:
name: payments-srv
port:
number: 3000
- path: /?(.*)
pathType: Prefix
pathType: ImplementationSpecific
backend:
service:
name: client-srv
Expand Down
2 changes: 1 addition & 1 deletion nats-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@types/node": "^17.0.13",
"node-nats-streaming": "^0.3.2",
"ts-node-dev": "^1.1.8",
"ts-node-dev": "^2.0.0",
"typescript": "^4.5.5"
}
}
2 changes: 1 addition & 1 deletion orders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"mongoose": "^6.1.8",
"mongoose-update-if-current": "^1.4.0",
"node-nats-streaming": "^0.3.2",
"ts-node-dev": "^1.1.8",
"ts-node-dev": "^2.0.0",
"typescript": "^4.5.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion payments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"mongoose-update-if-current": "^1.4.0",
"node-nats-streaming": "^0.3.2",
"stripe": "^8.202.0",
"ts-node-dev": "^1.1.8",
"ts-node-dev": "^2.0.0",
"typescript": "^4.5.5"
},
"devDependencies": {
Expand Down
53 changes: 27 additions & 26 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
apiVersion: skaffold/v2beta26
apiVersion: skaffold/v4beta12
kind: Config
deploy:
kubectl:
manifests:
- infra/k8s/*
build:
local:
push: false
artifacts:
- context: auth
image: jamalalhneidi/auth
docker:
dockerfile: Dockerfile
- image: jamalalhneidi/auth
context: auth
sync:
manual:
- src: 'src/**/*.ts'
- src: src/**/*.ts
dest: .
- context: client
image: jamalalhneidi/client
docker:
dockerfile: Dockerfile
- image: jamalalhneidi/client
context: client
sync:
manual:
- src: '**/*.js'
dest: .
- context: tickets
image: jamalalhneidi/tickets
docker:
dockerfile: Dockerfile
- image: jamalalhneidi/tickets
context: tickets
sync:
manual:
- src: 'src/**/*.js'
- src: src/**/*.js
dest: .
- context: orders
image: jamalalhneidi/orders
docker:
dockerfile: Dockerfile
- image: jamalalhneidi/orders
context: orders
sync:
manual:
- src: 'src/**/*.js'
- src: src/**/*.js
dest: .
- context: expiration
image: jamalalhneidi/expiration
docker:
dockerfile: Dockerfile
- image: jamalalhneidi/expiration
context: expiration
sync:
manual:
- src: 'src/**/*.js'
- src: src/**/*.js
dest: .
- context: payments
image: jamalalhneidi/payments
docker:
dockerfile: Dockerfile
- image: jamalalhneidi/payments
context: payments
sync:
manual:
- src: 'src/**/*.js'
- src: src/**/*.js
dest: .
docker:
dockerfile: Dockerfile
local:
push: false
manifests:
rawYaml:
- infra/k8s/*
deploy:
kubectl: {}
Binary file added ss.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tickets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mongoose": "^6.1.8",
"mongoose-update-if-current": "^1.4.0",
"node-nats-streaming": "^0.3.2",
"ts-node-dev": "^1.1.8",
"ts-node-dev": "^2.0.0",
"typescript": "^4.5.5"
},
"devDependencies": {
Expand Down

0 comments on commit 42e2a6f

Please sign in to comment.