## 九、Star History
+
[](https://starchart.cc/usual2970/certimate)
diff --git a/README_EN.md b/README_EN.md
index 4d1794ea..9064b8b6 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -15,8 +15,8 @@ Certimate was created to solve the above-mentioned issues and has the following
Related articles:
-* [Why Certimate?](https://docs.certimate.me/blog/why-certimate)
-* [Introduction to Domain Variables and Deployment Authorization Groups](https://docs.certimate.me/blog/multi-deployer)
+- [Why Certimate?](https://docs.certimate.me/blog/why-certimate)
+- [Introduction to Domain Variables and Deployment Authorization Groups](https://docs.certimate.me/blog/multi-deployer)
Certimate aims to provide users with a secure and user-friendly SSL certificate management solution. For usage documentation, please visit.[https://docs.certimate.me](https://docs.certimate.me)
@@ -96,10 +96,10 @@ password:1234567890
The workflow of Certimate is as follows:
-* Users fill in the certificate application information on the Certimate management page, including domain name, authorization information for the DNS provider, and authorization information for the service provider to deploy to.
-* Certimate sends a request to the certificate vendor's API to apply for an SSL certificate.
-* Certimate stores the certificate information, including the certificate content, private key, validity period, etc., and automatically renews the certificate when it is about to expire.
-* Certimate sends a deployment request to the service provider's API to deploy the certificate to the service provider's servers.
+- Users fill in the certificate application information on the Certimate management page, including domain name, authorization information for the DNS provider, and authorization information for the service provider to deploy to.
+- Certimate sends a request to the certificate vendor's API to apply for an SSL certificate.
+- Certimate stores the certificate information, including the certificate content, private key, validity period, etc., and automatically renews the certificate when it is about to expire.
+- Certimate sends a deployment request to the service provider's API to deploy the certificate to the service provider's servers.
This involves authorization information for the domain, DNS provider, and deployment service provider.
@@ -153,14 +153,14 @@ Certimate is a free and open-source project, licensed under the [MIT License](LI
You can support the development of Certimate in the following ways:
-* **Submit Code**: If you find a bug or have new feature requests, and you have relevant experience, [you can submit code to us](CONTRIBUTING_EN.md).
-* **Submit an Issue**: For feature suggestions or bugs, you can [submit an issue](https://github.com/usual2970/certimate/issues) to us.
+- **Submit Code**: If you find a bug or have new feature requests, and you have relevant experience, [you can submit code to us](CONTRIBUTING_EN.md).
+- **Submit an Issue**: For feature suggestions or bugs, you can [submit an issue](https://github.com/usual2970/certimate/issues) to us.
Support for more service providers, UI enhancements, bug fixes, and documentation improvements are all welcome. We encourage everyone to submit pull requests (PRs).
## Join the Community
-* [Telegram-a new era of messaging](https://t.me/+ZXphsppxUg41YmVl)
-* Wechat Group
+- [Telegram-a new era of messaging](https://t.me/+ZXphsppxUg41YmVl)
+- Wechat Group
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 385bc989..858148e8 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,10 +1,10 @@
-version: '3.0'
+version: "3.0"
services:
- certimate:
- image: registry.cn-shanghai.aliyuncs.com/usual2970/certimate:latest
- container_name: certimate_server
- ports:
+ certimate:
+ image: registry.cn-shanghai.aliyuncs.com/usual2970/certimate:latest
+ container_name: certimate_server
+ ports:
- 8090:8090
- volumes:
+ volumes:
- ./data:/app/pb_data
- restart: unless-stopped
\ No newline at end of file
+ restart: unless-stopped
diff --git a/internal/applicant/aliyun.go b/internal/applicant/aliyun.go
index 6ab27e44..0b0dc61d 100644
--- a/internal/applicant/aliyun.go
+++ b/internal/applicant/aliyun.go
@@ -1,12 +1,13 @@
package applicant
import (
- "certimate/internal/domain"
"encoding/json"
"fmt"
"os"
"github.com/go-acme/lego/v4/providers/dns/alidns"
+
+ "certimate/internal/domain"
)
type aliyun struct {
@@ -20,7 +21,6 @@ func NewAliyun(option *ApplyOption) Applicant {
}
func (a *aliyun) Apply() (*Certificate, error) {
-
access := &domain.AliyunAccess{}
json.Unmarshal([]byte(a.option.Access), access)
diff --git a/internal/applicant/applicant.go b/internal/applicant/applicant.go
index fd869f1d..2385bbad 100644
--- a/internal/applicant/applicant.go
+++ b/internal/applicant/applicant.go
@@ -1,8 +1,6 @@
package applicant
import (
- "certimate/internal/domain"
- "certimate/internal/utils/app"
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
@@ -18,6 +16,9 @@ import (
"github.com/go-acme/lego/v4/lego"
"github.com/go-acme/lego/v4/registration"
"github.com/pocketbase/pocketbase/models"
+
+ "certimate/internal/domain"
+ "certimate/internal/utils/app"
)
const (
@@ -66,19 +67,21 @@ type ApplyOption struct {
Timeout int64 `json:"timeout"`
}
-type MyUser struct {
+type ApplyUser struct {
Email string
Registration *registration.Resource
key crypto.PrivateKey
}
-func (u *MyUser) GetEmail() string {
+func (u *ApplyUser) GetEmail() string {
return u.Email
}
-func (u MyUser) GetRegistration() *registration.Resource {
+
+func (u ApplyUser) GetRegistration() *registration.Resource {
return u.Registration
}
-func (u *MyUser) GetPrivateKey() crypto.PrivateKey {
+
+func (u *ApplyUser) GetPrivateKey() crypto.PrivateKey {
return u.key
}
@@ -87,7 +90,6 @@ type Applicant interface {
}
func Get(record *models.Record) (Applicant, error) {
-
if record.GetString("applyConfig") == "" {
return nil, errors.New("apply config is empty")
}
@@ -97,7 +99,6 @@ func Get(record *models.Record) (Applicant, error) {
record.UnmarshalJSONField("applyConfig", applyConfig)
access, err := app.GetApp().Dao().FindRecordById("access", applyConfig.Access)
-
if err != nil {
return nil, fmt.Errorf("access record not found: %w", err)
}
@@ -129,7 +130,6 @@ func Get(record *models.Record) (Applicant, error) {
default:
return nil, errors.New("unknown config type")
}
-
}
type SSLProviderConfig struct {
@@ -162,7 +162,7 @@ func apply(option *ApplyOption, provider challenge.Provider) (*Certificate, erro
return nil, err
}
- myUser := MyUser{
+ myUser := ApplyUser{
Email: option.Email,
key: privateKey,
}
@@ -213,7 +213,6 @@ func apply(option *ApplyOption, provider challenge.Provider) (*Certificate, erro
IssuerCertificate: string(certificates.IssuerCertificate),
Csr: string(certificates.CSR),
}, nil
-
}
func getReg(client *lego.Client, sslProvider *SSLProviderConfig) (*registration.Resource, error) {
diff --git a/internal/applicant/cloudflare.go b/internal/applicant/cloudflare.go
index a2e9e061..75d083fd 100644
--- a/internal/applicant/cloudflare.go
+++ b/internal/applicant/cloudflare.go
@@ -1,12 +1,13 @@
package applicant
import (
- "certimate/internal/domain"
"encoding/json"
"fmt"
"os"
cf "github.com/go-acme/lego/v4/providers/dns/cloudflare"
+
+ "certimate/internal/domain"
)
type cloudflare struct {
diff --git a/internal/applicant/godaddy.go b/internal/applicant/godaddy.go
index 911ee7cd..adcfe13b 100644
--- a/internal/applicant/godaddy.go
+++ b/internal/applicant/godaddy.go
@@ -1,12 +1,13 @@
package applicant
import (
- "certimate/internal/domain"
"encoding/json"
"fmt"
"os"
godaddyProvider "github.com/go-acme/lego/v4/providers/dns/godaddy"
+
+ "certimate/internal/domain"
)
type godaddy struct {
@@ -20,7 +21,6 @@ func NewGodaddy(option *ApplyOption) Applicant {
}
func (a *godaddy) Apply() (*Certificate, error) {
-
access := &domain.GodaddyAccess{}
json.Unmarshal([]byte(a.option.Access), access)
diff --git a/internal/applicant/huaweicloud.go b/internal/applicant/huaweicloud.go
index 8da5f6ae..294e95a6 100644
--- a/internal/applicant/huaweicloud.go
+++ b/internal/applicant/huaweicloud.go
@@ -1,12 +1,13 @@
package applicant
import (
- "certimate/internal/domain"
"encoding/json"
"fmt"
"os"
huaweicloudProvider "github.com/go-acme/lego/v4/providers/dns/huaweicloud"
+
+ "certimate/internal/domain"
)
type huaweicloud struct {
@@ -20,7 +21,6 @@ func NewHuaweiCloud(option *ApplyOption) Applicant {
}
func (t *huaweicloud) Apply() (*Certificate, error) {
-
access := &domain.HuaweiCloudAccess{}
json.Unmarshal([]byte(t.option.Access), access)
@@ -28,7 +28,7 @@ func (t *huaweicloud) Apply() (*Certificate, error) {
os.Setenv("HUAWEICLOUD_ACCESS_KEY_ID", access.AccessKeyId)
os.Setenv("HUAWEICLOUD_SECRET_ACCESS_KEY", access.SecretAccessKey)
os.Setenv("HUAWEICLOUD_PROPAGATION_TIMEOUT", fmt.Sprintf("%d", t.option.Timeout))
-
+
dnsProvider, err := huaweicloudProvider.NewDNSProvider()
if err != nil {
return nil, err
diff --git a/internal/applicant/namesilo.go b/internal/applicant/namesilo.go
index 69f6277a..0f2aa155 100644
--- a/internal/applicant/namesilo.go
+++ b/internal/applicant/namesilo.go
@@ -1,12 +1,13 @@
package applicant
import (
- "certimate/internal/domain"
"encoding/json"
"fmt"
"os"
namesiloProvider "github.com/go-acme/lego/v4/providers/dns/namesilo"
+
+ "certimate/internal/domain"
)
type namesilo struct {
@@ -20,7 +21,6 @@ func NewNamesilo(option *ApplyOption) Applicant {
}
func (a *namesilo) Apply() (*Certificate, error) {
-
access := &domain.NameSiloAccess{}
json.Unmarshal([]byte(a.option.Access), access)
diff --git a/internal/applicant/tencent.go b/internal/applicant/tencent.go
index d7ed6dc9..705f63ad 100644
--- a/internal/applicant/tencent.go
+++ b/internal/applicant/tencent.go
@@ -1,12 +1,13 @@
package applicant
import (
- "certimate/internal/domain"
"encoding/json"
"fmt"
"os"
"github.com/go-acme/lego/v4/providers/dns/tencentcloud"
+
+ "certimate/internal/domain"
)
type tencent struct {
@@ -20,14 +21,13 @@ func NewTencent(option *ApplyOption) Applicant {
}
func (t *tencent) Apply() (*Certificate, error) {
-
access := &domain.TencentAccess{}
json.Unmarshal([]byte(t.option.Access), access)
os.Setenv("TENCENTCLOUD_SECRET_ID", access.SecretId)
os.Setenv("TENCENTCLOUD_SECRET_KEY", access.SecretKey)
os.Setenv("TENCENTCLOUD_PROPAGATION_TIMEOUT", fmt.Sprintf("%d", t.option.Timeout))
-
+
dnsProvider, err := tencentcloud.NewDNSProvider()
if err != nil {
return nil, err
diff --git a/internal/deployer/aliyun.go b/internal/deployer/aliyun.go
index ce8f0a2d..9c56e6df 100644
--- a/internal/deployer/aliyun.go
+++ b/internal/deployer/aliyun.go
@@ -1,12 +1,13 @@
package deployer
import (
- "certimate/internal/domain"
"context"
"encoding/json"
"fmt"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
+
+ "certimate/internal/domain"
)
type aliyun struct {
@@ -28,7 +29,6 @@ func NewAliyun(option *DeployerOption) (Deployer, error) {
}
a.client = client
return a, nil
-
}
func (a *aliyun) GetID() string {
@@ -48,13 +48,11 @@ func (a *aliyun) Deploy(ctx context.Context) error {
Force: true,
},
})
-
if err != nil {
return fmt.Errorf("deploy aliyun oss error: %w", err)
}
return nil
-
}
func (a *aliyun) createClient(accessKeyId, accessKeySecret string) (*oss.Client, error) {
diff --git a/internal/deployer/aliyun_cdn.go b/internal/deployer/aliyun_cdn.go
index d0f1edd4..0de5959f 100644
--- a/internal/deployer/aliyun_cdn.go
+++ b/internal/deployer/aliyun_cdn.go
@@ -1,8 +1,6 @@
package deployer
import (
- "certimate/internal/domain"
- "certimate/internal/utils/rand"
"context"
"encoding/json"
"fmt"
@@ -11,6 +9,9 @@ import (
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
util "github.com/alibabacloud-go/tea-utils/v2/service"
"github.com/alibabacloud-go/tea/tea"
+
+ "certimate/internal/domain"
+ "certimate/internal/utils/rand"
)
type AliyunCdn struct {
@@ -46,7 +47,6 @@ func (a *AliyunCdn) GetInfo() []string {
}
func (a *AliyunCdn) Deploy(ctx context.Context) error {
-
certName := fmt.Sprintf("%s-%s-%s", a.option.Domain, a.option.DomainId, rand.RandStr(6))
setCdnDomainSSLCertificateRequest := &cdn20180510.SetCdnDomainSSLCertificateRequest{
DomainName: tea.String(getDeployString(a.option.DeployConfig, "domain")),
diff --git a/internal/deployer/aliyun_esa.go b/internal/deployer/aliyun_esa.go
index 27ce040f..2115d796 100644
--- a/internal/deployer/aliyun_esa.go
+++ b/internal/deployer/aliyun_esa.go
@@ -6,8 +6,6 @@
package deployer
import (
- "certimate/internal/domain"
- "certimate/internal/utils/rand"
"context"
"encoding/json"
"fmt"
@@ -16,6 +14,9 @@ import (
dcdn20180115 "github.com/alibabacloud-go/dcdn-20180115/v3/client"
util "github.com/alibabacloud-go/tea-utils/v2/service"
"github.com/alibabacloud-go/tea/tea"
+
+ "certimate/internal/domain"
+ "certimate/internal/utils/rand"
)
type AliyunEsa struct {
@@ -51,7 +52,6 @@ func (a *AliyunEsa) GetInfo() []string {
}
func (a *AliyunEsa) Deploy(ctx context.Context) error {
-
certName := fmt.Sprintf("%s-%s-%s", a.option.Domain, a.option.DomainId, rand.RandStr(6))
setDcdnDomainSSLCertificateRequest := &dcdn20180115.SetDcdnDomainSSLCertificateRequest{
DomainName: tea.String(getDeployString(a.option.DeployConfig, "domain")),
diff --git a/internal/deployer/deployer.go b/internal/deployer/deployer.go
index 1a6497a9..d764c37d 100644
--- a/internal/deployer/deployer.go
+++ b/internal/deployer/deployer.go
@@ -1,9 +1,6 @@
package deployer
import (
- "certimate/internal/applicant"
- "certimate/internal/domain"
- "certimate/internal/utils/app"
"context"
"encoding/json"
"errors"
@@ -11,6 +8,10 @@ import (
"strings"
"github.com/pocketbase/pocketbase/models"
+
+ "certimate/internal/applicant"
+ "certimate/internal/domain"
+ "certimate/internal/utils/app"
)
const (
@@ -61,7 +62,6 @@ func Gets(record *models.Record, cert *applicant.Certificate) ([]Deployer, error
for _, deployConfig := range deployConfigs {
deployer, err := getWithDeployConfig(record, cert, deployConfig)
-
if err != nil {
return nil, err
}
@@ -70,13 +70,10 @@ func Gets(record *models.Record, cert *applicant.Certificate) ([]Deployer, error
}
return rs, nil
-
}
func getWithDeployConfig(record *models.Record, cert *applicant.Certificate, deployConfig domain.DeployConfig) (Deployer, error) {
-
access, err := app.GetApp().Dao().FindRecordById("access", deployConfig.Access)
-
if err != nil {
return nil, fmt.Errorf("access record not found: %w", err)
}
@@ -169,5 +166,4 @@ func getDeployVariables(conf domain.DeployConfig) map[string]string {
}
return rs
-
}
diff --git a/internal/deployer/local.go b/internal/deployer/local.go
index d092db95..f358215b 100644
--- a/internal/deployer/local.go
+++ b/internal/deployer/local.go
@@ -10,8 +10,7 @@ import (
"runtime"
)
-type localAccess struct {
-}
+type localAccess struct{}
type local struct {
option *DeployerOption
diff --git a/internal/deployer/qiniu.go b/internal/deployer/qiniu.go
index 637b1167..46ccee10 100644
--- a/internal/deployer/qiniu.go
+++ b/internal/deployer/qiniu.go
@@ -2,8 +2,6 @@ package deployer
import (
"bytes"
- "certimate/internal/domain"
- xhttp "certimate/internal/utils/http"
"context"
"encoding/json"
"fmt"
@@ -11,6 +9,9 @@ import (
"net/http"
"github.com/qiniu/go-sdk/v7/auth"
+
+ "certimate/internal/domain"
+ xhttp "certimate/internal/utils/http"
)
const qiniuGateway = "http://api.qiniu.com"
@@ -42,7 +43,6 @@ func (q *qiuniu) GetInfo() []string {
}
func (q *qiuniu) Deploy(ctx context.Context) error {
-
// 上传证书
certId, err := q.uploadCert()
if err != nil {
diff --git a/internal/deployer/qiniu_test.go b/internal/deployer/qiniu_test.go
index 35b0746a..38b54960 100644
--- a/internal/deployer/qiniu_test.go
+++ b/internal/deployer/qiniu_test.go
@@ -1,10 +1,11 @@
package deployer
import (
- "certimate/internal/applicant"
"testing"
"github.com/qiniu/go-sdk/v7/auth"
+
+ "certimate/internal/applicant"
)
func Test_qiuniu_uploadCert(t *testing.T) {
diff --git a/internal/deployer/ssh.go b/internal/deployer/ssh.go
index c7a03d4c..a534b5f6 100644
--- a/internal/deployer/ssh.go
+++ b/internal/deployer/ssh.go
@@ -103,7 +103,6 @@ func (s *ssh) sshExecCommand(client *sshPkg.Client, command string) (error, stri
}
func (s *ssh) upload(client *sshPkg.Client, content, path string) error {
-
sftpCli, err := sftp.NewClient(client)
if err != nil {
return fmt.Errorf("failed to create sftp client: %w", err)
@@ -129,7 +128,6 @@ func (s *ssh) upload(client *sshPkg.Client, content, path string) error {
}
func (s *ssh) getClient(access *sshAccess) (*sshPkg.Client, error) {
-
var authMethod sshPkg.AuthMethod
if access.Key != "" {
diff --git a/internal/deployer/ssh_test.go b/internal/deployer/ssh_test.go
index 909b68e2..c9b1e85a 100644
--- a/internal/deployer/ssh_test.go
+++ b/internal/deployer/ssh_test.go
@@ -8,5 +8,5 @@ import (
func TestPath(t *testing.T) {
dir := path.Dir("./a/b/c")
- os.MkdirAll(dir, 0755)
+ os.MkdirAll(dir, 0o755)
}
diff --git a/internal/deployer/tencent_cdn.go b/internal/deployer/tencent_cdn.go
index 9c1b96b1..3da84775 100644
--- a/internal/deployer/tencent_cdn.go
+++ b/internal/deployer/tencent_cdn.go
@@ -1,8 +1,6 @@
package deployer
import (
- "certimate/internal/domain"
- "certimate/internal/utils/rand"
"context"
"encoding/base64"
"encoding/json"
@@ -13,6 +11,9 @@ import (
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
ssl "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl/v20191205"
+
+ "certimate/internal/domain"
+ "certimate/internal/utils/rand"
)
type tencentCdn struct {
@@ -22,7 +23,6 @@ type tencentCdn struct {
}
func NewTencentCdn(option *DeployerOption) (Deployer, error) {
-
access := &domain.TencentAccess{}
if err := json.Unmarshal([]byte(option.Access), access); err != nil {
return nil, fmt.Errorf("failed to unmarshal tencent access: %w", err)
@@ -49,7 +49,6 @@ func (t *tencentCdn) GetInfo() []string {
}
func (t *tencentCdn) Deploy(ctx context.Context) error {
-
// 上传证书
certId, err := t.uploadCert()
if err != nil {
@@ -65,7 +64,6 @@ func (t *tencentCdn) Deploy(ctx context.Context) error {
}
func (t *tencentCdn) uploadCert() (string, error) {
-
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "ssl.tencentcloudapi.com"
@@ -116,7 +114,6 @@ func (t *tencentCdn) deploy(certId string) error {
// 返回的resp是一个DeployCertificateInstanceResponse的实例,与请求对象对应
resp, err := client.DeployCertificateInstance(request)
-
if err != nil {
return fmt.Errorf("failed to deploy certificate: %w", err)
}
diff --git a/internal/deployer/webhook.go b/internal/deployer/webhook.go
index 56486585..ce84f312 100644
--- a/internal/deployer/webhook.go
+++ b/internal/deployer/webhook.go
@@ -2,11 +2,12 @@ package deployer
import (
"bytes"
- xhttp "certimate/internal/utils/http"
"context"
"encoding/json"
"fmt"
"net/http"
+
+ xhttp "certimate/internal/utils/http"
)
type webhookAccess struct {
@@ -26,7 +27,6 @@ type webhook struct {
}
func NewWebhook(option *DeployerOption) (Deployer, error) {
-
return &webhook{
option: option,
infos: make([]string, 0),
diff --git a/internal/domain/access.go b/internal/domain/access.go
index 80cdee59..ca1df988 100644
--- a/internal/domain/access.go
+++ b/internal/domain/access.go
@@ -33,4 +33,3 @@ type GodaddyAccess struct {
ApiKey string `json:"apiKey"`
ApiSecret string `json:"apiSecret"`
}
-
diff --git a/internal/domains/deploy.go b/internal/domains/deploy.go
index 2f48434b..0f6776c6 100644
--- a/internal/domains/deploy.go
+++ b/internal/domains/deploy.go
@@ -1,14 +1,15 @@
package domains
import (
- "certimate/internal/applicant"
- "certimate/internal/deployer"
- "certimate/internal/utils/app"
"context"
"fmt"
"time"
"github.com/pocketbase/pocketbase/models"
+
+ "certimate/internal/applicant"
+ "certimate/internal/deployer"
+ "certimate/internal/utils/app"
)
type Phase string
diff --git a/internal/domains/domains.go b/internal/domains/domains.go
index 17d59ee9..03fc24f1 100644
--- a/internal/domains/domains.go
+++ b/internal/domains/domains.go
@@ -1,11 +1,12 @@
package domains
import (
- "certimate/internal/utils/app"
"context"
"fmt"
"github.com/pocketbase/pocketbase/models"
+
+ "certimate/internal/utils/app"
)
func create(ctx context.Context, record *models.Record) error {
@@ -19,7 +20,6 @@ func create(ctx context.Context, record *models.Record) error {
app.GetApp().Logger().Error("deploy failed", "err", err)
}
}()
-
}
scheduler := app.GetScheduler()
@@ -27,7 +27,6 @@ func create(ctx context.Context, record *models.Record) error {
err := scheduler.Add(record.Id, record.GetString("crontab"), func() {
deploy(ctx, record)
})
-
if err != nil {
app.GetApp().Logger().Error("add cron job failed", "err", err)
return fmt.Errorf("add cron job failed: %w", err)
@@ -46,7 +45,6 @@ func update(ctx context.Context, record *models.Record) error {
}
if record.GetBool("rightnow") {
-
go func() {
if err := deploy(ctx, record); err != nil {
app.GetApp().Logger().Error("deploy failed", "err", err)
@@ -57,7 +55,6 @@ func update(ctx context.Context, record *models.Record) error {
err := scheduler.Add(record.Id, record.GetString("crontab"), func() {
deploy(ctx, record)
})
-
if err != nil {
app.GetApp().Logger().Error("update cron job failed", "err", err)
return fmt.Errorf("update cron job failed: %w", err)
diff --git a/internal/domains/event.go b/internal/domains/event.go
index 33d1a571..5ad38ad1 100644
--- a/internal/domains/event.go
+++ b/internal/domains/event.go
@@ -1,9 +1,9 @@
package domains
import (
- "certimate/internal/utils/app"
-
"github.com/pocketbase/pocketbase/core"
+
+ "certimate/internal/utils/app"
)
const tableName = "domains"
diff --git a/internal/domains/history.go b/internal/domains/history.go
index 8850b37b..616c7c8c 100644
--- a/internal/domains/history.go
+++ b/internal/domains/history.go
@@ -1,12 +1,13 @@
package domains
import (
- "certimate/internal/applicant"
- "certimate/internal/utils/app"
- "certimate/internal/utils/xtime"
"time"
"github.com/pocketbase/pocketbase/models"
+
+ "certimate/internal/applicant"
+ "certimate/internal/utils/app"
+ "certimate/internal/utils/xtime"
)
type historyItem struct {
@@ -62,7 +63,6 @@ func (a *history) record(phase Phase, msg string, info *RecordInfo, pass ...bool
Info: info.Info,
Time: xtime.BeijingTimeStr(),
})
-
}
func (a *history) setCert(cert *applicant.Certificate) {
diff --git a/internal/domains/init.go b/internal/domains/init.go
index 46f1dd5d..69de4018 100644
--- a/internal/domains/init.go
+++ b/internal/domains/init.go
@@ -1,9 +1,10 @@
package domains
import (
+ "context"
+
"certimate/internal/notify"
"certimate/internal/utils/app"
- "context"
)
func InitSchedule() {
@@ -34,5 +35,4 @@ func InitSchedule() {
// 启动定时任务
app.GetScheduler().Start()
app.GetApp().Logger().Info("定时任务启动成功", "total", app.GetScheduler().Total())
-
}
diff --git a/internal/notify/expire.go b/internal/notify/expire.go
index c5a546ec..985d7491 100644
--- a/internal/notify/expire.go
+++ b/internal/notify/expire.go
@@ -1,14 +1,15 @@
package notify
import (
- "certimate/internal/utils/app"
- "certimate/internal/utils/xtime"
"strconv"
"strings"
"time"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/models"
+
+ "certimate/internal/utils/app"
+ "certimate/internal/utils/xtime"
)
type msg struct {
@@ -41,7 +42,6 @@ func PushExpireMsg() {
if err := Send(msg.subject, msg.message); err != nil {
app.GetApp().Logger().Error("send expire msg", "error", err)
}
-
}
type notifyTemplates struct {
@@ -94,5 +94,4 @@ func buildMsg(records []*models.Record) *msg {
subject: title,
message: content,
}
-
}
diff --git a/internal/notify/notify.go b/internal/notify/notify.go
index 3b238d52..3334fa67 100644
--- a/internal/notify/notify.go
+++ b/internal/notify/notify.go
@@ -1,18 +1,16 @@
package notify
import (
- "certimate/internal/utils/app"
"context"
"fmt"
"strconv"
notifyPackage "github.com/nikoksr/notify"
-
"github.com/nikoksr/notify/service/dingding"
-
+ "github.com/nikoksr/notify/service/http"
"github.com/nikoksr/notify/service/telegram"
- "github.com/nikoksr/notify/service/http"
+ "certimate/internal/utils/app"
)
const (
@@ -40,7 +38,6 @@ func Send(title, content string) error {
}
func getNotifiers() ([]notifyPackage.Notifier, error) {
-
resp, err := app.GetApp().Dao().FindFirstRecordByFilter("settings", "name='notifyChannels'")
if err != nil {
return nil, fmt.Errorf("find notifyChannels error: %w", err)
@@ -77,7 +74,6 @@ func getNotifiers() ([]notifyPackage.Notifier, error) {
}
return notifiers, nil
-
}
func getWebhookNotifier(conf map[string]any) notifyPackage.Notifier {
@@ -110,7 +106,6 @@ func getDingTalkNotifier(conf map[string]any) notifyPackage.Notifier {
Token: getString(conf, "accessToken"),
Secret: getString(conf, "secret"),
})
-
}
func getString(conf map[string]any, key string) string {
diff --git a/internal/utils/http/http.go b/internal/utils/http/http.go
index 743fa015..6269ea98 100644
--- a/internal/utils/http/http.go
+++ b/internal/utils/http/http.go
@@ -35,11 +35,9 @@ func Req2GetReader(url string, method string, body io.Reader, head map[string]st
req := BuildReq(url, method, body, head)
return ToRequest(req, opts...)
-
}
func BuildReq(url string, method string, body io.Reader, head map[string]string) *http.Request {
-
// Create an http.Request instance
req, _ := http.NewRequest(method, url, body)
for k, v := range head {
diff --git a/internal/utils/variables/variables.go b/internal/utils/variables/variables.go
index 626d513b..74a7b22d 100644
--- a/internal/utils/variables/variables.go
+++ b/internal/utils/variables/variables.go
@@ -4,7 +4,6 @@ import "strings"
// Parse2Map 将变量赋值字符串解析为map
func Parse2Map(str string) map[string]string {
-
m := make(map[string]string)
lines := strings.Split(str, ";")
diff --git a/internal/utils/xtime/time.go b/internal/utils/xtime/time.go
index 745ec45b..2c074e6c 100644
--- a/internal/utils/xtime/time.go
+++ b/internal/utils/xtime/time.go
@@ -15,7 +15,6 @@ func BeijingTimeStr() string {
}
func GetTimeAfter(d time.Duration) string {
-
t := time.Now().UTC()
return t.Add(d).Format("2006-01-02 15:04:05")
diff --git a/nixpacks.toml b/nixpacks.toml
index 1d68c6bf..c56baee7 100644
--- a/nixpacks.toml
+++ b/nixpacks.toml
@@ -27,4 +27,4 @@ nixOverlays = []
nixpkgsArchive = '1f13eabcd6f5b00fe9de9575ac52c66a0e887ce6'
[start]
-cmd = './out serve --http=0.0.0.0:8090 --dir=/data/pb_data '
\ No newline at end of file
+cmd = './out serve --http=0.0.0.0:8090 --dir=/data/pb_data '
diff --git a/ui/.eslintrc.cjs b/ui/.eslintrc.cjs
index d6c95379..1281ed3a 100644
--- a/ui/.eslintrc.cjs
+++ b/ui/.eslintrc.cjs
@@ -1,18 +1,23 @@
+/**
+ * @type {import("eslint").Linter.Config}
+ */
module.exports = {
root: true,
- env: { browser: true, es2020: true },
- extends: [
- 'eslint:recommended',
- 'plugin:@typescript-eslint/recommended',
- 'plugin:react-hooks/recommended',
- ],
- ignorePatterns: ['dist', '.eslintrc.cjs'],
- parser: '@typescript-eslint/parser',
- plugins: ['react-refresh'],
+ env: {
+ browser: true,
+ node: true,
+ es2020: true,
+ },
+ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended", "plugin:react-hooks/recommended"],
+ ignorePatterns: ["dist", ".eslintrc.cjs"],
+ parser: "@typescript-eslint/parser",
+ plugins: ["react-refresh"],
rules: {
- 'react-refresh/only-export-components': [
- 'warn',
- { allowConstantExport: true },
+ "react-refresh/only-export-components": [
+ "warn",
+ {
+ allowConstantExport: true,
+ },
],
},
-}
+};
diff --git a/ui/.prettierrc.cjs b/ui/.prettierrc.cjs
new file mode 100644
index 00000000..6eab4828
--- /dev/null
+++ b/ui/.prettierrc.cjs
@@ -0,0 +1,20 @@
+/**
+ * @type {import("prettier").Config}
+ */
+module.exports = {
+ arrowParens: "always",
+ bracketSpacing: true,
+ editorconfig: true,
+ htmlWhitespaceSensitivity: "ignore",
+ jsxSingleQuote: false,
+ endOfLine: "crlf",
+ printWidth: 160,
+ proseWrap: "preserve",
+ quoteProps: "as-needed",
+ semi: true,
+ singleQuote: false,
+ tabs: false,
+ tabWidth: 2,
+ trailingComma: "es5",
+ useTabs: false,
+};
diff --git a/ui/README.md b/ui/README.md
index e1cdc89d..85a6989e 100644
--- a/ui/README.md
+++ b/ui/README.md
@@ -17,12 +17,12 @@ If you are developing a production application, we recommend updating the config
export default {
// other rules...
parserOptions: {
- ecmaVersion: 'latest',
- sourceType: 'module',
- project: ['./tsconfig.json', './tsconfig.node.json', './tsconfig.app.json'],
+ ecmaVersion: "latest",
+ sourceType: "module",
+ project: ["./tsconfig.json", "./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: __dirname,
},
-}
+};
```
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
diff --git a/ui/components.json b/ui/components.json
index 46f4379c..b67a3e09 100644
--- a/ui/components.json
+++ b/ui/components.json
@@ -14,4 +14,4 @@
"components": "@/components",
"utils": "@/lib/utils"
}
-}
\ No newline at end of file
+}
diff --git a/ui/dist/assets/index-C9iolg9g.js b/ui/dist/assets/index-C9iolg9g.js
new file mode 100644
index 00000000..ae63a915
--- /dev/null
+++ b/ui/dist/assets/index-C9iolg9g.js
@@ -0,0 +1,324 @@
+var pP=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var VH=pP((n9,Ed)=>{function g1(e,t){for(var n=0;n