npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

saas-plat-server

v1.0.14

Published

saasplat app server

Downloads

3

Readme

saas-plat-server

概述

为saas-plat.com平台提供应用服务器,提供基于Restful Api、CQRS、sequelize的ORM、Workflow和定时服务的运行环境。

安装

  npm install saas-plat-server

仅仅saas-plat-server是没有意义,你还需要安装业务模块

  npm install saas-plat-erp-base saas-plat-retail_pos saas-plat-stock_control saas-plat-purchase_sale

需要在项目跟目录创建一个tenant.json配置服务器信息

{
  "modules": "saas-plat-*",  // glob 或 ['xxx','xxx2']
  "eventdb": {
    "username": "root",
    "password": "123456",
    "database": "testserver1_events",
    "host": "localhost",
    "dialect": "mysql"
  },
  "querydb": {
    "username": "root",
    "password": "123456",
    "database": "testserver1_querys",
    "host": "localhost",
    "dialect": "mysql"
  }
}

开发

按业务单元开发,每个单元划分成一个模块,一个模块包含如下项目结构:

  • saas-plat-erp-base-department
    • src // es6
      • controller
      • logic
      • service
      • model
      • domain
      • migration
      • command
      • event
      • workflow
      • task
    • app // es5
    • package.json

saas-plat-server是前后端分离的模式,server只能提供api接口, 如果需要高体验的前端,参见https://github.com/saas-plat/saas-plat-native

可以安装saas-plat-cli工具构建项目

  npm i -g saas-plat-cli

  saasplat module mymodule1
  cd mymodule1

更多API参见API文档

CQRS DDD

业务模块采用DDD领域驱动设计方式开发

相关文件夹

  - domain    // 领域对象或服务,主要实现业务逻辑代码
  - command   // 命令Handler,调用领域对象或服务执行逻辑
  - event     // 事件Handler,在发生了某个业务事件后处理保存成供查询的一维表数据、系统集成等其他逻辑
  - model     // 查询对象,简单的一维表,直接提供查询数据
  - migration // 业务迁移逻辑

eventhandler注意事项: 回溯业务事件时有可能不需要执行某些代码,例如发送短信通知,
这是可以使用 saasplat.resourcing 状态判断是否是回溯模式

业务迁移

业务迁移适用于调整业务逻辑或者错误产生的数据错误

ORM

查询对象采用ORM方式操作

相关文件夹

  - model

数据迁移

数据迁移并不需要编写创建表脚本或升级脚本,也不需要写错误数据修改脚本, 系统会计算相关模块,采用重塑业务事件方式,重建所有相关数据

定时任务

周期性执行一个command或者定时执行一个command

saasplat.task.add(taskname, module, cron/date, command, data, ...);

定时任务一般在evenghandler中调用,直接调用基类函数

export default class extends saasplat.eventhandler {
  async xxxCreated({
    this.addTask(taskname, cron/date, command, data, ...);
  })
}

cron 执行周期任务

cron格式

*    *    *    *    *    *
┬    ┬    ┬    ┬    ┬    ┬
│    │    │    │    │    |
│    │    │    │    │    └ day of week (0 - 7) (0 or 7 is Sun)
│    │    │    │    └───── month (1 - 12)
│    │    │    └────────── day of month (1 - 31)
│    │    └─────────────── hour (0 - 23)
│    └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)

date 定时任务

new Date(2012, 11, 21, 5, 30, 0)

工作流

Restful Api

Socket.io

配置

路由

运行

  npm start

授权

saas-plat-server和saas-plat-cli工具遵循GPL许可

部分由saas-plat.com开发者开发的业务模块可能采用非商业授权许可