Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@machinat/http
Advanced tools
Readme
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 14 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
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.