Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smapiot/sample-pilet-service
A simple Node.js sample pilet feed service for use with Piral. :rocket:
https://github.com/smapiot/sample-pilet-service
express feed hacktoberfest microfrontend nodejs pilet piral service
Last synced: 4 days ago
JSON representation
A simple Node.js sample pilet feed service for use with Piral. :rocket:
- Host: GitHub
- URL: https://github.com/smapiot/sample-pilet-service
- Owner: smapiot
- License: mit
- Created: 2019-06-18T22:42:58.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-12-05T23:57:28.000Z (about 2 months ago)
- Last Synced: 2025-01-21T03:07:39.512Z (12 days ago)
- Topics: express, feed, hacktoberfest, microfrontend, nodejs, pilet, piral, service
- Language: TypeScript
- Homepage: https://piral.io
- Size: 1.19 MB
- Stars: 36
- Watchers: 5
- Forks: 23
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![Piral Logo](https://github.com/smapiot/piral/raw/main/docs/assets/logo.png)](https://piral.io)
# [Sample Pilet Feed](https://piral.io) · [![Build Status](https://smapiot.visualstudio.com/piral/_apis/build/status/smapiot.sample-pilet-service?branchName=main)](https://smapiot.visualstudio.com/piral/_build/latest?definitionId=14&branchName=main) [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![GitHub Tag](https://img.shields.io/github/tag/smapiot/piral.svg)](https://github.com/smapiot/piral/releases) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
A simple Node.js sample pilet feed service for use with Piral. If you don't want to play around with a feed service locally then use the (free) community edition of the [official Piral Feed Service](https://feed.piral.cloud/). Alternatively, if you are interested in more beef such as running the official Piral Feed Service in your environment or accessing premium features in the online edition then have a look at [Piral Cloud website](https://www.piral.cloud/).
## Getting Started
For running this sample locally all you need to do is running:
```sh
npm i && npm start
```**Remark**: This sample requires Node.js and NPM. The used port is `9000`, which could be re-configured easily (e.g., via an environment variable `PORT`).
## Auth Keys
For publishing a Pilet a handful premade keys have been added (file: `src/auth/keys.ts`):
```plain
df133a512569cbc85f69788d1b7ff5a909f6bcfe1c9a2794283a2fc35175882c
da91e6a8aeee998b7d6b0701486e4909d2ee14fbcc0af5de601c1d09982141d5
f94fa7067e0299679af2b1dda6f1835cd7ed03a43c104446954b11ec7b1509d0
edf8c9275873ca743394b3367e67149d6fda5306b577113fbf1ff4f191de69e4
ad647bdc23b7437b8fa8f27c3e2d3f70fbb493c53e9160e07d37a98df333b188
```Either change the file when using this service in any non-local infrastructure or set the environment variable `PILET_API_KEYS` with comma separated values (e.g., `A,B,C` uses three keys `A`, `B`, and `C` instead).
## Pilet Database
For this simple sample everything is kept in memory. If you want to change this behavior to store the pilets also in a database / some storage you will need to modify the `src/db/index.ts` file.
**Remark**: The file has been prepared in such a sense that all exposed functions already return promises.
## Reported URL
For the pilets the reported URL is `http://localhost/...` unless changed via `src/constants.ts`. For simplicity, a resolution algorithm based on standard environment variables is already active.
| Variable | Meaning |
|------------------------|---------------------------------------------------------------------------------|
| WEBSITE_HOSTNAME | The name of the host, e.g., `localhost` |
| PORT | The port, otherwise falling back to 9000 |
| HTTPS | Is HTTPS active, otherwise falling back to HTTP |
| PILETS_SNAPSHOT | Defines the path of the database snapshot directory |
| HTTP_X_FORWARDED_PROTO | The used protocol (e.g., `http`), otherwise falling back to the `HTTPS` setting |## Snapshot
By default, the service creates a directory called `pilets` in the current working directory. If you don't want this (i.e., no snapshot should be created) then set the `PILETS_SNAPSHOT` environment variable to an empty string i.e., `PILETS_SNAPSHOT=""`. Otherwise, if you want to use another directory, set the variable to a directory, e.g., `PILETS_SNAPSHOT=/tmp/pilets`.
## Usage via NPM
Alternatively, if you want to use the service only locally to play around you can also install and run the package via NPM:
```sh
npx sample-pilet-service
```You could also install it globally:
```sh
npm i sample-pilet-service -g
```This will enable a new command `sample-pilet-service` to be invoked on the command line shell.
## License
Piral is released using the MIT license. For more information see the [license file](./LICENSE).