GithubHelp home page GithubHelp logo

nestjs-mysql-api's Introduction

一、项目初始化

  • 1、权限系统前端页面展示

    • 用户中心

    image-20200210094124374

    • 角色管理

    image-20200210094341500

    • 资源管理

    image-20200210094452098

  • 2、主要提供的API

  • 3、下载原代码及安装依赖包

  • 4、根目录下创建一个.env的文件

    // 端口号
    PORT = 4000;
    
    // mysql数据库配置
    DB_TYPE = mysql;
    DB_HOST = localhost;
    DB_USERNAME = root;
    DB_PASSWORD = root;
    DB_DATABASE = test;
    DB_PORT = 3306;
    DB_SYNCHRONIZE = false;
    DB_LOGGING = true;
    
    // jwt加盐
    SECRET = abc;
    // 前缀
    PREFIX = api/v1;
  • 5、创建数据库及创建表(直接使用项目中的sql文件)

  • 6、运行代码

    npm run start:dev
    # or
    npm run webpack
    npm run start1

二、主要实现功能

  • 使用nestjs-configdotenv保存敏感数据及在项目中直接使用ConfigService参考文档
  • 使用typeorm-model-generator由数据库表迁移生成*.entity.ts文件参考我的文章
  • 使用node-auth0模块进行密码加密处理(见src/core/user/user.entity.ts)
  • 使用jwt对用户登录授权(见src/shared/guard/auth.guard.ts)
  • 封装了统一成功、失败数据返回格式,并在全局使用(见src/shared/interceptor/transform.interceptor.tssrc/shared/filters/http-exception.filter.ts)
  • 封装了用户提交数据错误提示(见src/shared/pipe/validation.pipe.ts)
  • 日志拦截器,用于记录各个请求访问时间(见src/shared/interceptor/logging.interceptor.ts)
  • 核心模块curl封装了httpModule模块的网络请求
  • 使用@nestjs/swagger swagger-ui-express生成API文档(见src/main.ts)
  • 安全方面
  • src/core中添加上传附近模块官网地址
  • 使用webpack热更新官方文档
  • 权限系统主要的功能
    • 采用RBAC的方式,实现用户关联角色(一对多关系),角色关联资源(一对多的关系)

三、技术解答

本项目还在持续集成新功能进来,最后会加上前端做一个cms系统的api,后期会拉分支使用graphql提供api

  • 1、有关于nestjs的技术问题可以直接加我微信备注:nest 开发

  • 2、如果你觉得本项目对你帮助很大,给一个赞

nestjs-mysql-api's People

Contributors

kuangshp avatar

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.