Skip to content

Xanonymous-GitHub/sxcctw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple URL Shortener on Xanonymous Core Cell.

It is An URL shortener.

Service Build Web Build API Image DB Image

BUT STILL DEVELOPED IN PROGRESS. Please go back here to see the changes later.

Try it now

  1. Create your shortened URL.
curl --location --request POST 'https://s.xcc.tw/api/url' \
--header 'Content-Type: application/json' \
--data-raw '{
    "originUrl": "https://www.dcard.tw/f/mood/p/238545781?cid=306EA5A4-D67F-41A8-903F-1456E8FDE547",
    "expireAt": "2034-11-12T11:45:26.371Z"
}'
  1. Then use it
# Go to this URL.
https://s.xcc.tw/s/v5oSt3VFD1l

TODOS

  • Add redis. (In progress...)
  • Add openAPI3 doc.
  • Add k8s yaml.
  • Add LB, Grafana, ArgoCD
  • Consider not use base62 (KGS, or else...??)
  • Add tests.
  • cronjob (maybe)

Get started

  1. Ensure using go 1.19.
# go version go1.19
go version
  1. install dependencies.
go install github.com/silenceper/gowatch@latest

If you want to re-generate the gRPC files, please install these

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest \
&& go install entgo.io/contrib/entproto/cmd/protoc-gen-entgrpc@latest

And do this:

go generate ./...
  1. start a MySQL DB.
# For example, use docker
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=sxcctw -d mysql
  1. start sxcctw db server.
./scripts/watchgo.sh sxcctw_db
  1. start sxcctw api server.
./scripts/watchgo.sh sxcctw_api

How to use? (for development)

(openAPI doc TBD)

Create new ID. (201 Created)

# Create a shortened id, which is from `https://ntut/club`,
# and set expire time at `2034-11-12T11:45:26.371Z`.
curl --location --request POST 'localhost:8080/api/url' \
--header 'Content-Type: application/json' \
--data-raw '{
    "originUrl": "https://ntut/club",
    "expireAt": "2034-11-12T11:45:26.371Z"
}'

Get URL by existed ID. (200 OK / 404 Not Found / 410 Gone)

# Get an existing shortened id (ZNkw23qpiss).
curl --location --request GET 'localhost:8080/api/url?id=ZNkw23qpiss'

Why I choose (TBD)

  • MySQL
  • Gin
  • Gorm
  • gRPC
  • Clean Architecture

About

An URL shortener. Front-end is still inprogress, because backend is still inprogress too 🥺.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published