To start using ncr run the following commands
# download the binary
wget https://github.com/forkbombeu/ncr/releases/latest/download/ncr -O ~/.local/bin/ncr && chmod +x ~/.local/bin/ncr
# checkout this repo
git clone https://github.com/forkbombeu/ncr
# run the server with the example folder
ncr -p 3000 -z ./ncr/tests/fixtures --public-directory ./ncr/public
Opening http://localhost:3000/docs with your browser to see the result. You will found a list of all the available endpoints, that simply are the zencode files in the ./tests/fixtures
folder. Moreover you will have the possibility to access directly all the files under the ./public
folder, like http://localhost:3000/file_example_MP3_700KB.mp3.
Ncr comes also in a easy to use executable file. You can build it by running the following command
git clone https://github.com/forkbombeu/ncr
cd ncr
pnpm i
pnpm build
or dowload it from the latest realease from GitHub
wget https://github.com/forkbombeu/ncr/releases/latest/download/ncr
chmod +x ncr
and run it with the simple command
./ncr -p 3000 -z ./tests/fixtures --public-directory ./public
that will serve the zencode contract under the folder ./tests/fixtures
and the public files under the folder ./public
on http://0.0.0.0:3000.
docker pull ghcr.io/forkbombeu/ncr:latest
Configuration can be done both via CLI or via .env file.
Usage: ncr [options]
Options:
-z, --zencode-directory <directory>
--public-directory <directory>
-p, --port <number>
--zenroom-version <string>
--openapi-path <string>
--hostname <string>
--template <file>
--basepath <string>
-D, --debug
-v, --version
Test can be done with the command
pnpm i
pnpm test
Availabe bugs are reported via GitHub issues.
Coming soon.
git checkout -b feature/branch
git commit -am 'feat: New feature'
git push origin feature/branch
gh pr create --fill
noˑcodeˑroom - No code REST API server based on zencode
Copyleft 🄯 2024 The Forkbomb Company, Amsterdam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Metadata are used in NCR as ancillary files to the .zen and .keys.json, to better define behaviour and parameters of the API. The metadata file should have the same name as the .zen it follows, with the extensoin .metadata.json, see an example here. The metadata attributes, with the defualt values are listed below.
Attribute | Description | Default Value |
---|---|---|
http_headers |
Used to specify the HTTP headers. | false |
error_code |
Used to specify the error code. | '500' |
success_code |
Used to specify the success code. | '200' |
success_description |
Used to specify the success description in openApi. | 'The zencode execution output, splitted by newline' |
error_description |
Used to specify the error description. | 'Zenroom execution error' |
content_type |
Used to specify the content type. | 'application/json' |
disable_get |
Used to disable the GET method. | false |
disable_post |
Used to disable the POST method. | false |
success_content_type |
Used to specify the content type for successful responses. | 'application/json' |
error_content_type |
Used to specify the content type for error responses. | 'plain/text' |
examples |
Used to provide examples. | {} |
tags |
Used to specify the tags. | ['📑 Zencodes'] |
hidden |
Used to hide the endpoint. | false |
hide_from_openapi |
Used to hide the endpoint from OpenAPI documentation. | false |
precondition |
Used to specify a path to a slangroom contract to be used as precondition. | false |