https://github.com/eik-lib/service
The HTTP server running the Eik service
https://github.com/eik-lib/service
eik
Last synced: about 2 months ago
JSON representation
The HTTP server running the Eik service
- Host: GitHub
- URL: https://github.com/eik-lib/service
- Owner: eik-lib
- License: mit
- Created: 2020-04-15T09:46:12.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2026-05-11T05:03:52.000Z (about 2 months ago)
- Last Synced: 2026-05-11T05:09:40.808Z (about 2 months ago)
- Topics: eik
- Language: JavaScript
- Homepage: https://eik.dev
- Size: 2.51 MB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @eik/service
This is the [HTTP server](https://eik.dev/docs/server/) running the Eik service.
The implementation for the different [HTTP endpoints](https://eik.dev/docs/server/http-api) are in [`@eik/core`](https://github.com/eik-lib/core#readme).
## Installation
```
npm install @eik/service
```
## Usage
This server can either be run as a Node executable, or as a Fastify plugin.
### CLI
This spins up the built-in Fastify server using configuration from your `config/` folder, or from environment variables.
```sh
npx @eik/service
```
### Fastify plugin
For a production setup, the Fastify plugin method is recommended.
```js
import fastify from 'fastify';
import Service from '@eik/service';
import SinkGoogleCloudStorage from '@eik/sink-gcs';
// Set up the Google Cloud Storage sink
// https://github.com/eik-lib/sink-gcs?tab=readme-ov-file#example
const sink = new SinkGoogleCloudStorage({
credentials: {
client_email: 'a@email.address',
private_key: '[ ...snip... ]',
projectId: 'myProject',
},
});
// Set up the Eik service as a plugin
const service = new Service({ sink });
// Set up Fastify
const app = fastify({
ignoreTrailingSlash: true,
modifyCoreObjects: false,
trustProxy: true,
});
// Register the Eik service in Fastify
app.register(service.api());
// Start the server
const run = async () => {
await service.health();
await app.listen(
service.config.get('http.port'),
service.config.get('http.address'),
);
};
run();
```
The example above shows the Google Cloud Storage sink. You can also use the [file system sink](https://github.com/eik-lib/sink-file-system), or implement the [sink interface](https://github.com/eik-lib/sink) for your own custom storage backend.