added in License
This commit is contained in:
parent
9d40c9d7ec
commit
a2739dbbcd
27
LICENSE
Normal file
27
LICENSE
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Copyright (c) 2024 Patial Tech. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Patial Tech. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1,3 +1,6 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -31,7 +35,7 @@ func Request() func(http.Handler) http.Handler {
|
|||||||
// ID
|
// ID
|
||||||
requestID := r.Header.Get("X-Request-Id")
|
requestID := r.Header.Get("X-Request-Id")
|
||||||
if requestID == "" {
|
if requestID == "" {
|
||||||
requestID = uid.ULID()
|
requestID = uid.NewUUID()
|
||||||
}
|
}
|
||||||
ctx = context.WithValue(ctx, RequestIDKey, requestID)
|
ctx = context.WithValue(ctx, RequestIDKey, requestID)
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
// copied from https://github.com/joho/godotenv/blob/main/parser.go
|
// ported from https://github.com/joho/godotenv/blob/main/parser.go
|
||||||
//
|
//
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
// copied from https://github.com/joho/godotenv/blob/main/godotenv.go
|
// ported from https://github.com/joho/godotenv/blob/main/godotenv.go
|
||||||
//
|
//
|
||||||
|
|
||||||
// Read all env (with same file loading semantics as Load) but return values as
|
// Read all env (with same file loading semantics as Load) but return values as
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
// copied from https://github.com/joho/godotenv/blob/main/godotenv.go
|
// ported from https://github.com/joho/godotenv/blob/main/godotenv.go
|
||||||
//
|
//
|
||||||
|
|
||||||
const doubleQuoteSpecialChars = "\\\n\r\"!$`"
|
const doubleQuoteSpecialChars = "\\\n\r\"!$`"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
72
db/client.go
72
db/client.go
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -54,48 +58,52 @@ func Client() *ent.Client {
|
|||||||
return cl
|
return cl
|
||||||
}
|
}
|
||||||
|
|
||||||
// A AuditHook is an example for audit-log hook.
|
type entity interface {
|
||||||
func AuditHook(next ent.Mutator) ent.Mutator {
|
|
||||||
type Entity interface {
|
|
||||||
GetID() (int64, error)
|
GetID() (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A AuditHook is an example for audit-log hook.
|
||||||
|
func AuditHook(next ent.Mutator) ent.Mutator {
|
||||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (v ent.Value, err error) {
|
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (v ent.Value, err error) {
|
||||||
var id int64
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
saveAudit(ctx, id, m.Type(), m.Op().String(), time.Since(start), err)
|
saveAudit(ctx, m.Type(), m.Op(), v, err, time.Since(start))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
v, err = next.Mutate(ctx, m)
|
v, err = next.Mutate(ctx, m)
|
||||||
|
|
||||||
if en, ok := v.(Entity); ok {
|
|
||||||
id, _ = en.GetID()
|
|
||||||
}
|
|
||||||
logger.Info("** %v", v)
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveAudit(_ context.Context, entID int64, entT, op string, d time.Duration, err error) {
|
func saveAudit(ctx context.Context, t string, op ent.Op, v ent.Value, err error, d time.Duration) {
|
||||||
logger.Info("audit: %d, %s, %s, %s, %v", entID, entT, op, d, err)
|
if t == "Audit" {
|
||||||
// ml.SetCreatedAt(time.Now())
|
// skip Audit table operations
|
||||||
// if usr := auth.CtxUser(ctx); usr != nil {
|
return
|
||||||
// ml.SetByID(usr.ID)
|
}
|
||||||
// ml.SetBy(usr.DisplayName)
|
|
||||||
// }
|
var entOp string
|
||||||
|
switch {
|
||||||
// switch op := m.Op(); {
|
case op.Is(ent.OpCreate):
|
||||||
// case op.Is(ent.OpCreate):
|
entOp = "Create"
|
||||||
// ml.SetOperation("Create")
|
case op.Is(ent.OpDelete):
|
||||||
|
entOp = "Delete"
|
||||||
// case op.Is(ent.OpUpdate):
|
case op.Is(ent.OpDeleteOne):
|
||||||
// ml.SetOperation("Update")
|
entOp = "DeleteOne"
|
||||||
// case op.Is(ent.OpUpdateOne):
|
case op.Is(ent.OpUpdate):
|
||||||
// ml.SetOperation("UpdateOne")
|
entOp = "Update"
|
||||||
|
case op.Is(ent.OpUpdateOne):
|
||||||
// case op.Is(ent.OpDelete):
|
entOp = "UpdateOne"
|
||||||
// ml.SetOperation("Delete")
|
}
|
||||||
// case op.Is(ent.OpDeleteOne):
|
|
||||||
// ml.SetOperation("DeleteOne")
|
big.
|
||||||
// }
|
reqID := ctx.Value("RequestID")
|
||||||
|
ip := ctx.Value("RequestIP")
|
||||||
|
ua := ctx.Value("RequestUA")
|
||||||
|
|
||||||
|
if en, ok := v.(entity); ok {
|
||||||
|
id, _ := en.GetID()
|
||||||
|
logger.Info("%s %s %s-%s(%d) ip=%s ua=%s t=%v error=%e", reqID, status, op.String(), t, id, ip, ua, d, err)
|
||||||
|
} else {
|
||||||
|
logger.Info("%s %s %s-%s ip=%s ua=%s t=%v error=%e", reqID, status, op.String(), t, ip, ua, d, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package mailer
|
package mailer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package message
|
package message
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package message
|
package message
|
||||||
|
|
||||||
import _ "embed"
|
import _ "embed"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package mailer
|
package mailer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
// EmailResetPWD link to user to reset password
|
// EmailResetPWD link to user to reset password
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package crypto
|
package crypto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package crypto
|
package crypto
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package logger
|
package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
//go:build darwin
|
//go:build darwin
|
||||||
|
|
||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package open
|
package open
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
//go:build linux
|
//go:build linux
|
||||||
|
|
||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package open
|
package open
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package open
|
package open
|
||||||
|
|
||||||
// WithDefaultApp open a file, directory, or URI using the OS's default application for that object type.
|
// WithDefaultApp open a file, directory, or URI using the OS's default application for that object type.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
|
|
||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package open
|
package open
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package structs
|
package structs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package uid
|
package uid
|
||||||
|
|
||||||
import "github.com/sqids/sqids-go"
|
import "github.com/sqids/sqids-go"
|
||||||
|
23
util/uid/uuid.go
Normal file
23
util/uid/uuid.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package uid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"gitserver.in/patialtech/rano/util/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewUUID() string {
|
||||||
|
id, err := uuid.NewV7()
|
||||||
|
if err != nil {
|
||||||
|
logger.Incident(context.Background(), "New UUID", err.Error())
|
||||||
|
return fmt.Sprintf("%d", time.Now().UTC().UnixNano())
|
||||||
|
}
|
||||||
|
return id.String()
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package validate
|
package validate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import { gql } from '@urql/svelte';
|
import { gql } from '@urql/svelte';
|
||||||
export const Me = gql`
|
export const Me = gql`
|
||||||
query Me {
|
query Me {
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import { Client, cacheExchange, fetchExchange } from '@urql/svelte';
|
import { Client, cacheExchange, fetchExchange } from '@urql/svelte';
|
||||||
|
|
||||||
export function newClient(url: string) {
|
export function newClient(url: string) {
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
@ -1 +1,5 @@
|
|||||||
|
// Copyright 2024 Patial Tech. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
export let authUser = $state();
|
export let authUser = $state();
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type Snippet } from "svelte";
|
import { type Snippet } from 'svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: Snippet
|
children: Snippet;
|
||||||
}
|
}
|
||||||
const { children }: Props = $props();
|
const { children }: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
// Copyright 2024 Patial Tech. All rights reserved. // Use of this source code is governed by a BSD-style // license
|
||||||
|
that can be found in the LICENSE file.
|
||||||
|
|
||||||
<button>
|
<button>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user