Skip to content

Latest commit

 

History

History
81 lines (53 loc) · 1.74 KB

File metadata and controls

81 lines (53 loc) · 1.74 KB

Tiny package for sending and receiving https(s) requests

install size

downloads

docs

About

This package is part of SplitScript.js, the everything framework

It's a tiny package for sending http(s) requests

Install

$ npm i @splitscript.js/https

Listen for requests

Start the server

import https from '@splitscript.js/https'
https.start({ port: 3000 })

Handle requests

Create a file in functions/http/get

import { Events } from '@splitscript.js/https'
export default async function ({ req, res }: Events.Get) {
	res.write('<html><body><h1>hello world</h1></body></html>')
	res.end()
}

Parse body

Bodys get parsed automatically

import { Events } from '@splitscript.js/https'
export default async function ({ req, res, bodyParsed }: Events.Post}) {
    res.end(JSON.stringify(bodyParsed))
}

Raw body

To get the raw body

import { Events } from '@splitscript.js/https'
export default async function ({ req, res, body }: Events.Post}) {
    res.end(body)
}
v2.0.1 | docs

by ultraviolet