All Projects → mx-space → server-next

mx-space / server-next

Licence: AGPL-3.0 license
😎 The next generation of RESTful API service and more for Mix Space, powered by @nestjs.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to server-next

Nodepress
😎 RESTful API service for Blog/CMS, powered by @nestjs
Stars: ✭ 829 (+1827.91%)
Mutual labels:  mongoose, nest, cms-framework, restful-api, nestjs
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: ✭ 145 (+237.21%)
Mutual labels:  mongo, mongoose, nest, nestjs
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-60.47%)
Mutual labels:  mongoose, nestjs, typegoose
Nestjs Typegoose
Typegoose with NestJS
Stars: ✭ 215 (+400%)
Mutual labels:  mongoose, nest, nestjs
Schedule
Schedule module for Nest framework (node.js) ⏰
Stars: ✭ 137 (+218.6%)
Mutual labels:  cron, nest, nestjs
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: ✭ 307 (+613.95%)
Mutual labels:  mongoose, nest, nestjs
Nestjs Mongoose Crud
Nest.js crud module for mongoose models without `nestjsx/crud`
Stars: ✭ 164 (+281.4%)
Mutual labels:  mongoose, restful-api, nestjs
Nest Schedule
A cron-like and not-cron-like job distributed scheduler for Nest.js by decorators.
Stars: ✭ 368 (+755.81%)
Mutual labels:  cron, nest, nestjs
Bull
Bull module for Nest framework (node.js) 🐮
Stars: ✭ 356 (+727.91%)
Mutual labels:  cron, nest, nestjs
NodeRestApi
Node.js, Express.js and MongoDB REST API App
Stars: ✭ 38 (-11.63%)
Mutual labels:  mongo, mongoose, restful-api
nestjs-api-mongoose
Collection example apps with NestJS and Typeorm, Sequelize, Mongodb, PostgreSQL, MySQL, GraphQL, Mercurius, etc. for the NestJS community 😻
Stars: ✭ 153 (+255.81%)
Mutual labels:  mongo, mongoose, nestjs
Jianshu
仿简书nx+nodejs+nestjs6+express+mongodb+angular8+爬虫
Stars: ✭ 296 (+588.37%)
Mutual labels:  mongoose, restful-api, nestjs
nestjs-rest-sample
NestJS RESTful APIs Sample
Stars: ✭ 204 (+374.42%)
Mutual labels:  mongoose, restful-api, nestjs
Mongoose
Mongoose module for Nest framework (node.js) 🍸
Stars: ✭ 191 (+344.19%)
Mutual labels:  mongoose, nest, nestjs
Crud
NestJs CRUD for RESTful APIs
Stars: ✭ 2,709 (+6200%)
Mutual labels:  nest, restful-api, nestjs
blog3.0
博客V3.0 目前使用的技术(Nuxtjs + Nestjs + Vue + Element ui + vuetify),存储(MongoDB + Redis + COS)
Stars: ✭ 37 (-13.95%)
Mutual labels:  mongo, nest, nestjs
angular-chat
Angular v.9, Node.js, Nest.js v.6, Mongoose, Socket.io, Passport, Angular Universal SSR (in progress...)
Stars: ✭ 35 (-18.6%)
Mutual labels:  mongoose, nest, nestjs
nest-rest-mongo-boilerplate
🍱 backend with nest (typescript), mongoose, and authentication
Stars: ✭ 180 (+318.6%)
Mutual labels:  mongoose, nest, nestjs
uuid-mongodb
📇 Generates and parses MongoDB BSON UUIDs
Stars: ✭ 94 (+118.6%)
Mutual labels:  mongo, mongoose
aws-nestjs-starter
Serverless, AWS, NestJS, GraphQL and DynamoDB starter
Stars: ✭ 200 (+365.12%)
Mutual labels:  nest, nestjs

MX-Server

GitHub stars GitHub issues GitHub Workflow Status GitHub license wakatime Docker Image Size (latest by date)

RESTful API service for Mix Space, powered by nestjs, required mongoDB & Redis.

适用于 Mix Space 的 RESTful API 服务端应用;基于 nestjs (nodejs),需安装 mongoDBRedis 方可完整运行。

v3 还是使用 nestjs 进行重构,之前的版本在 此仓库

配合相关项目一起使用:

  • SSR Blog:
    • Kami powered by NextJS (一个走可爱风路线的个人空间)
    • 未来会变多吗
  • Admin: Admin
  • 未来可期

接口文档通过开发环境 Swagger 查阅。

现有的比较有意思的一些小玩意的实现:

  • 实时日志输出。通过 Socket.IO + 劫持 process.stdout 实现。
  • PTY 支持。
  • 云函数

快速开始

需要以下环境:

  • Node.js 16.10+
  • MongoDB
  • Redis

现有 macOS(x86)、Linux(x86) 的已构建产物。使用以下脚本可免手动构建直接运行。

curl https://cdn.jsdelivr.net/gh/mx-space/mx-server@master/scripts/download-latest-asset.js >> download.js
zx ./download.js
cd mx-server
node index.js

或者手动下载 release,之后解压然后

node index.js

所有的依赖都打包进了产物,无需黑洞一般的 node_modules

Docker 部署

cd
mkdir -p mx/server
cd mx/server
wget https://cdn.jsdelivr.net/gh/mx-space/mx-server@master/docker-compose.yml
docker-compose up -d

开发环境

git clone https://github.com/mx-space/mx-server
cd mx-server
pnpm i
pnpm dev

项目结构

.
├── app.config.ts                 # 主程序配置,数据库、程序、第三方,一切可配置项
├── app.controller.ts             # 主程序根控制器
├── app.module.ts                 # 主程序根模块,负责各业务模块的聚合
├── common                        # 存放中间件
│   ├── adapters                  # Fastify 适配器的配置
│   ├── decorator                 # 业务装饰器
│   ├── exceptions                # 自定义异常
│   ├── filters                   # 异常处理器
│   ├── guard                     # 守卫与鉴权
│   ├── interceptors              # 拦截器, 数据过滤与响应格式化处理
│   ├── middlewares               # 传统意义上的中间件
│   └── pipes                     # 管道
├── constants                     # 常量
│   ├── article.constant.ts
│   ├── cache.constant.ts
│   ├── meta.constant.ts
│   ├── path.constant.ts
│   └── system.constant.ts
├── main.ts                       # 引入配置,启动主程序,引入各种全局服务
├── modules                       # 业务逻辑模块
│   ├── aggregate
│   ├── analyze
│   ├── auth
│   ├── backup
│   ├── category
│   ├── comment
│   ├── configs
│   ├── feed
│   ├── health
│   ├── init
│   ├── link
│   ├── markdown
│   ├── note
│   ├── option
│   ├── page
│   ├── pageproxy
│   ├── post
│   ├── project
│   ├── pty
│   ├── recently
│   ├── say
│   ├── search
|   ├── snippet
|   ├── serverless
│   ├── sitemap
│   ├── tool
│   └── user
├── processors                      # 核心辅助模块
│   ├── cache                       # Redis 缓存相关
│   ├── database                    # Mongo 数据库相关
│   ├── gateway                     # Socket.IO 相关
│   ├── helper                      # 辅助类
│   └── logger                      # 自定义 Logger
├── shared                          # 通用模型
│   ├── dto                         # 数据验证模型
│   ├── interface                   # 接口
│   └── model                       # 基本数据模型
├── utils                           # 工具类
│   ├── crud.util.ts
│   ├── dayjs.util.ts
│   ├── global.util.ts
│   ├── index.util.ts
│   ├── ip.util.ts
│   ├── nest.util.ts
│   ├── pic.util.ts
│   ├── query.util.ts
│   ├── redis.util.ts
│   ├── system.util.ts
│   ├── time.util.ts
│   ├── transfrom.util.ts
│   └── validator
└── zx.global.ts

应用结构

  • 请求处理流程

    1. request:收到请求
    2. middleware:中间件过滤爬虫 PHP 肉鸡扫描路径,记录访问历史
    3. guard:守卫过滤(鉴权)和角色附加
    4. interceptor:before:只用于 DEBUG 请求计时
    5. pipe:校验请求数据,过滤未知数据,非法类型抛错 422
    6. controller & resolver:业务控制器
    7. service:业务服务
    8. interceptor:after:数据流拦截器(格式化数据)、请求缓存
    9. filter:捕获以上所有流程中出现的异常,如果任何一个环节抛出异常,则返回错误
  • 拦截器流向

ResponseInterceptor -> JSONSerializeInterceptor -> CountingInterceptor -> AnalyzeInterceptor -> HttpCacheInterceptor
  • 业务逻辑模块

    1. [Aggregate] 聚合
    2. [Analyze] 数据统计
    3. [Auth] 认证
    4. [Backup] 备份
    5. [Category] 分类
    6. [Commnet] 评论
    7. [Configs] 读取配置项
    8. [Feed] RSS
    9. [Health] 应用健康检查与日志相关
    10. [Init] 初始化相关
    11. [Link] 友链
    12. [Markdown] Markdown 解析导入导出解析相关
    13. [Note] 日记
    14. [Option] 设置
    15. [Page] 独立页面
    16. [PageProxy] 反代管理页
    17. [Post] 博文
    18. [Project] 项目
    19. [Recently] 最近
    20. [Say] 说说
    21. [Search] 搜索
    22. [Sitemap] 站点地图
    23. [Tool] 工具接口
    24. [User] 用户
  • 核心辅助模块 processors

    1. [cache] Redis 缓存相关
    2. [database] 数据库相关
    3. [gateway] Socket.IO 相关
      • 用户端
      • 管理端
      • 实时通知
    4. [helper] 辅助类
    5. [CountingService] 提供更新阅读计数
    6. [CronService] 维护管理计划任务
      • 自动备份
      • 推送百度搜索
      • 清除缓存
      • etc.
    7. [EmailService] 送信服务
    8. [HttpService] 请求模块
    9. [ImageService] 图片处理
    10. [TqService] 任务队列
    11. [UploadService] 上传服务
    12. [AssetService] 获取本地资源服务

开发

pnpm i
pnpm start

Reference

项目参考了 nodepress


Since 2021-08-31

Thanks

许可

This project is licensed under AGPLv3 licensed. 2021 Innei

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].