Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

swiftflow

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swiftflow

Maintainable expressjs endpoints.

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

SwiftFlow

Maintainable expressjs endpoints.

Install

npm i --save swiftflow

Example

// server.js
const app = require("express")()
const { EndpointManager } = require("swiftflow")

// Create a new EndpointManager, points to a directory of JS files.
const endpoints = new EndpointManager("./endpoints")

// Install all JS files in "./endpoints" then listen on port 80.
endpoints.install(app).then(() => app.listen(80))
// endpoints/hello.js
const { Endpoint } = require('swiftflow')

// Export a class that extends from the SwiftFlow Endpoint class.
module.exports = class HelloEndpoint extends Endpoint {
  constructor () {
    super('/api/hello/:name') // The path this endpoint will listen to.
  }

  async execute (params) {
    // All variables like .params and .query gets combined into a single object, "params".
    const { name } = params
    
    // The Endpoint class automatically handles returns and sends it to the client.
    return { response: `Hi there ${name}!` }
  }
}

Keywords

ExpressJS

FAQs

Package last updated on 12 Jun 2019

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