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

@lund-org/cherry

v0.2.2

Published

A light framework to quickly create a web server

Downloads

10

Readme

🍒 Cherry

Build Status Maintainability Test Coverage

Cherry is a lightweight framework to quickly generate a web server

:electric_plug: Installation

Use the package manager npm to install Cherry.

npm install @lund-org/cherry

:wrench: Usage

Checkout the example in the example folder.

For the development : To use the https mode, you need to generate the ssl keys, you can use this command in the config folder :

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/C=FR/ST=./L=./O=./OU=./CN=."

Warning : It doesn't work on Windows, you will only get the key.pem with this command. Let's find the way to do it on stackoverflow :joy:


Hooks

Example here

You can hook some events and retrieve informations. It is useful to add some code at specific moment of the workflow.

| Hook Name | Data sent | |------------ |--------- | | beforeStartServer | { cherry: <Cherry>, server: <CherryHTTPSServer or CherryHTTPServer> } | | afterStartServer | { cherry: <Cherry>, server: <CherryHTTPSServer or CherryHTTPServer> } | | beforeStopServer | { cherry: <Cherry>, server: <CherryHTTPSServer or CherryHTTPServer> } | | afterStopServer | { cherry: <Cherry>, server: <CherryHTTPSServer or CherryHTTPServer> } | | beforeStartOrm | { cherry: <Cherry>, orm: <The ORM plugin instance> } | | afterStartOrm | { cherry: <Cherry>, orm: <The ORM plugin instance> } | | beforeStopOrm | { cherry: <Cherry>, orm: <The ORM plugin instance> } | | afterStopOrm | { cherry: <Cherry>, orm: <The ORM plugin instance> } | | beforeProcess | { request: <CherryIncomingMessage>, response: <CherryServerResponse>, middlewares: <Array<Function>> } | | afterProcess | { request: <CherryIncomingMessage>, response: <CherryServerResponse>, processResult: <The return value of the callback> } |


Route types

Example here and here

There is 2 types of route, the public folders to retrieve raw resources and the configured routes.

:warning: The public routes are always resolved at first

Public routes

| Route Name | Description | Options | |------------ |--------- |--------- | | PUBLIC_ROUTE_PUBLIC_FOLDER | The folder where we will find a resource.It's an entrypoint, it means that if you request a route /my/route.html, if you have it as a configured route and the same path available in your public folder, it will retrieve the file in the public folder and then quit | path : The absolute path of the folderpriority (optionnal) : The priority of check |

Configured routes

| Route Name | Description | Options | |------------ |--------- |--------- | | ROUTE_CONTEXT | A wrapper of routes which allows to avoid to set the same thing for a bunch of routes.For example, if you have an admin, you will have a middleware to check the authentication and the rights of the user. To not set it to every routes, you can put in on the ROUTE_CONTEXT and it will apply to subsequent routes | type : The type of route, here ROUTE_CONTEXTcollection : The array of subroutesname (optionnal) : The name of the route which will be added before the name of the subroutesmethod (optionnal) : The default HTTP method of the subroute, can be overridingpath (optionnal) : The leading path which will be added before the path of the subroutesmiddlewares (optionnal) : The middlewares to execute for each subroutesrules (optionnal) : The rules for route parameters if there is some in the path | | ROUTE | A configured route which will execute your code when requested | type : The type of route, here ROUTEpath : The path of the routecallback : The method to execute when the route is requestedname (optionnal) : The name of the route. It can be useful to detect it in a hookmethod (optionnal) : The HTTP method of the route, it overrides the value set in the context (if present)middlewares (optionnal) : The middlewares to execute before accessing to the callbackrules (optionnal) : The rules for route parameters if there is some in the path |

:scroll: To do list

:open_file_folder: Resources

View engine plugin

ORM plugin

:computer: Applications using Cherry (as a real example)

  • Livedeck-server : This project is the core of the livedeck project. It's the central point between the web/smartphone client and the software client. Like a bridge but with a database.

:pencil2: Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

:book: License

MIT