Giter VIP home page Giter VIP logo

koa2-typescript-base-server's Introduction

koa2-typescript-base-server

使用typescript开发的koa2 mongoose 基础模板 包含日志记录 分页查询

使用提醒 2024-04-02

因为本项目为基础模板,功能较少,我会不定期更新package.json中的依赖项至最新版本, 克隆此项目后,可手动将package.json文件内的依赖项迁移至最新稳定版本,方便后续使用。

项目默认创建了数据库koa2TypescriptBaseServer 可在.env文件内修改项目配置

基础功能

  • test.controller 定义了一些测试接口操作redis
  • log.controller 分页查询/删除数据库操作日志; 查询/删除系统文本日志

使用说明

  • 确保本地安装了 node.js >= 16.20.2 mongoDB redis typescript

  • 安装依赖并启动 3031端口

> npm install 或 yarn install
> npm run dev 或 yarn dev

启动后可尝试请求 GET: http://localhost:3031/api/test/get_version 会返回json

{"code":200,"msg":"OK","data":{"version":"1.0.1","env":"development"}}
  • redis设置值: GET: /api/test/set_value?value=abc
{"code":200,"msg":"OK","data":null}
  • redis获取值: GET: /api/test/get_value
{"code":200,"msg":"OK","data":"abc"}
  • redis清除全部缓存: POST: /api/test/flushdb 清除操作会被记录在数据库日志中。

  • 分页查询日志列表: GET: /api/log/get_dblog

  • 分页响应和分页查询的逻辑查看 src\core\result.tssrc\services\log.service.ts

  • 项目打包

> npm run build 或 yarn build
  • 打包完成后需要创建.env文件并将NODE_ENV修改为production
NODE_ENV=production

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.