GithubHelp home page GithubHelp logo

haokur / koa-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 4.65 MB

🧑‍🎨 从0到1的工程化,自动化,规范的最佳实践,开箱即用,让开发更高效

Home Page: https://haokur.github.io/koa-server

TypeScript 70.51% JavaScript 3.83% Shell 0.24% HTML 0.27% Vue 25.00% SCSS 0.16%

koa-server's Introduction

Koa-server

  • nodemon监听变化自动重新执行
  • eslint+prettier+cell-speller,代码规范
  • husky,提交规范
  • koa2基本项目架构配置
  • client端使用vue3+vite+ts
  • 文件分片上传下载
  • SQLiteMysql
  • Redis
  • mysql,redis联动API,数据一致性
  • github访问统计svg
  • 音视频

对应文档

Mysql使用
import { SqlService } from '../services/sql.service';

// 创建表
const createResult = await SqlService.createTable({
    tableName: 'user',
    tableComment: '用户表',
    tableColumns: {
        username: 'varchar(255)|false|false|false|用户名',
        email: 'varchar(255)|false|false|false|用户邮箱',
    },
});

// 增
const createResult = await SqlService.insert('user', {
    username:"jack",
    email:"[email protected]",
});
// 增加多个
await SqlService.insert('user', 
    [
        { username:"jack", email:"[email protected]",},
        { username:"jack2",email:"[email protected]",},
    ]
);

// 删
const deleteResult = await SqlService.delete('user', { username: 'jack' });

// 改
const updateResult = await SqlService.update('user', {
    from: { username: 'jack' },
    to: { username: 'bob' },
});

// 查单个
await SqlService.first('user',{ username: 'jack' });
// 查多个
await SqlService.find('user',{ username: 'jack' })
// 分页查找
await SqlService.findByPage('user',,{ username: 'jack' },{
    pageIndex: 1, pageSize: 4
})
// 查总数
await SqlService.count('user', { username: 'jack' });

QueryService中实现的功能,使用QueryService自动处理redis缓存。

环境变量配置
  • /.env/.env.example.ini,配置模板
  • src/services/config.service.ts 中配置 IKoaConfig
  • development 环境使用 .env.development.ini
  • production 环境使用 .env.production.ini
  • node 启动的 process.env.NODE_ENV 变量注入,由 cross-env 提供兼容
  • .gitignore 已忽略各种环境的配置的提交,只留了配置模板

koa-server's People

Watchers

Lucian avatar  avatar  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.