All Projects → thonatos → shorturl-egg

thonatos / shorturl-egg

Licence: other
shorturl powered by egg

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to shorturl-egg

shorturl
Generic implementation for interacting with various URL shortening services in Go.
Stars: ✭ 82 (+241.67%)
Mutual labels:  shorturl
m-server
egg.js简单应用
Stars: ✭ 35 (+45.83%)
Mutual labels:  egg
egg-grpc
grpc plugin for egg
Stars: ✭ 79 (+229.17%)
Mutual labels:  egg
akasio-go
Akasio is a simple HTTP server that redirects traffic based on a JSON redirect table.
Stars: ✭ 12 (-50%)
Mutual labels:  shorturl
create-egg
so you could use `npm init egg showcase` to init egg project
Stars: ✭ 28 (+16.67%)
Mutual labels:  egg
egg-kafka-node
kafka plugin for egg.js
Stars: ✭ 36 (+50%)
Mutual labels:  egg
ShortURL
短网址生成器,演示地址:http://t.haojima.net/
Stars: ✭ 50 (+108.33%)
Mutual labels:  shorturl
AntEggBlogService
🔥egg、mongodb、restful api、jwt
Stars: ✭ 21 (-12.5%)
Mutual labels:  egg
bili-short-url
哔哩哔哩短链生成器。将B站站内链接转化为Bilibili短链,例如:https://b23.tv/F78kbY
Stars: ✭ 38 (+58.33%)
Mutual labels:  shorturl
chat-webapp
一个基于eggjs与react全家桶的移动端webapp
Stars: ✭ 21 (-12.5%)
Mutual labels:  egg
xiaomishop
基于nodejs web框架egg.js+mongoose实现的仿小米商城的项目
Stars: ✭ 26 (+8.33%)
Mutual labels:  egg
egg-view-assets
Manage frontend assets in development and production.
Stars: ✭ 51 (+112.5%)
Mutual labels:  egg
egg-exporter
Egg.js 的 Prometheus 指标收集插件,附带 Grafana 看板。
Stars: ✭ 24 (+0%)
Mutual labels:  egg
yasuser
Yet another self-hosted URL shortener. | 短域名
Stars: ✭ 17 (-29.17%)
Mutual labels:  shorturl
egg-sentry
Sentry Plugin For Egg.js
Stars: ✭ 18 (-25%)
Mutual labels:  egg
biturl
短网址
Stars: ✭ 38 (+58.33%)
Mutual labels:  shorturl
ShortURL-Services-List
A list of 600+ URL shorteners (i.e goo.gl, bit.ly)
Stars: ✭ 32 (+33.33%)
Mutual labels:  shorturl
benchmark
benchmark for egg
Stars: ✭ 19 (-20.83%)
Mutual labels:  egg
egg-aop
AOP plugin for eggjs, add DI, AOP support.
Stars: ✭ 44 (+83.33%)
Mutual labels:  egg
egg-rbac
Role Based Access Control for eggjs
Stars: ✭ 32 (+33.33%)
Mutual labels:  egg

shorturl

shorturl powered by egg.js

QuickStart

see egg docs for more detail.

Development

$ npm install
$ npm run dev
$ open http://localhost:7001

Deploy

Use EGG_SERVER_ENV=prod to enable prod mode

$ EGG_SERVER_ENV=prod npm start

npm scripts

  • Use npm run lint to check code style.
  • Use npm test to run unit test.
  • Use npm run autod to auto detect dependencies upgrade, see autod for more detail.

docker-compose

cd docs/docker-compose
docker-compose up

see docs/docker-compose for more detail.

Config

Database

// mysql
DROP TABLE IF EXISTS  `url`;
CREATE TABLE `url` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(512) NOT NULL,
  `created` datetime DEFAULT CURRENT_TIMESTAMP,
  `hash` varchar(512) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200 DEFAULT CHARSET=utf8mb4;
// elasticsearch

// geoip configure
PUT _ingest/pipeline/geoip
{
  "description" : "Add geoip info",
  "processors" : [
    {
      "geoip" : {
        "field" : "ip"
      }
    }
  ]
}

// mappings
PUT shorturl
{
  "mappings": {
    "view": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "ip": {
          "type": "ip"
        },
        "date": {
          "type": "date"
        }
      }
    }
  }
}

Application

  • app/config/config.prod.js
'use strict';

exports.site = {
  domain: 'https://swz.li/',
};

exports.mysql = {
  client: {
    host: 'mysql',
    port: '3306',
    user: 'root',
    password: 'mysql',
    database: 'shorturl',
  },
};

exports.redis = {
  client: {
    port: 6379,
    host: 'redis',
    password: null,
    db: 0,
  },
};

exports.elasticsearch = {
  host: 'elasticsearch:9200',
};

Api

  • POST /api/v1/shorten
// request body
{
	"url":"http://www.baidu.com"
}

// response
{
  "url": "http://www.baidu.com",
  "hash": "QioWY",
  "shorturl": "http://localhost:7001/QioWY"
}
  • GET /api/v1/expand/:hash
{
  "id": 2,
  "url": "http://www.baidu.com",
  "created": "2017-07-24T03:42:06.000Z"
}
  • GET /api/v1/count
[
  {
    "id": 2,
    "url": "http://www.baidu.com",
    "created": "2017-07-24T03:42:06.000Z"
  },
  {
    "id": 1,
    "url": "http://www.baidu.com/?test=3",
    "created": "2017-07-23T06:56:48.000Z"
  }
]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].