Skip to content

Commit 4890270

Browse files
Merge pull request #2 from RndmCodeGuy20/staging
Newest Release
2 parents c99a452 + 791b62c commit 4890270

11 files changed

Lines changed: 701 additions & 18 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,5 @@ tests/verdict/
105105
tests/reports/
106106
tests/logs/
107107
coverage-reports/
108-
coverage
108+
coverage
109+
API_DOCUMENTATION.md

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<div align="center">
44

5+
![Logo](./assets/dyno.png)
56
![Version](https://img.shields.io/badge/version-0.0.1-blue.svg)
67
![License](https://img.shields.io/badge/license-MIT-green.svg)
78
![Go Version](https://img.shields.io/badge/go-1.24-00ADD8.svg)
@@ -16,7 +17,7 @@ Lightweight dynamic DNS service that lets you manage your DNS records without ma
1617
</div>
1718

1819
---
19-
20+
2021
## 📖 Overview
2122

2223
Dyno is a self-hosted dynamic DNS service that eliminates the manual overhead of managing DNS records. Bring your own domain and Cloudflare tokens, and let Dyno handle the rest. Perfect for home labs, development environments, and self-hosted infrastructure.

assets/dyno.png

439 KB
Loading

cmd/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func main() {
4444
}
4545
}(baseLogger)
4646

47-
baseLogger.Sugar().Infof("Starting %s srv on https://%s:%d in %s mode", "Dyno", cfg.Server.Host, cfg.Server.Port, cfg.Environment)
47+
baseLogger.Sugar().Infof("Starting %s server on https://%s:%d in %s mode", "Dyno", cfg.Server.Host, cfg.Server.Port, cfg.Environment)
4848

4949
db, err := database.NewPostgresDB(cfg.DB)
5050
if err != nil {

db/migrations/001_seed.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ CREATE TABLE IF NOT EXISTS users (
5050

5151
CREATE TABLE IF NOT EXISTS domain_records (
5252
id SERIAL PRIMARY KEY,
53-
domain_name VARCHAR(255) NOT NULL,
53+
domain_name VARCHAR(255) NOT NULL UNIQUE,
5454
current_ip_v4 INET NOT NULL,
5555
current_ip_v6 INET,
5656
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
5757
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
5858
dns_record_id_v4 VARCHAR(32) UNIQUE NULL,
5959
dns_record_id_v6 VARCHAR(32) UNIQUE NULL,
6060
provider provider NOT NULL DEFAULT 'cloudflare',
61-
user_id INT REFERENCES users(id) ON DELETE CASCADE,
62-
UNIQUE (domain_name, user_id)
61+
user_id INT REFERENCES users(id) ON DELETE CASCADE
6362
);
6463

6564
-- Add trigger to auto-update updated_at timestamp
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--+ migrate up
2+
-- ALTER TABLE domain_records
3+
-- DROP CONSTRAINT IF EXISTS domain_records_domain_name_user_id_key;
4+
-- ALTER TABLE domain_records
5+
-- ADD CONSTRAINT unique_domains UNIQUE (domain_name);

dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ARG VERSION
1818
ARG COMMIT_HASH
1919
ARG ENV
2020
ARG BUILD_TIME
21+
ARG HOST
2122

2223
# Build static binary
2324
RUN CGO_ENABLED=0 \

internal/models/api.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ package models
22

33
// CreateDomainRequest represents the payload to create a new domain
44
type CreateDomainRequest struct {
5-
UserID string `json:"user_id" binding:"required"`
6-
DomainName string `json:"domain_name" binding:"required"`
7-
IPV4 string `json:"ip_v4,omitempty" binding:"required"`
8-
IPV6 string `json:"ip_v6,omitempty"`
5+
UserID string `json:"userID" binding:"required"`
6+
DomainName string `json:"domainName" binding:"required"`
7+
IPV4 string `json:"IPV4,omitempty" binding:"required"`
8+
IPV6 string `json:"IPV6,omitempty"`
99
}
1010

1111
// UpdateDomainRequest represents the payload to update an existing domain
1212
type UpdateDomainRequest struct {
13-
UserID string `json:"user_id" binding:"required"`
14-
DomainName string `json:"domain_name"`
15-
NewIPV4 string `json:"new_ip_v4,omitempty" binding:"required"`
16-
NewIPV6 string `json:"new_ip_v6,omitempty"`
13+
UserID string `json:"userID" binding:"required"`
14+
NewIPV4 string `json:"newIPV4,omitempty" binding:"required"`
15+
NewIPV6 string `json:"newIPV6,omitempty"`
1716
}
1817

1918
// DeleteDomainRequest represents the payload to delete a domain

internal/service/domain.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ func (s *domainService) CreateDomainRecord(ctx context.Context, body models.Crea
130130
},
131131
})
132132
if err != nil {
133+
133134
s.logger.Error("Failed to create A record in Cloudflare", zap.Error(err))
134-
return "", err
135+
return "", errors.NewBadRequestError("Failed to create A record in Cloudflare", err)
135136
}
136137
dnsRecordIds = append(dnsRecordIds, response.ID)
137138
}
@@ -285,7 +286,7 @@ func (s *domainService) DeleteDomainRecord(ctx context.Context, domainId string,
285286
zap.String("dns_record_id_v6", currentDomainRecord.DNSRecordIdV6.String),
286287
)
287288

288-
if currentDomainRecord.CurrentIPV4.Valid {
289+
if currentDomainRecord.DNSRecordIdV4.Valid {
289290
_, err := s.client.DNS.Records.Delete(
290291
ctx,
291292
currentDomainRecord.DNSRecordIdV4.String,
@@ -299,7 +300,7 @@ func (s *domainService) DeleteDomainRecord(ctx context.Context, domainId string,
299300
}
300301
}
301302

302-
if currentDomainRecord.CurrentIPV6.Valid {
303+
if currentDomainRecord.DNSRecordIdV6.Valid {
303304
_, err := s.client.DNS.Records.Delete(
304305
ctx,
305306
currentDomainRecord.DNSRecordIdV6.String,

0 commit comments

Comments
 (0)