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

throubell

v1.0.6

Published

Model that replaces the functions of other modules with those of Throubell, more understandable and easier to handle

Downloads

7

Readme

[email protected]

Version Status Build Status checks Status Release Status License Status

Throubell is a module that is in its initial stage, it has some basic functionalities such as: get, put, post, etc. throubell will facilitate some tasks for you to connect to a database and create a js file that creates configurations for you, these are some of its simple functionalities, remember that it is only in its initial stage, the goal is to shorten some methods , throubell is made with express, the objective is to shorten methods and make the code easier, I will update it weekly, for more information on how to use the documentation, I hope you find it useful.

Install:

You should first install it with the following command

npm i throubell

You will have to request it in your javascript file and set the class with which it will be handled

const throubell = require('throubell');
const thr = new throubell();

How to use:

To use your methods use thr at the beginning of each method.

thr.method();

Open Port

To open a server on the port heard by your pc or on the 3000, use the following syntax:

thr.onPORT(process.env.PORT || 3000); // throubell issues a message if the port was successfully opened, the same will happen with the error

body-parser

throubell incorporates the body-parser module, in order to make the correct adjustments use the following syntax.

// extended: false
thr.extendedBody(false);
// jsonBody
thr.jsonBody();

Static Files

To use static files the following method must be used:

thr.staticFiles(// path of files);

//Example

thr.staticFiles('public');

HTTP methods

The http methods are important when developing a web application, that's why throubell offers you some of the most important htpp methods, they are not 100% tested, in fact, it is very likely that an error will occur when developing, leave comments about errors.

GET

  • The GET method is used as follows
thr.get('/', (req, res) => {
    res.json({
        ok: true,
        name: 'name'
    });

    // your code
})

POST

  • The POST method is used as follows
thr.post('/', (req, res) => {
    let body = req.body;
    // your code
})

PUT

  • The PUT method is used as follows
thr.put('/', (req, res) => {
    // your code
})

DELETE

  • The DELETE method is used as follows
thr.delete('/', (req, res) => {
    // your code
})

Note: get methods are very important when making requests, it is also useful when rendering a file. check doc


Mongoose

In throubell we have incorporated some shortened methods, mongoose now it will be better to use some methods, simpler and improved, remember that it is in version 1.0.0, so there are not many features for this, in the future we will be adding much more things.

Methods:

  • directConnectToDB: This method allows you to connect to a mongo database just by putting the url inside the method, putting the url in single quotes, if everything goes well when making the connection, it will send you a message saying DataBase is online : url, on the contrary if something fails this method will throw an error.

// enter the variable in the method thr.directConnectToDB(DB);


**Note:** later we will see how to create a `config file` automatically with `throubell`, config file where all the port configurations will be, until connecting to a `Mongo Atlas DB`.

---------

## WebSockets in server (BUILDING)
Well, `throubell` has decided to implement `websockets`, `throubell` `websockets` is written under `socket.io 2.0`, sockets are only available for the server side, we are working to update and update it for the frontend, this version of socket offered by `throubell` is not It has been `100%` tested so it is very likely that some type of error will happen, in fact the possibilities are `95%`, we are working to test it well and update it, I have been very busy so it has not been possible to dedicate myself to 100% module, here a little `tutorial`.

### Methods

- **on:** The on method is used to listen to some event such as the connection or disconnect. 
```js
thr.on('connection', function(client){
    //client.on
    //client.emit

    // others events
});

How to create a config file automatically

  • configHelper: This method will allow you to create a js file with some settings that throubell do for you, these settings are so that your app can be launched into production, you simply have to request the file from your main js file and make use of its variables.

How to use configHelper.js file

To use the configHelper.js file you must require it in your main js file.

require('//path of your configHelper.js file');
  • process.env.URLDB: go to configHelper.js and set urlDB variable, just change the database path.
let urlDB;

if (process.env.NODE_ENV === 'dev') {
    urlDB = 'mongodb://localhost:27017/test'; // local dataBase
} else {
    urlDB = 'mongodb+srv://username:<password>@cluster0-mbqdw.mongodb.net/database'; 
    // your url mongoDB Atlas
}

process.env.URLDB = urlDB;

Once you've configured that, you can go to your main js file and use the process.env.URLDB variable

thr.directConnectToDB(process.env.URLDB);
  • process.env.PORT: To configure the port and be able to launch the app to production, use this variable to open the port, it will simply take port 3000 and if it does not exist it will take the one given.
thr.onPORT(process.env.PORT);

Console Messages

Throubell offers you the functionality of being able to print messages by console with its personalization, here we will leave you the clg that you can use.

  • clgErr: This method will print an error message by console.
  • clgSucc: Invoke this method and print a message on console if everything went correctly. example:
thr.clgSucc('Sucess message');
  • clgWarn: If you want to issue a warning use this method.
thr.clgWarn('Warning message');

Others Methods

  • USE: Basically this method helps them to configure midlewares.

// other example

thr.jsonBody(); // you can also write like this thr.use(bodyParser.json());


- **gitIgn:** Use this `method` if you want to `generate` a `.gitignore` file.
<br>
**example:**
```javascript
thr.gitIgn(boolean, [data], 'message');
// example
thr.gitIgn(true, ['node modules'], 'git ignore create succefully');

boolean: In the boolean it must have a value of true since if it has false the file will not be generated.

data: In the data is the value that we enter in the .gitignore file and what will not upload when uploading our file to github.

message: This will be the message that the console prints if it was possible to generate the file with the data.


Releases

[email protected]: Nothing [email protected]: Nothing [email protected]: Nothing [email protected]: Nothing [email protected]: This version integrates custom console message types offered by throubell, also offers functionality to generate a .gitignore file. [email protected]: This version integrates how to call Static Files and how use socket with throubell.`


More Information

This package was made by luis-dev-npm, The objective of this package is simply to make the code smaller in different proportions, for more information visit the doc.

throubell.org