Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adonisjs-sse

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonisjs-sse

An addon/plugin package to provide server-sent events functionality for AdonisJS 4.0+

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-28.57%
Maintainers
1
Weekly downloads
 
Created
Source

adonis-sse

An addon/plugin package to provide server-sent events functionality for AdonisJS 4.0+

NPM Version Build Status Coveralls

Getting Started


    adonis install adonisjs-sse

Usage

Setup serve-sent events route inside start/routes.js file.


/** @type {typeof import('@adonisjs/framework/src/Route/Manager')} */
const Route = use('Route');

Route.get('/stream', ({ source }) => {
      // send a server-sent events comment
      source.send(null, '!This is a comment!');
})//.middleware(['eventsource']);

Route.post('/send/email', 'NotificationsController.sendEmail')

Installation Instructions

See the instructions.md file for the complete installation steps and follow as stated.

HINT: It would be much easier and better to make the EventSourceWatcher middleware a global middleware

Example(s)

Setup a controller to dispatch server-sent events to the browser using the source.send() method like so:


/** @type {typeof import('@adonisjs/mail/src/Mail')} */
const Mail = use('Mail')

class NotificationsController {

    async sendEmail ({ request, auth, source }){

        let input = request.only([
            'ticket_user_id'
        ]);

        let { id, email, fullname } = await auth.getUser();
        let error = false

		try{

			await Mail.send(
                'emails.template', 
                { fullname }, (message) => {
				message.to(email) 
				message.from('crm.tickets@funsignals.co') 
				message.subject('Ticket Creation Job Status')
            })
            
		}catch(err){
            
            error = true
            
		}finally{

            source.send({
                ticket_reciever: id,
                ticket_creator: input.ticket_user_id,
                ticket_mail_status: `email sent ${error ? 'un' : ''}successfuly`
            }, null, 'update')
			
        }
    }
}

module.exports = NotificationsController		

License

MIT

Running Tests


    npm i


    npm run lint
    
    npm run test

Credits

Contributing

See the CONTRIBUTING.md file for info

Support

Coolcodes is a non-profit software foundation (collective) created by Oparand - parent company of StitchNG, Synergixe based in Abuja, Nigeria. You'll find an overview of all our work and supported open source projects on our Facebook Page.

Follow us on facebook if you can to get the latest open source software/freeware news and infomation.

Does your business depend on our open projects? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

Keywords

FAQs

Package last updated on 22 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc