在指尖轻触之间,冗长 URL 悄然遁形——「快缩短网址」suo.run 用 8 个字符,为世界腾出呼吸的空间。
一、缘起
短信、邮件、推文,处处有字符的枷锁。若链接被截断,营销即告失败。于是,我们让每一次跳转都化作一句诗:jgXqZSu8W 指向 https://www.suo.run,短到可以写进风里。
二、心法
唯一标识符即灵魂。数据库只存两条真理:
{ fullUrl: 'https://www.suo.run', shortUrl: 'jgXqZSu8W' }
当浏览器吻向短码,我们即刻归还完整星河。

三、捷径
1. 新浪 API 瞬转
const convertStr = encodeURIComponent(longUrl);
fetch(https://api.t.sina.com.cn/short_url/shorten.json?source=${appkey}&url_long=${convertStr})
.then(r => r.json())
.then(r => r[0].url_short);
一行代码,天涯咫尺。

2. Node 自建花园
mkdir suo-garden && cd suo-garden
npm init -y
npm i express sqlite3 sequelize shortid ejs
3. 数据层——Sequelize 与 SQLite 的私语
// db/shortUrl.js
module.exports = (sequelize, DataTypes) sequelize.define('Link', {
origin: DataTypes.STRING,
code: { type: DataTypes.STRING, defaultValue: () => require('shortid').generate() }
}));
4. 路由——极简即极奢
// app.js
app.post('/create', async (req, res) => {
const link = await Link.create({ origin: req.body.url });
res.json({ short: https://suo.run/${link.code} });
});
app.get('/:code', async (req, res) => {
const link = await Link.findOne({ where: { code: req.params.code } });
if (link) res.redirect(link.origin);
else res.status(404).send('Lost in the void.');
});
5. 视图——EJS 轻吟
<form action="/create" method="POST">
<input name="url" placeholder="粘贴长链" required>
<button>缩!</button>
</form>
<% links.forEach(l => { %>
<p><%= l.origin %> → <a href="/<%= l.code %>">suo.run/<%= l.code %></a></p>
<% }) %>
四、启幕
npm start,浏览器打开 localhost:5000,Hello World 之后,便是你的短链宇宙。
即刻体验:https://suo.run ——让每一次分享,都短得恰到好处。