Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mannuelf/bookeezy-api
GraphQL backend for Bookeezy
https://github.com/mannuelf/bookeezy-api
Last synced: about 14 hours ago
JSON representation
GraphQL backend for Bookeezy
- Host: GitHub
- URL: https://github.com/mannuelf/bookeezy-api
- Owner: mannuelf
- License: mit
- Created: 2021-09-13T20:52:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-03T23:58:43.000Z (almost 2 years ago)
- Last Synced: 2023-03-26T14:25:52.063Z (almost 2 years ago)
- Language: TypeScript
- Size: 2.98 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bookeezy API
Local development has two options:
1. Docker with standard Node.js and npm workflow, with a Docker PostgreSQL database container with mounted persistent volumes.
2. Kubernetes with Docker using Minikube.## 1. Docker and Node.js
Download & install Docker for desktop [here](https://www.docker.com/get-started) or Docker compose [here](https://docs.docker.com/compose/)
### Database
To create the PostgreSQL database run:
```bash
docker-compose up -d
```Exec into container check it's working as should be:
```bash
docker exec -it bookeezy-api_postgresql_1 /bin/sh;
```Connect application to the DB via Mikro-orm connector
```javascript
export default {
type: 'postgresql',
entities: [User, Book],
dbName: 'bookeezydb', // HERE
user: 'root', // HERE
password: 'root', // HERE
migrations: {
path: path.join(__dirname, './migrations'),
pattern: /^[\w-]+\d+\.[tj]s$/,
},
};
```### Node
Install dependencies:
```bash
yarn
```Run nodemon server which serves up the `dist` folder:
```bash
yarn watch
```Run in development mode with type checking:
```bash
yarn dev:ts
```## GraphQL
Start GraphQL Server
```bash
yarn dev:ts
```At [http://localhost:4000/graphql](http://localhost:4000/graphql), you should see:
![image](https://user-images.githubusercontent.com/210504/134149956-6c794560-60f3-4e2b-969b-0786fd5c8a35.png)
## 2. Kubernetes
Install [minikube](www.minikube.sigs.k8s.io) & [kubectl](https://kubernetes.io/docs/tasks/tools/) , out of scope for this guide.
### PostgreSQL
Start the PostgreSQL service.
To start k8's env, cd into k8's folder and run command below:
```bash
kubectl apply -f postgres-workload.yml
```That will create:
- Deployment
- PersistentVolume
- PersistentVolumeClaim
- ConfigMap
- ServiceCheck if everything works:
```bash
kubectl get svc,deploy,po,persistentvolume,persistentvolumeclaims,configmaps
``````bash
minikube start
``````bash
minikube pause
```Don't lose you environment, run this before putting computer to sleep or if you not working with minikube.
```bash
minikube unpause
``````bash
minikube stop
``````bash
minikube delete
```Change docker env context to minikube (add this to your .bash_profile or .zshrc)
```bash
eval $(minikube docker-env)
```### Other useful Kubernetes commands
```bash
kubectl create -f webserver.yml
```Test to see if it worked
```bash
kubectl get replicasets
```#### Create service
```bash
kubectl create -f webserver-scv.yml
```#### Expose service
```bash
kubectl expose deployment webserver --name=web-service --type=NodePort
```#### Get pods
```bash
kubectl get po
```#### List services
```bash
kubectl get svc
```#### Describe service
```bash
kubectl describe service db-service
```#### Minikube IP
Application is running on the Minikube VM, so get the IP
```bash
minikube ip
```#### Launch service in the browser
```bash
minikube service web-service-name
```