Skip to content

Releases: stackpress/ingest

0.3.27

06 Feb 04:59
Compare
Choose a tag to compare

0.3.21

21 Jan 22:11
Compare
Choose a tag to compare

What's Changed

Mainly tests, coverage and dependencies version updates.

Full Changelog: 0.3.11...0.3.21

0.3.11

19 Dec 04:14
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.3.10...0.3.11

0.3.10

05 Dec 10:29
Compare
Choose a tag to compare

New API Methods

res.fromStatusResponse() - imports a status response object to the response.

res.fromStatusResponse({
  code: 200,
  status: 'OK',
  results: { foo: 'bar'} ,
  total: 1
});

res.toStatusResponse() - exports a response to a status response object .

res.toStatusResponse(); //--> { code: 200, status: 'OK' }

server.call() - a shortcur to emit, that can auto create a request and/or response and return a status response object

const response = await server.call('foobar', req, res);
const response = await server.call('foobar' { foo: bar });
const response = await server.call('foobar');

server.routeTo() - Allows routes to call on other routes without redirecting. Return a status response object

await server.routeTo('get', '/foo/bar', req, res);
await server.routeTo('get', '/foo/bar', { foo: bar });
await server.routeTo('get', '/foo/bar');

Full Changelog: 0.3.6...0.3.10

0.3.6

03 Dec 07:31
Compare
Choose a tag to compare

SFIAL Version

(Serverless Functions is a Lie) Ingest was designed under the assumption that serverless was designed for one unit of function. This is why the server limits are lower than a normal cloud or dedicated server. Serverless functions bundles serverless and a API gateway, but under the hood it just uses one function to process all the routing. You can visualize this as stuffing an entire app into one unit of function and that one function is ran on serverless (as compared to a Kubernetes approach to auto deploying to multiple serverless functions per entry file). While convenient for the service provider, it can cause server limits to be exceeded more often than not.

Under these circumstances, we rewrote Ingest with the following simple directives.

  • Back to basics design
  • event driven routing
  • In memory routing, first
  • entry file routing, second
  • Pluggable. Modules can intro functionality.

What's Changed

New Contributors

Full Changelog: 0.2.14...0.3.6

0.3.0 alpha

02 Dec 12:29
c6e3379
Compare
Choose a tag to compare
0.3.0 alpha Pre-release
Pre-release

Just tagging this state because it's working using action functions.

What's Changed

Full Changelog: 0.2.14...0.3.0-alpha.1

0.2.14

29 Nov 04:56
Compare
Choose a tag to compare

Pluggable Pattern

Use of plugins are optional in Ingest. The ingest pluggable pattern allows 3rd party libraries to push functionality to your app. Consider app.ts in an example project.

// [cwd]/src/app.ts
import { Factory } from '@stackpress/ingest';

const app = new Factory({
  //location of plugins
  plugins: [
    './dist/plugin/session'
    'package-in-node-modules'
  ],
  //file to look for in each plugin
  filenames: [
    '/plugin.js',
    '/plugin.json'
  ],
})

We can create a new plugin [cwd]/src/plugin/session/plugin.ts with the following code.

// [cwd]/src/plugin/session/plugin.ts
import type { Factory } from '@stackpress/ingest';

export default function plugin(app: Factory) {
  app.config.set('session', 'abc123');
};

When we call await app.bootstrap(), all plugins will be loaded. Specifically app will have a session found in app.config('session'). While this is good for initial setup, we can go deeper and plugin at certain points of your app using events. Consider the following code.

// [cwd]/src/plugin/session/plugin.ts
import type { Factory } from '@stackpress/ingest';

export default function plugin(app: Factory) {
  app.config.set('session', 'abc123');
  app.on('session-signin', (req, res) => {
    //encode password using 'abc123' ...
  });
};

You can see a use of plugins here: https://github.com/stackpress/ingest/tree/main/examples/with-vercel

What's Changed

New Contributors

Full Changelog: 0.2.10...0.2.14

0.2.10

26 Nov 08:47
Compare
Choose a tag to compare

Callable

Request props (data, headers, session, query, post), Context props (data, headers, session, query, post) and Response props (headers, session, errors) now are callable functions used to retrieve data within their respective objects. For example:

req.data('id')
//is the same as...
req.data.get('id')

Full Changelog: 0.2.7...0.2.10

0.2.7

25 Nov 13:14
Compare
Choose a tag to compare

Context

Framework now passes Context instead of Request in entry files. Before entry files use to look like the following.

import { Request, Response } from '@stackpress/ingest';

export default function UserDetail(req: Request, res: Response) {
  //get params
  const ctx = req.fromRoute('/user/:id');
  const id = ctx.params.get('id');
  //maybe get from database?
  const results = { 
    id: id, 
    name: 'John Doe', 
    age: 21, 
    created: new Date().toISOString() 
  };
  //send the response
  res.setResults(results);
};

Contexts are shallow copies of Requests with the routes like /user/:id already processed. It now looks like the following code.

import { Context, Response } from '@stackpress/ingest';

export default function UserDetail(ctx: Context, res: Response) {
  //get params
  const id = ctx.params.get('id');
  //maybe get from database?
  const results = { 
    id: id, 
    name: 'John Doe', 
    age: 21, 
    created: new Date().toISOString() 
  };
  //send the response
  res.setResults(results);
};

Take into consideration a route like /user/:id and a route /user/search. If the URL being requested was https://localhost/user/search, both routes would match and be triggered, but /user/search should not care about :id. Thus these are 2 different request contexts. Contexts have a param property that extract the route parameters from the route string. To get the ID in /user/:id you can do the following code.

ctx.param.get('id');

Stage Data

request and context now merge the data from query, post and param in that respective order and stores that merged data inside the data property. Entry files that intends to be used across many mediums (ie. http, terminal, socket requests) should use data instead of post/query/... in order to be agnostic.

// ex. /user/2?name=doe
const id = ctx.data.get('id'); //--> 2
const name = ctx.data.get('name'); //--> doe

Full Changelog: 0.2.6...0.2.7

0.2.6

25 Nov 04:52
Compare
Choose a tag to compare

Beta 2

Reorganized and simplified the project in a way there is a clear separation between build time and run time libraries.

Full Changelog: 0.1.25...0.2.6