Giter Club home page Giter Club logo

link-shorter's Introduction

Shorten Link

缩短网址,让分享更简单
Shorten Link, Make Sharing Simpler


Live Demo


简体中文 | English


Features

  • ⚡️ qwik 从源头上加速SSR应用

  • 📦 iris 一个高性能、易用且功能强大的Go语言Web框架

  • 🔎 bolt 一个高效的、嵌入式的、持久化的键值存储数据库, 只是不想用太重的mysql和redis~

  • 🎨 TaliWindCss 原子类CSS框架的祖师爷

  • 😃 daisyui 使用 Tailwind CSS 但少写类名

  • ☁️ Deploy on Netlify, zero-config

  • 🦾 Golang, of course

  • 🦾 TypeScript, of course


功能介绍-qwik部分

  • 全局变量管理
  • I18n多语言切换

功能介绍-iris部分

记录请求日志,写入本地文件

{
  "timestamp": "2023-01-21 21:15:03",
  "latency": 405000,
  "code": 200,
  "method": "GET",
  "path": "/ping",
  "ip": "::1",
  "bytes_sent": 4
}

管理端JWT身份校验

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)
}

依赖注入,降低耦合

{
...
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
}

路由自测,成为一名可爱的后端

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)
}

相关资料

golang

qwik

link-shorter's People

Contributors

leizhenpeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

itsharex bdpqlhk

link-shorter's Issues

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.