@splitscript.js/https
v2.0.1
Published
Send and listen for HTTPS/HTTP requests
Downloads
15
Maintainers
Readme
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)
}
by ultraviolet