GithubHelp home page GithubHelp logo

hapiblog's Introduction

📕 hapiblog 博客 api

基于 hapi 框架的博客系统,使用 jwt 鉴权,支持用户注册和登录,获取文章列表和文章详情。以 redis 作为缓存解决方案,使用 mysql 数据库和 sequelize 处理数据持久化。

👕 DEMO

点击这里查看DEMO

🌈 支持的功能

  • 分页获取博客文章列表
  • 增查改删博客文章
  • 根据标签、标题和作者 ID 筛选文章
  • 获取文章排行列表支持 30 天以内的文章阅读量排行
  • 使用 redis 缓存请求的数据
  • 用户的注册和登录以及 JSON WebToken 的鉴权
  • 通过 swagger 创建 API 文档
  • 使用 hapi-good 日志工具
  • 使用 sequelize 创建数据迁移

screencapture-127-0-0-1-8000-documentation-2018-10-07-21_48_37.png

🎉 使用方法

🍎 clone

git clone https://github.com/oliyg/hapiblog.git

🚨 配置环境变量

根目录新增 .env 文件,仿照 .env.example 配置环境变量:

# server
HOST = HOST
PORT = PORT

# mysql
MYSQL_USERNAME = MYSQL_USERNAME
MYSQL_PASSWORD = MYSQL_PASSWORD
MYSQL_DB_NAME = MYSQL_DB_NAME
MYSQL_HOST = MYSQL_HOST
MYSQL_PORT = MYSQL_PORT

# redis
REDIS_HOST = REDIS_HOST
REDIS_PORT = REDIS_PORT

# jwt
JWT_SECRET = JWT_SECRET

# passwd encrypt secret
PASSWD_SECRET = PASSWD_SECRET

📖 数据迁移

开启 mysql 服务,并执行命令:

  • npm run createdb:dev 创建数据库
  • npm run createtable 创建数据库表
  • npm run initdata 创建示例数据
  • npm run start 开启服务

✈️ 启动服务

访问 http://127.0.0.1:8000/documentation#/ 查看 API 文档

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.