Giter VIP home page Giter VIP logo

egg-nideshop's Introduction

egg-nideshop

本项目使用egg框架重写nideshop开源商城的服务端,网络接口与原版的nideshop服务端几乎完全一样。可以配合nideshop小程序端项目进行联调(特别提醒:由于小程序sdk升级,原版的nideshop小程序端项目的用户登录功能已经无法使用,我对用户登录部分代码做了修改,修改后的小程序项目点此到达

本项目要点:

  • 项目模板基于egg官方脚手架的ts模板
  • 技术栈:typescript + egg + Sequelize + mysql
  • 使用jwt + egg-userrole完成会话控制
  • 所有请求需要做参数校验
  • 测试数据来源于 NideShop商城 项目
  • 针对大部分controller提供单元测试
  • 本项目使用git flow工作流进行管理,请大家选择master分支进行clone

本地开发环境配置

本地运行

  1. git clone https://github.com/aasailan/egg-nideshop.git

  2. 使用navicat等工具创建egg-nideshop数据库,并运行sql/egg-nideshop.sql文件。注意数据库字符编码为utf8mb4

  3. config/config.local.ts 中修改数据库配置,默认配置如下:

    config.sequelize = {
        dialect: 'mysql',
        database: 'egg_nideshop',
        host: 'localhost',
        port: '3306',
        username: 'root',
        password: '12345678',
        // 数据表名前缀
        tablePrefix: 'nideshop_',
      };
  4. 填写小程序信息,配置如下(微信支付功能还未实现):

    const config: DefaultConfig = {};
    config.wechat = {
      // 小程序appid
      appid: '', 
      // 小程序secret
      secret: '', 
    
      mch_id: '',
      partner_key: '',
      notify_url: '',
    };
  5. 安装依赖并启动

    npm install
    npm run dev
  6. egg默认监听7001端口,与nideshop小程序项目进行联调时,请记得将nideshop小程序项目的api端口改为7001。

调试

在vscode中安装eggjs拓展,在项目安装依赖后,按f5进入debug模式。按shift + f5 退出debug模式

生成type文件

npm run type

运行测试用例

npm run test-local

Requirement

  • Node.js 8.x
  • Typescript 2.8+

项目目录说明

  • app文件夹:egg工程源码目录
  • config:egg工程配置目录
  • sql:数据表与测试数据文件,其中egg-nideshop.sql是整体文件,其余子文件夹是拆分出的各个数据表文件。
  • test:测试用例文件夹
  • typings:项目类型生命文件夹

下一步计划

  • 完成支付功能
  • 编写docker-compose文件,实现docker部署

egg-nideshop's People

Watchers

 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.