wildcard-api | Wildcard is a JavaScript library to create an API | REST library
kandi X-RAY | wildcard-api Summary
kandi X-RAY | wildcard-api Summary
Wildcard is a JavaScript library to create an API between your Node.js backend and your browser frontend. With Wildcard, creating an API endpoint is as easy as creating a JavaScript function. That's all Wildcard does: it makes functions, that are defined on your Node.js server, callable in the browser. Nothing more, nothing less. To retrieve and mutate data, you can direclty use SQL or an ORM. Wildcard is used in production at many companies, every release is assailed against a heavy suite of automated tests, and issues are fixed promptly. It is financed with the Lsos. :sparkles: Easy Setup :shield: Simple Permissions :rotating_light: Simple Error Handling :detective: Dev Tools :microscope: TypeScript Support :memo: SSR Support :zap: Automatic Caching.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Starts the Hapi server .
- Page page to fetching the user .
- Wraps the loading API .
- Fetch the completed todo page
- creates a new collection
- Show a todo
- Update todos
- check a todo
- Ensure that the database exists .
- Render a page
wildcard-api Key Features
wildcard-api Examples and Code Snippets
Community Discussions
Trending Discussions on wildcard-api
QUESTION
In application's responses we see doubled transfer-encoding headers.
Suppose, because of that we get 503 in UI, but at the same time application returns 201 in pod's logs.
Except http code: 201
there are transfer-encoding=chunked
and Transfer-Encoding=chunked
headers in logs, so that could be a reason of 503.
We've tried to remove transfer-encoding
via Istio virtual service or envoy filter, but no luck..
Here are samples we tried:
VS definition:
...ANSWER
Answered 2021-Mar-23 at 14:02Decision so far: created requirement for dev team to remove the duplication of chunked encoding
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wildcard-api
Install Wildcard. With Express: const express = require('express'); // npm install @wildcard-api/server const { wildcard } = require('@wildcard-api/server/express'); const app = express(); // We install the Wildcard middleware app.use(wildcard(setContext)); // `setContext` is called on every API request. It defines the `context` object. // `req` is Express' request object async function setContext(req) { const context = {}; // Authentication middlewares usually make user information available at `req.user`. context.user = req.user; return context; } With Hapi const Hapi = require('hapi'); // npm install @wildcard-api/server const { wildcard } = require('@wildcard-api/server/hapi'); const server = Hapi.Server(); // We install the Wildcard middleware await server.register(wildcard(setContext)); // `setContext` is called on every API request. It defines the `context` object. // `request` is Hapi's request object async function setContext(request) { const context = {}; // Authentication plugins usually make user information // available at `request.auth.credentials`. context.user = request.auth.isAuthenticated ? request.auth.credentials : null; return context; } With Koa const Koa = require('koa'); // npm install @wildcard-api/server const { wildcard } = require('@wildcard-api/server/koa'); const app = new Koa(); // We install the Wildcard middleware app.use(wildcard(setContext)); // `setContext` is called on every API request. It defines the `context` object. async function setContext(ctx) { const context = {}; // Authentication middlewares often make user information available at `ctx.state.user`. context.user = ctx.state.user; return context; } With other server frameworks Wildcard provides a getApiHttpResponse() function which returns the HTTP response of API requests; by using getApiHttpResponse() you can integrate Wildcard with any server framework. In fact, the Express/Koa/Hapi middlewares are just tiny wrappers around getApiHttpResponse(). // This is generic pseudo code for how to integrate Wildcard with any server framework. // npm install @wildcard-api/server const { getApiHttpResponse } = require('@wildcard-api/server'); // A server framework usually provides a way to add a route and define an HTTP response. const { addRoute, HttpResponse } = require('your-favorite-server-framework'); // Add a new route `/_wildcard_api/*` to your server addRoute( '/_wildcard_api/*', // A server framework usually provides an object holding // information about the request. We denote this object `req`. async ({req}) => { // The context object is available to endpoint functions as `this`. const context = { user: req.user, // Information about the logged-in user. }; const { url, // The HTTP request url (or pathname) method, // The HTTP request method (`GET`, `POST`, etc.) body, // The HTTP request body } = req; const responseProps = await getApiHttpResponse({url, method, body}, context); const {body, statusCode, contentType} = responseProps; const response = new HttpResponse({body, statusCode, contentType}); return response; } );
Define an endpoint function myFirstEndpoint in a file called endpoints.js. // Node.js server const { server } = require('@wildcard-api/server'); server.myFirstEndpoint = async function () { // The `this` object is the `context` object we defined in `setContext`. console.log('The logged-in user is: ', this.user.username); return {msg: 'Hello, from my first Wildcard endpoint'}; }; :information_source: Wildcard automatically loads files named endpoints.js or *.endpoints.js.
Use the @wildcard-api/client package to remotely call enpdoint.myFirstEndpoint from the browser. // Browser // npm install @wildcard-api/client import { server } from '@wildcard-api/client'; (async () => { const {msg} = await server.myFirstEndpoint(); console.log(msg); })(); Without bundler <script crossorigin src="https://unpkg.com/@wildcard-api/client/wildcard-client.production.min.js"></script> <script src="my-script-using-wildcard.js"></script> // my-script-using-wildcard.js (async () => { const {msg} = await wildcard.server.myFirstEndpoint(); console.log(msg); })();
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page