基于koa2, mongodb, redis技术栈,开发类似于知乎社区的restful服务

Overview
logo

mongoose KoaJS typescript qiniu License


🎉 技术栈

  • Koa2: Koa -- 基于 Node.js 平台的下一代 Web 开发框架。

  • TypeScript:通过在JavaScript的基础上添加静态类型定义构建而成的开源编程语言。

  • Mongoose: 为node.js设计的优雅mongodb对象模型库。

  • Redis: 连接Redis数据库快捷类库。


🎨 运行环境


🔨 环境搭建指引


注意事项:中国大陆如果想要域名访问绑定的主机,域名需要备案。如果购买中国香港节点,不需要走备案审核流程,比较方便。


流程图

process

📝 目录结构

开发目录如下面解释所示:

├── app.ts 程序入口
├── commitlint.config.js //git hooks校验规则
├── config  //配置文件目录
│   ├── config.ts
│   └── db.ts
├── controller //控制器目录
│   ├── article.ts
│   ├── comment.ts
│   ├── common.ts
│   └── user.ts
├── docker-compose.yml 
├── dockerfile 
├── model  模型定义目录
│   ├── article.ts
│   ├── comment.ts
│   └── user.ts
├── package.json
├── package-lock.json
├── README.md
├── routes 路由目录
│   ├── article.ts
│   ├── comment.ts
│   ├── common.ts
│   └── user.ts
├── tsconfig.json
├── utils 帮助工具函数目录
│   ├── auth.ts // 权限校验函数
│   ├── email.ts // 邮件发送
│   ├── middleware.ts // 中间件配置
│   ├── oss-upload.ts // 七牛云对象储存函数工具
│   └── tools.ts // 帮助函数
└── yarn.lock

先前准备

需要相应的账号密码填写

# 监听端口
PORT=3000

# JWT加密秘钥
JWT_SECRET= xxx

# 数据库地址
DATABASE_URL=xxx

# 七牛云 ACCESS_KEY
ACCESS_KEY=xxx

# 七牛云 SECRET_KEY 
SECRET_KEY=xxx

# 七牛云 OSS-Space
UPLOAD_SPACE = xxx

# 域名1地址
DOMAIN=xxxx

# 网易邮箱发送
[email protected]
EMAILPASS=xxx

# redisLab
REDISHOST=xxx
REDISPORT=17781
REDISPASS=xxx
REDISPASS=8wLDeSdq6d522yY0BEVDSCiYp7QHw0pB

🚀 运行命令

// 安装依赖
yarn

// 开发环境运行
yarn watch-server

// 打包部署环境产物
yarn build

// 运行生产环境资源
yarn serve

// 检查代码风格
yarn lint

//停止运行
yarn stop

💡 参考文献

You might also like...

E-Commerce Application developed with nodejs and stored to mongodb.

E-Commerce Application This Application has been developed with nodejs and mongodb. Environment Variables Create a file named config.env in config dir

Dec 23, 2021

A bot Similar to the reaction roles discord bot, but free. Written in JavaScript, and uses MongoDB.

Discord Reaction Roles bot About • Features • Installation • Setting Up About An open source reaction roles bot to anyone who needs one in their serve

Dec 22, 2022

A URL shortener website and PWA build with vercel serverless cloud function, MongoDB and nodeJS

A URL shortener website and PWA build with vercel serverless cloud function, MongoDB and nodeJS

❤️ lenk.cf A URL shortner made using NodeJS, MongoDB and Vercel serverless function. This project also includes a serverless API. With the help of thi

Nov 5, 2022

This is the FARM Stack course, where you are going to learn how to build an application from scratch using FASTAPI, React and mongoDB

FARM-Stack-Course This is the FARM Stack course, where you are going to learn how to build an application from scratch using FASTAPI, React and mongoD

Jan 2, 2023

Database manager for MySQL, PostgreSQL, SQL Server, MongoDB, SQLite and others. Runs under Windows, Linux, Mac or as web application

Database manager for MySQL, PostgreSQL, SQL Server, MongoDB, SQLite and others. Runs under Windows, Linux, Mac or as web application

Database manager for MySQL, PostgreSQL, SQL Server, MongoDB, SQLite and others. Runs under Windows, Linux, Mac or as web application

Dec 30, 2022

This is a full-stack exercise tracker web application built using the MERN (MongoDB, ExpressJS, ReactJS, NodeJS) stack. You can easily track your exercises with this Full-Stack Web Application.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Dec 25, 2021

A back-end server aplication created using node.js, express and mongodb.

Course Material and FAQ for my Complete Node.js, Express and MongoDB Bootcamp This repo contains starter files and the finished project files for all

Jan 4, 2022

Online Inventory Control System for an apparel manufacturing company "CASANOVA" (Pvt) Ltd. Technology stack: Node.js, Express.js, MongoDB Atlas, React.js (MERN Stack).

Project Name - Online Inventory Control System for an apparel manufacturing company "CASANOVA". The project was given a "A" grade. Group Leader - IT20

Dec 26, 2021

5-BackControlFinanzas - Node & MongoDB

API para APP 'Control Finanzas' Pequeña API/Backend creada para la aplicacion personal de Control Finanzas. Enlace de github a la aplicacion que requi

Jan 3, 2022

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database.

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database.

The Wholesome App. A project that allows you to upload images directly to MongoDB Atlas into your collection, a faster cloud database. To upload your cute and wholesome images.

Jul 17, 2022

School App / Back-End with MongoDB / mongoose / Express / TS

TEST Api Dependencies El mati se la come es por eso que en 1998 la guerra fria se llevo a mas de la mitad del activo del pais "dependencies": { "axios

Jun 10, 2022

Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Minimalist express-typescript-boilerplate Available Scripts - `tsc' - builds the tsc project to the dist folder - `build` - cleans the previous build

Dec 13, 2022

Tasks Management CLI application with Nodejs, Mongodb, inquirer.js, and commander

Tasks CLI Tasks CLI is a program to manage your tasks in a database using terminal or console. This is a sample project for beginners Requirements Nod

Nov 17, 2022

Guide for Advanced Discord.js x MongoDB systems

Guide for Advanced Discord.js x MongoDB systems

disco.js Discord.js Guide on how to build advanced system using Mongoose and Node.js Requirements Basic Knowledge of JavaScript/NodeJS Basic+ Knowledg

Nov 27, 2022

Simple React Social Network, built with React,Node,Express,MongoDB and Tailwind

Simple React Social Network, built with React,Node,Express,MongoDB and Tailwind

Full stack react social network application A mini social network application built with React,Typescript, Redux, Node, Express, MongoDB, and Tailwind

Dec 19, 2022

API em NodeJS, utilizando banco de dados MongoDB (TypeORM), com cobertura de testes (coverages), utilizando o Jest

API em NodeJS, utilizando banco de dados MongoDB (TypeORM), com cobertura de testes (coverages), utilizando o Jest

Api Backend Tindin Sobre API em NodeJS, utilizando banco de dados MongoDB (TypeORM), com cobertura de testes (coverages), utilizando o Jest. 👉 app ur

Jan 20, 2022

API Bate Papo UOL - A backend application developed using NodeJS and mongoDB

BatePapoUOL BackEnd My first backend project! Building an API to the most used brazillian chat app ages ago - Bate Papo UOL! Table of Contents Overvie

Apr 13, 2022

New multilingual Discord Gif BOT with MongoDB, economy and market system

multilingual niyuki-gif-bot but v13 (/w MongoDB, Economy and Market) One of the most advanced Discord Gif BOT with MongoDB, Economy and Market System

Sep 26, 2022

v13 butonlu + mongodb'li register botudur. Sadece Merakımdan V13 uğraştım, devamı geleceğini düşünmüyorum. İstek üzerine yapılmıştır

v13 butonlu + mongodb'li register botudur. Sadece Merakımdan V13 uğraştım, devamı geleceğini düşünmüyorum. İstek üzerine yapılmıştır

Testleri yapılmıştır. Hiçbir hatası bulunmamaktadır. Starlarınızı bekliyorum. Yapmanız gereken adımlar settings.json dosyasının içindeki idleri doldur

Dec 20, 2022
Owner
Harhao
Harhao
A developer directory built on Next.js and MongoDB Atlas, deployed on Vercel with the Vercel + MongoDB integration.

MongoDB Starter – Developer Directory A developer directory built on Next.js and MongoDB Atlas, deployed on Vercel with the Vercel + MongoDB integrati

Vercel 246 Dec 20, 2022
Mongo Strict is a TypeScript based smart MongoDB ORM, It makes the usage of MongoDB safer, easier and faster with a better performance...

mongo-strict mongo-strict is compatible with mongo >= 5 Mongo Strict is a TypeScript-based smart MongoDB ORM, It makes the usage of MongoDB safer, eas

Mohamed Kamel 4 Sep 22, 2022
MongoDB object modeling designed to work in an asynchronous environment.

Mongoose Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks. Do

Automattic 25.2k Dec 30, 2022
The Official MongoDB Node.js Driver

MongoDB NodeJS Driver The official MongoDB driver for Node.js. NOTE: v3.x released with breaking API changes. You can find a list of changes here. Ver

mongodb 9.6k Dec 28, 2022
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite datab

MikroORM 5.4k Dec 31, 2022
🍹 MongoDB ODM for Node.js apps based on Redux

Lightweight and flexible MongoDB ODM for Node.js apps based on Redux. Features Flexible Mongorito is based on Redux, which opens the doors for customi

Vadim Demedes 1.4k Nov 30, 2022
A high performance MongoDB ORM for Node.js

Iridium A High Performance, IDE Friendly ODM for MongoDB Iridium is designed to offer a high performance, easy to use and above all, editor friendly O

Sierra Softworks 570 Dec 14, 2022
The ultimate solution for populating your MongoDB database.

Mongo Seeding The ultimate solution for populating your MongoDB database ?? Define MongoDB documents in JSON, JavaScript or even TypeScript files. Use

Paweł Kosiec 494 Dec 29, 2022
📇 Generates and parses MongoDB BSON UUIDs

uuid-mongodb Generates and parses BSON UUIDs for use with MongoDB. BSON UUIDs provide better performance than their string counterparts. Inspired by @

Carmine DiMascio 96 Nov 21, 2022
A MongoDB-like database built on top of Hyperbee with support for indexing

hyperbeedeebee A MongoDB-like database built on top of Hyperbee with support for indexing WIP: There may be breaking changes in the indexing before th

null 35 Dec 12, 2022