Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

platformatic

Package Overview
Dependencies
Maintainers
8
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

platformatic

Platformatic CLI

  • 2.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
845K
increased by20.43%
Maintainers
8
Weekly downloads
 
Created

What is platformatic?

Platformatic is a versatile npm package designed to simplify the development of modern web applications. It provides a suite of tools and features that streamline the process of building, deploying, and managing web services and APIs.

What are platformatic's main functionalities?

API Development

This feature allows developers to quickly set up and manage API endpoints. The code sample demonstrates how to create a simple server with a single GET endpoint that returns a 'Hello, world!' message.

const { createServer } = require('platformatic');

const server = createServer({
  routes: [
    {
      method: 'GET',
      url: '/hello',
      handler: async (request, reply) => {
        return { message: 'Hello, world!' };
      }
    }
  ]
});

server.listen(3000, (err) => {
  if (err) {
    console.error('Error starting server:', err);
  } else {
    console.log('Server listening on port 3000');
  }
});

Database Integration

Platformatic provides seamless database integration, allowing developers to connect to and query databases easily. The code sample shows how to set up a route that fetches data from a 'users' table in a database.

const { createServer } = require('platformatic');
const { connect } = require('platformatic-db');

const server = createServer({
  routes: [
    {
      method: 'GET',
      url: '/users',
      handler: async (request, reply) => {
        const db = await connect();
        const users = await db.query('SELECT * FROM users');
        return users;
      }
    }
  ]
});

server.listen(3000, (err) => {
  if (err) {
    console.error('Error starting server:', err);
  } else {
    console.log('Server listening on port 3000');
  }
});

Authentication

Platformatic includes built-in authentication mechanisms to secure endpoints. The code sample demonstrates how to protect a route using an authentication middleware.

const { createServer } = require('platformatic');
const { authenticate } = require('platformatic-auth');

const server = createServer({
  routes: [
    {
      method: 'GET',
      url: '/secure',
      preHandler: authenticate,
      handler: async (request, reply) => {
        return { message: 'This is a secure endpoint' };
      }
    }
  ]
});

server.listen(3000, (err) => {
  if (err) {
    console.error('Error starting server:', err);
  } else {
    console.log('Server listening on port 3000');
  }
});

Other packages similar to platformatic

Keywords

FAQs

Package last updated on 08 Nov 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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc