You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

jetpress

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jetpress

JetPress is a high-performance, flexible, and extensible web server framework designed to streamline web development.JetPress aims to provide developers with an efficient and versatile platform for building web applications and APIs.JetPress is a high-per


Version published
Maintainers
0
Created

Readme

Source

JetPress

JetPress is a high-performance, flexible, and extensible web server framework designed to streamline web development.JetPress aims to provide developers with an efficient and versatile platform for building web applications and APIs.JetPress is a high-performance Node.js framework for building fast and scalable server applications using TypeScript. It also supports Bun for an even faster runtime experience.

jetpress
npm i jetpress@latest
Key Features
  1. High Performance: Built with performance in mind, JetPress ensures rapid request handling and efficient resource management.
  2. Flexible Routing: Supports both static and dynamic routing, allowing developers to easily define routes and handle requests.
  3. Static File Serving: Effortlessly serve static files from specified directories, making it ideal for serving HTML, CSS, JavaScript, images, and other assets.
  4. Middleware Support: Integrate custom middleware to handle request preprocessing, logging, authentication, and other tasks.
  5. Built-in Body Parser: Automatically parses incoming request bodies, supporting JSON, URL-encoded, and multipart form data. This includes built-in support for handling file uploads.
  6. File Uploader: Seamlessly handle file uploads, with easy access to uploaded files through the request object.
  7. Cookie Parser: Built-in support for parsing cookies, allowing for easy manipulation and management of cookies within your application.
  8. URL Parser: Comprehensive URL parsing capabilities, extracting query parameters, path variables, and other URL components.
  9. Modular Design: Promotes a modular approach, enabling developers to organize their codebase efficiently.
  10. TypeScript Support: Written in TypeScript, providing strong type definitions and interfaces, enhancing development experience and reducing runtime errors.
  11. Extensible: Easily extend JetPress with additional features and plugins as needed.

Full documentation

Example Use Case
import { readFile, writeFile } from "fs";
import { Request, Response,FormWizard, Router, Server } from "jetpress";
import path from "path";

const server = new Server();

// Middleware for parsing form data
server.use(FormWizard);

// Static file serving
server.static('/static', path.join(__dirname, 'public'), {
    cacheControl: 'public, max-age=31536000', // 1 year
    headers: {
        'Content-Security-Policy': "default-src 'self'",
        'X-Content-Type-Options': 'nosniff',
        'X-Frame-Options': 'DENY',
        'X-XSS-Protection': '1; mode=block'
    }
});
server.static('/uploads', './uploads');
// Serve static folder with cache control and custom headers
server.static('/static', path.join(__dirname, 'public'), {
    cacheControl: 'public, max-age=31536000', // 1 year
    headers: {
        'Content-Security-Policy': "default-src 'self'",
        'X-Content-Type-Options': 'nosniff',
        'X-Frame-Options': 'DENY',
        'X-XSS-Protection': '1; mode=block'
    }
});

// Define routes
server.get('/', (req: Request, res: Response) => {
    res.html('<h1>Welcome to JetPress!</h1>');
});

server.post('/upload', (req: Request, res: Response) => {
    const uploadedFile = req.file;
    if (!uploadedFile) {
        return res.status(400).send('No file uploaded.');
    }

    const newPath = path.join(__dirname, 'uploads', uploadedFile.filename);
    writeFile(newPath, uploadedFile.buffer, err => {
        if (err) throw err;
        console.log('File saved successfully:', newPath);
        res.send('File uploaded and processed successfully.');
    });
});

// Example route using router
const router = new Router();
router.get("/example", (req: Request, res: Response) => {
    res.json({ message: "Hello from the router!" });
});
server.use('/api', router);

// Handle all other routes with a 404
server.use("*", (req: Request, res: Response) => {
    res.html("Not Found");
});

// Start the server
server.listen(3000, () => {
    console.log('JetPress server running at http://localhost:3000');
});

With JetPress, you can build modern web applications quickly and efficiently, leveraging its high performance, flexible routing, and comprehensive feature set. Whether you're building a simple website or a complex API, JetPress has the tools you need to succeed.

Contributing

If you want to encourage contributions, include guidelines for contributing to the project. This may include information on how to report issues or submit pull requests.

FAQs

Package last updated on 05 Jul 2024

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc