Development server for local development of helix universal functions
$ npm install @adobe/helix-universal-devserver
// test/dev.js
import { DevelopmentServer } from '@adobe/helix-universal-devserver';
import { main } from '../src/index.js';
async function run() {
const devServer = await new DevelopmentServer(main).init();
await devServer.start();
}
run().then(process.stdout).catch(process.stderr);
sometimes it is useful to test a bundled universal function directly, for example to verify that
all imports are properly resolved. This can be achieved by setting the adapter
, either to
lambda
or lambda.raw
. the later bypasses loading of the secrets.
import { lambda } from '../../dist/helix-services/[email protected]';
async function run() {
const devServer = await new DevelopmentServer()
.withHeader('x-forwarded-host', 'localhost:{port}')
.withAdapter(lambda.raw) // use raw adapter and don't load secrets
.init();
await devServer.start();
}
Sometimes it might be useful to specify action params that would be provided during deployment
but are not available during development. those can be specified by a dev-params-file
wsk
property. those parameters are loaded an applied to every function call. eg:
{
// ...
"wsk": {
// ...
"dev-params-file": ".dev-secrets.env"
},
// ...
}
$ npm install
$ npm test
$ npm run lint