Coder Social home page Coder Social logo

xanonymous-github / sxcctw Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 705 KB

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

Home Page: https://s.xcc.tw

License: MIT License

Go 69.55% HTML 2.31% Vue 8.56% TypeScript 11.06% SCSS 0.28% Shell 2.45% Dockerfile 5.78%
golang inprogress

sxcctw's Introduction

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

sxcctw's People

Contributors

xanonymous-github avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.