1.1.4 • Published 5 years ago

swiftflow v1.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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}!` }
  }
}
1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago