# Installation

To get started with ExpressWebJs, you will need to install Node.js >= v14.15.1 and npm >= 6.0.0

Because we want it to be as easy as possible getting started with ExpressWebJs, that's while we have a command line tool to help you install ExpressWebJs.

To start your new typescript project, you can use npx expresswebcli new command, followed by your project name and --ts or --typescript.

--ts or --typescript flag tells Expresswebjs to generate the typescript version. Example:

 npx expresswebcli new ritetech --ts
      or
 npx expresswebcli new ritetech --typescript

Or you can install it globally via npm like so:

npm install -g expresswebcli

and then run to create your new ritetech application.

  expresswebcli new ritetech --ts
      or
  expresswebcli new ritetech --typescript

Make sure to add the npm system-wide node_modules/.bin directory to your $PATH to be able to access the installed binary.

Once that is done,

 cd ritetech

Once you do that, you can now install all dependencies by running npm install.

 npm install

In version 2 upwards, MAKER command line interface is included in ExpressWebJs. Maker exists at the root of your application as the maker script and provides a number of helpful commands that can assist you while you build your application.

Run the following code once you have created your new application to see all maker commands.

  ts-node maker -h

# Database Setup

ExpressWebJs makes interacting with SQL and NOSQL databases extremely easy across a variety of supported database.

  • MySql
  • MariaDB
  • PostgreSQL
  • Amazon Redshift
  • SQLite3
  • Oracle
  • MicroSoft SQL
  • MongoDB

Befor we continue, if you've not created your .env file, quickly do that by copying example.env to .env file or you can run the following command in your terminal:

   cp example.env .env

Now that our .env file is ready, the configuration for ExpressWebJs database is located in Config/database.ts configuration file. In this file, you may define all of your database connections, as well as specify which connection should be used by default. Most of the configuration options within this file are driven by the values of your application's environment variables.

# SQL Database configuration

You can easily configure your environment variables to point to your database by placing the connection values in the .env file: Let's connect to mysql database

DB_SHOULD_CONNECT = true; //should connect to database
DB_CONNECTION = mysql; //database
DB_HOST = localhost; //database host
DB_PORT = 3306; //database port
DB_USER = DB_PASSWORD = DB_DATABASE = DB_USENEWURLPARSER = true; //database username //database password //database name
DB_USEUNIFIEDTOPOLOGY = true;
DB_USECREATEINDEX = true;

# NOSQL Database configuration

You can configure your nosql database environment variables to point to your database by placing the connection values in the .env file: Let's connect to mongoDB

DB_SHOULD_CONNECT = true; //should connect to database
DB_CONNECTION = mongoose; //database
DB_HOST = localhost; //database host
DB_PORT = 27017; //database port
DB_USER = DB_PASSWORD = DB_DATABASE = DB_USENEWURLPARSER = true; //database username //database password //database name
DB_USEUNIFIEDTOPOLOGY = true;
DB_USECREATEINDEX = true;

Once that is done, you can now run your application with:

  npm run dev

# Initial Configuration

ExpressWebJs configuration files are stored in the application config directory Config. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

You are free to get started developing! However, you may wish to review the Config/app.ts file and its documentation. It contains several options you may wish to change according to your application.