wapi-core
Core module for weeb.sh APIs
How to use it
- Install via Yarn or NPM
yarn add @weeb_services/wapi-core
npm i @weeb_services/wapi-core
- Create an index.js with the following code
const { WeebAPI } = require('@weeb_services/wapi-core');
class YourAPI extends WeebAPI {
async onLoad() {
}
async onLoaded() {
}
async registerMiddlewares(app) {
}
async registerRouters(app) {
}
async onInitialized() {
}
}
new YourAPI().init();
- Create a folder called "config" in your project root and put a file called "main.json" into that with the following contents
{
"host": "127.0.0.1",
"port": 8080,
"env": "development",
"sentry": "",
"track": "",
"redis": "",
"mongodb": "",
"registration": {
"enabled": false,
"host": "",
"token": "",
"checks": null
},
"whitelist": [
{
"path": "/"
}
],
"irohHost": "http://localhost:9010"
}
-
Make sure you have a package.json file in your project root
-
Run it! It should start up and show something if you open http://localhost:8080 in your browser. For authentication and such you should also get an instance of Iroh up and running and provide a token as a header.
How to develop with it
The module provides several utilites to help creating an API like a Router class and such. Here are some of the available classes:
const {
Async,
Constants,
FileCache,
Middleware,
Redis,
Require,
Route,
Router,
Util,
WeebAPI,
} = require('@weeb_services/wapi-core');