Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/singcl/express
🐠 A counterfeit Express.
https://github.com/singcl/express
counterfeit-express express framework layer mocha nodejs server static-server
Last synced: 6 days ago
JSON representation
🐠 A counterfeit Express.
- Host: GitHub
- URL: https://github.com/singcl/express
- Owner: singcl
- License: bsd-3-clause
- Created: 2018-03-31T15:00:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-03T14:55:47.000Z (over 6 years ago)
- Last Synced: 2024-08-10T23:18:55.958Z (3 months ago)
- Topics: counterfeit-express, express, framework, layer, mocha, nodejs, server, static-server
- Language: JavaScript
- Homepage:
- Size: 137 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Express@singcl](./src/img/express.jpg)
## 🐠 Express[![Travis](https://img.shields.io/travis/singcl/express.svg?style=flat-square)](https://www.travis-ci.org/singcl/express)
[![npm (scoped)](https://img.shields.io/npm/v/@singcl/express.svg?style=flat-square)](https://www.npmjs.com/package/@singcl/express)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-10de6e.svg?style=flat-square)](https://github.com/prettier/prettier)
![David](https://img.shields.io/david/dev/singcl/express.svg?style=flat-square)
![David](https://img.shields.io/david/singcl/express.svg?style=flat-square)
[![npm](https://img.shields.io/npm/dm/@singcl/express.svg?style=flat-square)](https://www.npmjs.com/package/@singcl/express)### A counterfeit Express.
### V1.x is constructing...
### Usage
`npm i @singcl/express -S`### example
```js
// var opn = require('opn')
var error = require('@singcl/express-error')
var express = require('@singcl/express')
var app = express()app.use(function(req, res, next) {
// 告诉客户端以UTF-8的方式解析 设置charset=utf-8解决前端拿到的数据中文乱码
res.setHeader('Content-Type', 'text/plain;charset=utf-8')
// next('[全局]-中间件错误捕获:next(err)')
next()
})app.get('/example', function(req, res, next) {
// 告诉客户端以UTF-8的方式解析 设置charset=utf-8解决前端拿到的数据中文乱码
res.setHeader('Content-Type', 'text/plain;charset=utf-8')
next('[路由]-中间件错误捕获:next(err)')
})app.get('/user', function(req, res, next) {
// 告诉客户端以UTF-8的方式解析 设置charset=utf-8解决前端拿到的数据中文乱码
res.setHeader('Content-Type', 'text/plain;charset=utf-8')
res.write('来自星星的你', 'utf8')
res.end(function() {
console.log('数据已发送!')
})
})app.post('/user', function(req, res, next) {
// 告诉客户端以UTF-8的方式解析 设置charset=utf-8解决前端拿到的数据中文乱码
res.setHeader('Content-Type', 'text/plain;charset=utf-8')
res.write('来自星星的POST', 'utf8')
res.end(function() {
console.log('post数据已发送!')
})
})// 错误中间件use - 自定义如何处理错误
app.use(error())//
app.listen(3000, function() {
console.log('node server start at port 3000!')
// opn('http://127.0.0.1:3000')
})
```## License[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fsingcl%2Fexpress.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fsingcl%2Fexpress?ref=badge_shield)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fsingcl%2Fexpress.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fsingcl%2Fexpress?ref=badge_large)*badge: https://img.shields.io/*