https://github.com/leizhenpeng/link-shorter
缩短网址,让分享更简单 Shorten Link, Make Sharing Simpler
https://github.com/leizhenpeng/link-shorter
boltdb golang iris qwik qwik-city url-shortener
Last synced: 12 months ago
JSON representation
缩短网址,让分享更简单 Shorten Link, Make Sharing Simpler
- Host: GitHub
- URL: https://github.com/leizhenpeng/link-shorter
- Owner: Leizhenpeng
- Created: 2023-01-17T07:54:42.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T04:26:11.000Z (over 3 years ago)
- Last Synced: 2025-07-19T05:42:38.527Z (about 1 year ago)
- Topics: boltdb, golang, iris, qwik, qwik-city, url-shortener
- Language: TypeScript
- Homepage: https://ss-link.netlify.app/
- Size: 12.6 MB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.en.md
Awesome Lists containing this project
README
缩短网址,让分享更简单
Shorten Link, Make Sharing Simpler
English | 简体中文
## Features
- ⚡️ [qwik](https://qwik.builder.io/) Accelerate our SSR application from the source
- 📦 [iris](https://www.iris-go.com/) A High Performance, Easy to Use and Powerful Go Language Web Framework
- 🔎 [bolt](https://github.com/boltdb/bolt) An efficient, embedded, and persistent key-value storage database, just don't want to use too heavy mysql and redis
- 🎨 [TaliWindCss](https://tailwindcss.com/) The Patriarch of the Atomic CSS Framework
- 😃 [daisyui](https://daisyui.com/) Use Tailwind CSS but write less class names
- ☁️ Deploy on Netlify, zero-config
- 🦾 Golang, of course
- 🦾 TypeScript, of course
## Function introduction - qwik part
- Global variable management
- [I18n](https://robisim74.gitbook.io/qwik-speak/) multi-language switching
## Function introduction - iris part
### Record the request log and write it to a local file
```json
{
"timestamp": "2023-01-21 21:15:03",
"latency": 405000,
"code": 200,
"method": "GET",
"path": "/ping",
"ip": "::1",
"bytes_sent": 4
}
```
### Management side JWT identity verification
```go
app.Post("/login", s.Login)
admin := app.Party("/admin")
{
admin.UseRouter(jwtMiddle.Serve)
admin.Post("/flush", s.Flush)
admin.Get("/all", s.All)
admin.Post("/del", s.DelOne)
}
```
### Dependent injection(DI) to reduce coupling()
```golang
{
...
app.RegisterDependency(shortService)
...
app.ConfigureContainer(func(api *iris.APIContainer) {
api.Post("/short", s.ShortLink)
api.Get("/u/{key}", s.GetRaw)
})}
...
func (s ShorterCtl) GetRaw(ctx iris.Context, ss *service.ShorterService) {
key := ctx.Params().Get("key")
link, err := ss.GetRaw(key)
if err != nil {
CommonResponse{}.Fail().SetData(err.Error()).Send(ctx)
return
}
ctx.Redirect(link, iris.StatusMovedPermanently)
return
}
### Routing self-test, become a cute backend
```go
var commonSchema = `{
"type": "object",
"properties": {
"code": {"type": "number"},
"msg": {"type": "string"},
"data": {"type": ["object","string"]}},
"required": ["code", "msg", "data"]
}`
func TestAdminApi(t *testing.T) {
app := NewApp()
e := httptest.New(t, app)
e.GET("/admin/all").Expect().Status(httptest.StatusOK).
JSON().Schema(commonSchema)
}
```
## Relevant information
### golang
- [iris-cors](https://docs.iris-go.com/iris/security/cors#the-cors-configuration)
- [iris-jwt](https://github.com/iris-contrib/middleware/tree/master/jwt)
- [iris-test](https://docs.iris-go.com/iris/contents/testing)
### qwik
- [vite-env](https://cn.vitejs.dev/guide/env-and-mode.html#env-files)
- [qwik-i18n-by-speak](https://github.com/robisim74/qwik-speak)
- [qwik-init-repo](https://qwik.builder.io/docs/getting-started/)
- [qwik-state-management](https://qwik.builder.io/docs/components/state/)
- [qwik-component](https://qwik.builder.io/docs/components/overview/)
- [qwik-lite-component](https://qwik.builder.io/docs/components/lite-components/)
- [svg-to-jsx](https://www.svgviewer.dev/svg-to-react-jsx)