@splitscript.js/https
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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

Package Sidebar

Install

npm i @splitscript.js/https

Weekly Downloads

50

Version

2.0.1

License

MIT

Unpacked Size

24.7 kB

Total Files

17

Last publish

Collaborators

  • infrareddevs