An open API service indexing awesome lists of open source software.

https://github.com/noueii/gonuxt-starter

Fullstack GO + Nuxt blueprint
https://github.com/noueii/gonuxt-starter

docker gin go grpc grpc-go nuxt openapi

Last synced: 8 months ago
JSON representation

Fullstack GO + Nuxt blueprint

Awesome Lists containing this project

README

          

# gonuxt-starter

## Installing

### Step 1. Docker postgres image (optional)

*This step assumes you have docker already installed on your machine*

I recommend outsourcing the database and skipping to step 3.
Self hosting a database in a production environment is easier said than done, even if everything seems to be working properly :)

1. Pulling the latest postgres image for docker

```
docker pull postgres:latest
```

2. Running your image on a container

**Syntax**
```
docker run --name [CONTAINER_NAME] -p [INTERNAL PORT:EXTERNAL PORT] -e POSTGRES_USER=[DATABASE USER NAME] -e POSTGRES_PASSWORD=[DATABASE USER PASSWORD] -d postgres
```
**My defaults**
```
docker run --name gonuxt-postgres -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=gonuxtsecret -d postgres
```

3. Connecting with your database

I recommend using psql, you would need to install postgres on your local machine.

**Syntax**
```
psql [DATABASE DRIVER]://[DATABASE USER]:[DATABASE PASSWORD]@[IP ADDRESS]:[PORT]
```

**My defaults**
```
psql postgres://root:gonuxtsecret@localhost:5432
```

If your terminall connects to the database shell, it means you have completed the setup correctly.

You can exit out of the shell with the command \q

4. Creating the database for our project

I created some Makefiles to make the setup a bit more intuitive.


You can find the commands ran inside the Makefiles at the root at the project.


In order to execute them, you will need gnu make


Based on your setup, you might want to modify the variables available inside Makefile.variable


After you are done modifying the variables, you can run the command

```
make createdb
```


This should create a database with the name set up inside the Makefile.variable

5. Creating migrations

I am using sqlc and goose for this project. Make sure to install them.
I created a folder called db with 3 other folders inside it.



  • db/schema - we write the migrations we want to apply here


  • db/queries - we write the queries for our database here


  • db/out - the output folder where sqlc generates our go code


You can find the syntax for writing migrations and queries on the official goose website.
I created some files for our small use case.