@nayotta/mta-fission-onion
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

mta-fission-onion

Build and LintNode.js Package

简体中文

Used in fission/nodejs , like koajs onion code style middleware module.

Install

$ npm install @nayotta/mta-fission-onion

How to use it ?

// fission function js file
const { Onion } = require('@nayotta/mta-fission-onion')

const onion = new Onion()

onion.use(async (ctx, next) => {
	// TODO: authrization
	const authPass = true
	if (!authPass) {
		ctx.status = 401
		ctx.body = 'unauthrization'
		return
	}
	await next()
})

onion.use(async (ctx, next) => {
	// TODO: deal with data
	// ctx.context -> fission/nodejs express/request object
	const data = 'hello' + ctx.request.body.name
	ctx.status = 200
	ctx.body = {
		data
	}
})

// or injext middlewares funcs
onion.inject([async (ctx, next) => {
	// do something
	await next()
}, () => {
	// do something
	await next()
}])

module.export = onion.go()

Package Sidebar

Install

npm i @nayotta/mta-fission-onion

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

8.34 kB

Total Files

8

Last publish

Collaborators

  • goku-gaga
  • classlfz