# Installation & Setup

3 min read (537 words)

# Table of contents

# Prerequisite

Before creating your first ZenTS application you must install the following dependencies:

It's highly recommend to install Node.js with a versions manager like nvm (opens new window).

Furthermore, ZenTS has a dependency to node-gyp, which has a few dependencies that needs to be installed before installing ZenTS. Please check the official documentation (opens new window) for more details.

# Installing & Using ZenTS-CLI

The ZenTS framework offers a CLI utility belt, which ease the pain of developing a TypeScript application. While completely optional, it's highly recommend to install ZenTS CLI. The rest of the documentation will use the CLI for its explanations.

To install the CLI, open a terminal and type:

npm i zents-cli -g
1

This will install the CLI as a global command. Try it out by running...

zen --version
1

...in your terminal. If the installation was successfully, this should show you the installed version of the CLI and you're ready to use it now.

# Creating your first ZenTS application

After the CLI is installed we can create our first ZenTS project. Open your terminal and run this command:

zen create myproject
cd myproject
1
2

This command will create a new ZenTS application called myproject inside a newly created myproject folder (relative) to the folder you executed the command.

TIP

If the folder already exists, and you like to delete it before, you can call the create command with a --clean flag.

# Directory structure

After the application has been created the directory structure looks like this:

|-- src
    |-- index.ts
    |-- controller // place your controller files here
    |   |-- MyController.ts
    |-- entity // your database entities are located here
    |   |-- MyEntity.ts
    |-- service // services are saved inside this folder
    |   |-- MyService.ts
    |-- view // place your template files here
        |-- index.njk
|-- package.json // npm's package.json
|-- tsconfig.json // TypeScript configuration file
|-- zen.json // ZenTS configuration file
1
2
3
4
5
6
7
8
9
10
11
12
13

Don't worry, we will cover all the listen directories detailed later in this guide.

# Running the application

Running the application is quiet easy with the CLI. Just open your terminal again and type:

cd /path/to/myproject
zen dev
1
2

WARNING

Don't use the dev command in production. In production mode, you should install a webserver like nginx (opens new window) or Apache (opens new window) which serves as proxy in front of your ZenTS application.

TIP

Head over to the CLI documentation to learn more about the commands (like dev), options and flags the CLI provides.

The dev command is a convenient way to lunch a development server. This will start the TypeScript compiler with the --watch flag attached, which will watch your source files for changes and recompile when your code changed. In addition, a web-server will be started with hot reloading enabled. Open your favorite browser and navigate to http://localhost:8080 (opens new window). You should see the default starting page of a ZenTS application.

# Start writing your ZenTS application

Congratulations! Everything has been setup and you're ready to write your custom application. Head over to the next section to figure out more and create your the iconical Hello World example.