
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
@machinat/http
Advanced tools
This module provide HTTP listening capability to all the services require it. For example, to serve a webhook for subscribing events from chat platform.
This module provide HTTP listening capability to all the services require it. For example, to serve a webhook for subscribing events from chat platform.
npm install @machinat/core @machinat/http
# or with yarn
yarn add @machinat/core @machinat/http
Check the package reference.
Use listenOptions
to set the network options for server.listen()
.
import Machinat from '@machinat/core';
import Http from '@machinat/http';
const app = Machinat.createApp({
modules: [
Http.initModule({
listenOptions: {
port: 8080,
host: 'localhost',
}
}),
],
});
Provide Http.RequestRouteList
or Http.UpgradeRouteList
(for WebSocket)
to register RPC style routes. All the requests under the registered path
will
be received by the handler. You can also use default: true
to catch all
unmatch requests.
const app = Machinat.createApp({
modules: [
Http.initModule({ /* ... */ }),
],
service: [
{ // route listening to /api
provide: Http.RequestRouteList,
withValue: {
name: 'my_api',
path: '/api',
handler: (req, res) => {
// handle http requests
},
}
},
{ // default request route
provide: Http.RequestRouteList,
withValue: {
name: 'default',
default: true,
handler: (req, res) => {
// catch requests not matching any route
},
}
},
{ // handle WebSocket connection
provide: Http.UpgradeRouteList,
withValue: {
name: 'web_socket',
path: '/',
handler: (req, head, socket) => {
// handle http upgrade requests
},
}
},
],
});
FAQs
This module provide HTTP listening capability to all the services require it. For example, to serve a webhook for subscribing events from chat platform.
The npm package @machinat/http receives a total of 212 weekly downloads. As such, @machinat/http popularity was classified as not popular.
We found that @machinat/http demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.