Getting started
Installation
Marble.js requires node v8.0 or higher:
or if you are a hipster:
Bootstrapping
The very basic configuration consists of two steps: HTTP listener definition and HTTP server configuration.
httpListener
is the basic starting point of every Marble application. It includes definitions of all middlewares and API effects.
And here is our simple "hello world" endpoint.
To create Marble app instance, we can use createServer
, which is a wrapper around Node.js server creator with much more possibilities and goods inside. When created, it won't automatically start listening to given port and hostname until you call .run()
method on it.
you can always visit example repository for a complete Marble.js app example.
We'll use TypeScript in the documentation but you can always write Marble apps in standard JavaScript (and any other language that transpiles to JavaScript).
To test run your server you can install typescript
compiler and ts-node
:
then add the following script to your package.json
file:
Now go ahead, create server.ts
, http.listener.ts
, api.effects.ts
modules in your project and run your server:
finally test your "functional" server by visiting http://localhost:1337
For more API specific details about server bootstraping, visit createServer API reference.
If you prefer to have standard Node.js control over server creation, you can also easily hook the app directly into Node.js http.createServer
In the next chapter you will learn how to create basic Marble.js endpoints using Effects.
Last updated