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

@refactor-later/core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@refactor-later/core

Basic http-server functionality

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Maintainability Test Coverage

Most importantly, here are the badges. :)

@refactor-later/core

This is a fun repository to play around with node http.
It is not its aim to be a production ready framework. If you are looking for a solid solution maybe try one of my favorites:

Nest.js
If you love typescript and/or angular you will love it aswell.

Fastify
Currently the fastest lightweight framework around.

Hapi.js
Lightweight and easy to configure.

Express.js
And of course the good old express.

Installation

npm install @refactor-later

Usage

const http = require('http')
const { createApp, prepareRoutes } = require('@refactor-later/core')

const PORT = process.env.port || 3000

const routes = prepareRoutes({
  GET: [
    {
      path: '/',
      handler: (req, res) => {
        res.writeHead(200, {
          'Content-Type': 'application/json'
        })
        res.write(JSON.stringify({ hello: 'world' }))
        res.end()
      }
    },
    {
      path: '/posts/:postId?sort=date',
      handler: (req, res) => {
        const { postId } = req.params
        const { sort } = req.query
        res.writeHead(200, {
          'Content-Type': 'application/json'
        })
        res.write(JSON.stringify({ 
          postId,
          sort
        }))
        res.end()
      }
    }
  ]
})

const app = createApp({ routes })
const server = http.createServer(app)

server.listen(PORT, () => {
  console.log(`Server listening on port ${PORT}`)
})

API

TBD

createApp(config)


prepareRoutes(routes)


mergeRoutes(route1, routes2, ...)


Keywords

FAQs

Package last updated on 14 Apr 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

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