npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nestjs-early-access

v1.1.1

Published

This Nest Js package makes it easy to add early access mode to your existing application. This is useful for when you want to launch a product and need to gather the email addresses of people who want early access to the application.

Downloads

10

Readme

Nestjs Early Access.

This NestJs package makes it easy to add early access mode to your existing application. This is useful when you want to launch a product and need to gather the email addresses of people who want early access or want to stay on the waiting list of the application.

Table of Contents

Usage

Installation

npm install nestjs-early-access  

EarlyAccessModule

This EarlyAccessModule is the core of the package, it serves as the main entry point and can be used in both synchronous and asynchronous manner.
Simple import the EarlyAccessModule into your application.

Synchonous Mode

Simple call the forRoot method on the synchronous mode.

EarlyAccessModule.forRoot({        
  	enabled: true    
  	    })    
export class AppModule {}  

Asynchronous Mode

EarlyAccessModule.registerAsync({      inject: [EarlyAccessService],    
   imports: [ServiceModule],    
   useFactory: (earlyAccessService: EarlyAccessService) => ({    
       repository: earlyAccessService,    
       enabled: true,    
   }),    
 })    

export class AppModule {}  

Using Default Template

Nest Js provides you to easily just add the information on your early access page using the default template if you wish. Simple provide the options object with defaultTemplate of type. Remember that you can do this in synchronous and asynchronous mode.

  EarlyAccessModule.registerAsync({  
       inject: [EarlyAccessService],  
       imports: [ServiceModule],  
       useFactory: (earlyAccessService: EarlyAccessService) => {  
         return {  
           repository: earlyAccessService,  
 	      enabled: true,  
 	      url: '/',  
 	      defaultTemplate: {  
               		assetsDir: `${process.cwd()}/assets`,  
 			productName: 'Aso Books',  
 			    logo: {  
 	                 	type: 'img',  
 				source: `/logo.svg`,  
 				},  
 		      	submitButton: {  
 	                  	color: '#5661b3',  
 			  	text: 'Join waiting list',  
 			      	},  
 		      	placeHolderImage: `/undraw_all_the_data_h4ki.svg`,  
 		      	welcomeMessage: {  
 	                  	text: 'Welcome to early access',  
 				color: '#5661b3',  
 				sub: 'You can type any thing you like to write as a sub welcome message. Do not forget to start this though.',  
 			      	},  
 			},  
 		 };  
 	   },  
     	}),  
    ],  
   controllers: [AppController],  
   providers: [AppService],  
 })  
 export class AppModule {  
 }

Using Custom Assets

You can also decide to use custom assets if you wish, although early access provides a default one out of the box for you. If you provide a template early-access will use the provided template instead.

EarlyAccessModule.forRoot({        enabled: false,    
    template: {    
         viewDir: `${process.cwd()}/views`,    
       assetsDir: `${process.cwd()}/assets`,    
       index: 'index',    
   }    
 })    
 export class AppModule {    
     
 }  

API SPEC

| property | type | description |
|---------------------|-----------------------|-------------------------------------------------------------------------------------------------------------------|
| enabled | boolean | This will activate early access when set to true and will set to false when otherwise. |
| URL | string | This is the URL to use to access the early access page this defaults to "/early-access" |
| twitterHandle | string | This is the twitter handle of your products |
| template | Object | This is the custom template you might wish to render if you do not want to use the default template. |
| template.viewDir | string | This is the directory of your custom views |
| template.assetsDir | string | This is the directory of the assets of your custom view. |
| template.index | string | This is the file that will be rendered. At this time early access uses .ejs. |
| twitterShareMessage | string | This is the message you will like to share on twitter when your user clicks share on twitter. |
| repository | EarlyAccessRepository | This is the repository you will like to use to persist the subscribers as well as removed the subscribers |

Providing the early access URL

If you want to provide a custom URL. Provide URL in the forRoot object.

EarlyAccessRepository

The nestjs-early-access uses an in-memory storage to persist. You should provide your repository to persist subscribers as well as remove subscribers.

Todos

  • Provide a notification class or an event. So that this can be implemented or subscribed to when a subscriber is created or removed.
  • Improve on read me.
  • Write better test

Credits

This was inspired from Neo's Laravel-early-access
Awwal moved the view to ejs 😇

Appreciation

If you think you like this. Show me some love if you like this. Why don't you just star it? Maybe this can encourage me to build more.