A full scale production grade micro services backend application for selling tickets to attend a sports event
$ npm install -g typescript
$ cd app
$ mkdir auth
$ npm init -y
$ npm install --save typescript express @types/express
$ npm install --save-dev ts-node-dev
$ tsc --init
$ npm start
$ cd skaffold
$ skaffold dev
$ minikube --profile my-profile ip
172.17.0.2
$ sudo vi /etc/hosts
#---------------------------------------------------------------------
# Minikube
#---------------------------------------------------------------------
172.17.0.2 ticketing.dev
browser --> https://ticketing.dev/api/users/currentuser
$ cd app/auth
$ npm install --save express-validator
$ curl \
--data '{"email":"notValidEmail", "password":"1"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signup \
| python -m json.tool
response:
[
{
"location": "body",
"msg": "Email must be valid",
"param": "email",
"value": "notValidEmail"
},
{
"location": "body",
"msg": "Password must be between 4 and 20 characters",
"param": "password",
"value": "1"
}
]
$ cd app/auth
$ npm install --save mongoose
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
auth-deployment-5985769fb8-j5k79 1/1 Running 0 57s
auth-mongo-deployment-55d6d9cc49-jrzsc 1/1 Running 0 57s
$ cd app/auth
$ npm install --save @types/mongoose
$ curl \
--data '{"email":"marley@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signup \
| python -m json.tool
response:
{
"__v": 0,
"_id": "5eb40ea00b8b66048cc1564e",
"email": "marley@example.com",
"password": "123456789"
}
$ curl \
--data '{"email":"marley1@example.com", "password":"123456789"}' \
--header "Content-Type: application/json" \
--request POST http://ticketing.dev/api/users/signup \
| python -m json.tool
response:
{
"__v": 0,
"_id": "5eb4248c1650af0359d5170f",
"email": "marley1@example.com",
"password": "8229ab93d0751b4cbd0f396fd8e701e36089fff0d0c848d5617e65cee9eb830fc7619135058815873d24a4adcbd1779cff1c8efec79a38647810e5b14f15ae33.ef63680bfb5151ed"
}