This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package datastore | |
import ( | |
"github.com/go-sql-driver/mysql" | |
"github.com/jinzhu/gorm" | |
) | |
func NewDB() (*gorm.DB, error) { | |
DBMS := "mysql" | |
mySqlConfig := &mysql.Config{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
"github.com/labstack/echo" | |
"github.com/labstack/echo/middleware" | |
"firebase-authentication-with-react-and-go/backend/datastore" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
import "time" | |
type User struct { | |
ID uint `gorm:"primary_key" json:"id"` | |
UUID string `json:"uuid"` | |
Email string `json:"email"` | |
CreatedAt *time.Time `json:"createdAt"` | |
UpdatedAt *time.Time `json:"updatedAt"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// ... | |
e.POST("/users", func(c echo.Context) error { | |
var params model.User | |
user := model.User{} | |
if err := c.Bind(¶ms); !errors.Is(err, nil) { | |
return c.JSON(http.StatusBadRequest, err.Error()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios' | |
import { API_URL } from '../const' | |
const api = axios.create({ | |
baseURL: API_URL, | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
responseType: 'json', | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package middleware | |
import ( | |
"context" | |
"net/http" | |
"strings" | |
firebase "firebase.google.com/go" | |
"github.com/labstack/echo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package context | |
import ( | |
fa "firebase.google.com/go/auth" | |
"github.com/labstack/echo" | |
) | |
type Context struct { | |
echo.Context | |
Token *fa.Token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
... | |
rc "firebase-authentication-with-react-and-go/backend/router/context" | |
m "firebase-authentication-with-react-and-go/backend/router/middleware" | |
) | |
func main() { | |
// ... | |
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
type User = { | |
id: string | |
uuid: string | |
name: string | |
email: string | |
createdAt: string | |
updatedAt: string | |
deletedAt: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { useBabelRc, override, useEslintRc } = require('customize-cra') | |
module.exports = override( | |
useBabelRc(), | |
useEslintRc() | |
); |