go-sh

command module
v0.0.0-...-68a4101 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2019 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Stacks

Features

  • User Sign Up & Sign In
  • Change a Password, Profile

How to Run

Initialize DB

  1. Create a database
postgres=# CREATE DATABASE go;
  1. Create a user as owner of database
postgres=# CREATE USER go WITH ENCRYPTED PASSWORD 'go';

postgres=# ALTER DATABASE go OWNER TO go;
  1. Grant all privileges to user for the database
postgres=# GRANT ALL PRIVILEGES ON DATABASE go TO go;
  1. Configure the db in db.go
// ConnectDB : connecting DB
func ConnectDB() (*DB, error) {
	db, err := gorm.Open("postgres", "host=localhost port=5432 user=go dbname=go password=go sslmode=disable")

	if err != nil {
		panic(err)
	}

	return &DB{db}, nil
}

or with Docker

host address should be edited to host.docker.internal to connect a host interface.

// ConnectDB : connecting DB
func ConnectDB() (*DB, error) {
	db, err := gorm.Open("postgres", "host=host.docker.internal port=5432 user=go dbname=go password=go sslmode=disable")

	if err != nil {
		panic(err)
	}

	return &DB{db}, nil
}

Initial Migration

$ go run ./migrations/init.go

or with Docker

$ docker build -t go-graphql-api .
$ docker run --rm go-graphql-api migrate

This will generate the users table in the database as per the User Model declared in ./model/user.go

Run the server

$ go run server.go

or with Docker

$ docker run --rm -d -p 8080:8080 go-graphql-api

GraphQL Playground

Connect to http://localhost:8080

Authentication : JWT

You need to set the Http request headers Authorization: {JWT_token}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址