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

sapix

v1.0.1

Published

sapix is a high-performance, scalable, and developer-friendly web framework for Node.js, designed to provide a superior alternative to existing frameworks with built-in security, efficient routing, and a modular architecture.

Downloads

32

Readme

Sapix Library Documentation

SAPIX: Simple API Processing and Integration eXperience

Welcome to Sapix, a lightweight library designed to help you build robust servers with intuitive routing. This documentation provides examples and instructions to get you started using Sapix effectively.


Installation

Install Sapix via npm:

npm install sapix

Usage Overview

Below is an example of setting up a server using Sapix and configuring multiple routes with different HTTP methods.


Step-by-Step: Create Routes with Sapix

GET / – Home Route

routes.get('/', (res) => {
    res.status(200).sendText('Welcome to sapixRoutes Home Page!');
});
  • Purpose: Handles the homepage request and responds with text.
  • Response:
    Welcome to sapixRoutes Home Page!

GET /profile/:id/user/:userId – Dynamic Route with Params

routes.get('/profile/:id/user/:userId', (res, query, path_params) => {
    res.status(200).sendJSON({ 
        message: 'This is a JSON response.', 
        query, 
        path_params 
    });
});
  • Purpose: Responds with JSON including query and path parameters.
  • Example Request:
    GET /profile/1/user/456?status=active
  • Example Response:
    {
      "message": "This is a JSON response.",
      "query": { "status": "active" },
      "path_params": { "id": "1", "userId": "456" }
    }

HTTP Method Examples

POST /profile – Create User Profile

routes.post('/profile', (res) => {
    res.status(200).sendJSON({ message: 'Profile created successfully.' });
});
  • Purpose: Responds to POST requests with a confirmation message.
  • Response:
    { "message": "Profile created successfully." }

DELETE /profile – Delete User Profile

routes.delete('/profile', (res) => {
    res.status(200).sendJSON({ message: 'Profile deleted successfully.' });
});
  • Purpose: Responds with a message confirming deletion.
  • Response:
    { "message": "Profile deleted successfully." }

PATCH /profile – Update User Profile

routes.patch('/profile', (res) => {
    res.status(200).sendJSON({ message: 'Profile updated successfully.' });
});
  • Purpose: Responds with a message confirming the profile update.
  • Response:
    { "message": "Profile updated successfully." }

Additional Routes

GET /about – About Page

routes.get('/about', (res) => {
    res.status(200).sendHTML('<h1>Welcome to the About Page!</h1>');
});
  • Purpose: Sends an HTML response for the "About" page.
  • Response:
    <h1>Welcome to the About Page!</h1>

GET /error – Error Handling

routes.get('/error', (res) => {
    res.sendError('An unexpected error occurred.', 500);
});
  • Purpose: Simulates a server error response.
  • Response:
    { "error": "An unexpected error occurred." }

Starting the Sapix Server

Once your routes are defined, start the server using the following code:

import { sapixServer, sapixRoutes } from 'sapix';

// Create routes
const routes = new sapixRoutes();

// Start the server
const server = new sapixServer()
    .setPort(4000)    // Specify the port
    .setRoute(routes) // Attach the routes
    .start();         // Start the server

Your server will now be running at http://localhost:4000.


Key Features of Sapix

  1. Simple: Easy to configure with minimal setup.
  2. API-oriented: Focused on building APIs efficiently.
  3. Processing-friendly: Handles different HTTP methods (GET, POST, PATCH, DELETE).
  4. Integrated: Supports dynamic routes, query params, and path params.
  5. Xperience-first: Provides error handling and a smooth developer experience.

Project Structure

├── index.js           // Main server script
└── package.json       // Project metadata and dependencies

How to Test

  • GET Request:
    Visit http://localhost:4000/profile/1/user/456 in your browser or Postman.

  • POST Request:
    Send a POST request to http://localhost:4000/profile with an appropriate payload.


Error Handling

Use sendError to return error responses:

routes.get('/error', (res) => {
    res.sendError('Something went wrong!', 500);
});

Feedback & Contribution

Feel free to contribute to this project by submitting pull requests or opening issues.


License

This project is licensed under the MIT License.


Enjoy the Simple API Processing and Integration eXperience with Sapix! 🚀