Giter Site home page Giter Site logo

apimockmanage's Introduction

apiMockManage

nodejs koa2 前后端开发本地api数据模拟

nodejs,mysql,使用sequelize来操作数据库

基于 koa-generator 生成项目然后在此基础上进行修改

该架构适合开发后台管理系统以及restful 前端接口

使用 nunjucks 模板引擎。

目录结构说明:

1.bin 目录为项目启动入口目录
2.config 目录为项目配置目录,db.js为sequelize对数据库的配置,common.js为开发环境和生产环境的配置(环境变量的设置需要安装 npm install cross-env 这个npm包)
3.public 为静态资源目录
4.src 为整个项目开发源代码目录, 5.views 为后台管理系统模板页面

src内目录说明:

1.controllers 为控制器,主要处理用户的请求,业务逻辑 2.middlewares 为中间件 3.models 为 模型使用 4.schema 为数据表模型,定义需要查询的表以及字段 5.routes 为路由,将控制映射到路由 6.utils 为工具函数

使用说明

import axios from 'axios'  //引入axios插件

axios({
   method: 'post',
   url: 'http://192.168.1.46:8080/api/api-record/api-mock/5',
   data: {
        firstName: 'Fred',
        lastName: 'Flintstone'
   },
   headers: {'X-Requested-With': 'XMLHttpRequest'},//需要加上这个header 后端mock系统根据此字段判断是否为ajax请求
   }).then(function (response) {
      console.log(response.data);
 });

apimockmanage's People

Watchers

James Cloos avatar  avatar

Forkers

miluxi

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.