Skip to content

A simple Node.js sample pilet feed service for use with Piral. 🚀

License

Notifications You must be signed in to change notification settings

marceloeguino/sample-pilet-service

 
 

Repository files navigation

Piral Logo

A simple Node.js sample pilet feed service for use with Piral.

Getting Started

For running this sample locally all you need to do is running:

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):

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
HTTP_X_FORWARDED_PROTO The used protocol (e.g., http), otherwise falling back to the HTTPS setting

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:

npx sample-pilet-service

You could also install it globally:

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.

About

A simple Node.js sample pilet feed service for use with Piral. 🚀

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.0%
  • JavaScript 2.6%
  • Dockerfile 0.4%