Skip to content
franck-yvetot edited this page Mar 24, 2024 · 7 revisions

Tutorial : using nxn-boot

Overview

Framework for large scale applications, supporting configuration file, services, routes, express middleware, client data.

This npm module addresses requirements of medium to large applications.

Base components for creating REST API

  • Routes : for creating REST controllers,
  • Services : for doing actual work ("providers"),

Routes and services are simple classes with optional "init()" functions. These classes are listed in a YAML file and loaded by nxn at boot time.

see sample below...

Install

Install @nxn/boot cli nxg from npm:

npm install -g @nxn/cli

init the project:

nxg init

and install dependencies:

npm install

This creates following file structure:

File structure
  • index.js : main file, that you never need to modify
  • a basic README.md for your documentation
  • client_data/default/config_default.yml : where all components are defined.
  • package.json with dependencies and scripts.
  • Dockerfile that should work for most cases.

Basically: index.js loads the application config_default.yml and initialises all components. Then it runs express (default server here).

##Run the generated sample:##

Run the sample:

node index.js

or

npm start

You should then see :

Output

The application is then up and running.. It doesnt do much right now but everything is ready. Have a look on the config file and you'll see sections where routes, services, run, tests anf middleware will be listed.

Docker

Just to make sure Dowker is also ready to go, create the image and run it:

npm run docker
npm run docker:run

You should then see the image running as well if Docker is installed on your workstation.

NEXT >> Sample

Clone this wiki locally