Package Exports
- @stackpress/ingest
- @stackpress/ingest/dist/buildtime
- @stackpress/ingest/dist/buildtime/Router
- @stackpress/ingest/dist/buildtime/Router.js
- @stackpress/ingest/dist/buildtime/Server
- @stackpress/ingest/dist/buildtime/Server.js
- @stackpress/ingest/dist/buildtime/helpers
- @stackpress/ingest/dist/buildtime/helpers.js
- @stackpress/ingest/dist/buildtime/index.js
- @stackpress/ingest/dist/helpers
- @stackpress/ingest/dist/helpers.js
- @stackpress/ingest/dist/http/Builder
- @stackpress/ingest/dist/http/Builder.js
- @stackpress/ingest/dist/payload/Request
- @stackpress/ingest/dist/payload/Request.js
- @stackpress/ingest/dist/payload/Response
- @stackpress/ingest/dist/payload/Response.js
- @stackpress/ingest/dist/payload/Session
- @stackpress/ingest/dist/payload/Session.js
- @stackpress/ingest/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stackpress/ingest) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ᗊ Ingest
An unopinionated event driven serverless framework.
Install
$ npm install @stackpress/ingest
Usage
- Create an entry file called
entry.ts
// entry.ts
import { task } from '@stackpress/ingest/dist/helpers';
export default task(function UserDetail(req, res) {
//get params
const ctx = req.ctxFromRoute('/user/:id');
const id = ctx.params.get('id');
if (!id) {
res.code = 400;
res.status = 'Bad Request';
res.body = { error: 'ID is required' };
return;
}
//maybe get from database?
const results = {
id: id,
name: 'John Doe',
age: 21,
created: new Date().toISOString()
};
//send the response
res.mimetype = 'text/json';
res.body = results;
});
- Create a server file called
server.ts
// server.ts
import path from 'path';
import http from '@stackpress/ingest/http';
const server = http({ minify: false });
server.get('/user/:id', path.resolve(__dirname, 'user/detail'));
server.develop().listen(3000, () => {
console.log('Server is running on port 3000');
console.log('------------------------------');
console.log(server.router.listeners);
});